/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.fusesource.amqpjms.jms.transactions;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import javax.jms.Connection;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;

import org.apache.activemq.broker.jmx.QueueViewMBean;
import org.fusesource.amqpjms.jms.JmsConnection;
import org.fusesource.amqpjms.jms.JmsConnectionFactory;
import org.fusesource.amqpjms.util.AmqpTestSupport;
import org.junit.Ignore;
import org.junit.Test;

/**
 * Test for messages produced inside a local transaction.
 */
public class JmsTransactedProducerTest extends AmqpTestSupport {

    @Test(timeout = 60000)
    public void testCreateTxSessionAndProducer() throws Exception {
        JmsConnectionFactory factory = new JmsConnectionFactory(getBrokerAmqpConnectionURI());
        JmsConnection connection = (JmsConnection) factory.createConnection();
        assertNotNull(connection);
        connection.start();

        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
        assertNotNull(session);
        assertTrue(session.getTransacted());

        Queue queue = session.createQueue(name.getMethodName());
        MessageProducer producer = session.createProducer(queue);
        assertNotNull(producer);

        connection.close();
    }

    @Test(timeout = 60000)
    public void testTXProducerCommitsAreQueued() throws Exception {
        final int MSG_COUNT = 10;
        Connection connection = createAmqpConnection();
        connection.start();
        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
        Queue queue = session.createQueue(name.getMethodName());
        MessageProducer producer = session.createProducer(queue);

        for (int i = 0; i < MSG_COUNT; ++i) {
            producer.send(session.createTextMessage());
        }

        QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
        session.commit();
        assertEquals(MSG_COUNT, proxy.getQueueSize());
        connection.close();
    }

    @Ignore
    @Test(timeout = 60000)
    public void testTXProducerRollbacksNotQueued() throws Exception {
        final int MSG_COUNT = 10;
        Connection connection = createAmqpConnection();
        connection.start();
        Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
        Queue queue = session.createQueue(name.getMethodName());
        MessageProducer producer = session.createProducer(queue);

        for (int i = 0; i < MSG_COUNT; ++i) {
            producer.send(session.createTextMessage());
        }

        QueueViewMBean proxy = getProxyToQueue(name.getMethodName());
        session.rollback();
        assertEquals(0, proxy.getQueueSize());
        connection.close();
    }

}

@@ -979,42 +979,145 @@
 sert
-True;%0A%0Aimport javax.jms.Connection
+Null;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport javax.jms.Connection;%0Aimport javax.jms.Message;%0Aimport javax.jms.MessageConsumer
 ;%0Aim
@@ -2284,24 +2284,36 @@
 e();%0A    %7D%0A%0A
+    @Ignore%0A
     @Test(ti
@@ -2319,32 +2319,32 @@
 imeout = 60000)%0A
-
     public void 
@@ -2591,32 +2591,122 @@
 ON_TRANSACTED);%0A
+        Session nonTxSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);%0A
         Queue qu
@@ -2915,32 +2915,32 @@
 TextMessage());%0A
-
         %7D%0A%0A     
@@ -2926,32 +2926,175 @@
 ());%0A        %7D%0A%0A
+        MessageConsumer consumer = nonTxSession.createConsumer(queue);%0A        Message msg = consumer.receive(5000);%0A        assertNull(msg);%0A%0A
         QueueVie

Update test case and add ignore as it now fails.