qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject qpid-broker-j git commit: QPID-6933: [System Tests] Remove redundant tests
Date Fri, 01 Dec 2017 09:22:08 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 0a3b816ba -> 1fc001fea


QPID-6933: [System Tests] Remove redundant tests

* Tests in MessageConsumerCloseTest duplicate tests from CommitRollbackTest
* Test in TopicPublisherCloseTest is moved into TopicSessionTest


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/1fc001fe
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/1fc001fe
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/1fc001fe

Branch: refs/heads/master
Commit: 1fc001fea0305ca26fad887377f0b0bb2ded46c7
Parents: 0a3b816
Author: Alex Rudyy <orudyy@apache.org>
Authored: Fri Dec 1 09:21:51 2017 +0000
Committer: Alex Rudyy <orudyy@apache.org>
Committed: Fri Dec 1 09:21:51 2017 +0000

----------------------------------------------------------------------
 .../jms_1_1/topic/TopicSessionTest.java         |  28 +++
 .../jms_1_1/transaction/CommitRollbackTest.java |  49 ++++-
 .../unit/close/MessageConsumerCloseTest.java    | 184 -------------------
 .../unit/close/TopicPublisherCloseTest.java     |  68 -------
 4 files changed, 74 insertions(+), 255 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1fc001fe/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/TopicSessionTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/TopicSessionTest.java
b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/TopicSessionTest.java
index 15e2b4b..3ea05d7 100644
--- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/TopicSessionTest.java
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/topic/TopicSessionTest.java
@@ -25,7 +25,9 @@ import static org.junit.Assert.fail;
 import javax.jms.JMSException;
 import javax.jms.Queue;
 import javax.jms.Session;
+import javax.jms.Topic;
 import javax.jms.TopicConnection;
+import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 import javax.naming.NamingException;
 
@@ -96,6 +98,32 @@ public class TopicSessionTest extends JmsTestBase
         }
     }
 
+    @Test
+    public void publisherGetDeliveryModeAfterConnectionClose() throws Exception
+    {
+        Topic topic = createTopic(getTestName());
+        TopicConnection connection =  getTopicConnection();
+        try
+        {
+            TopicSession session = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+            TopicPublisher publisher = session.createPublisher(topic);
+            connection.close();
+            try
+            {
+                publisher.getDeliveryMode();
+                fail("Expected exception not thrown");
+            }
+            catch (javax.jms.IllegalStateException e)
+            {
+                // PASS
+            }
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+
     private TopicConnection getTopicConnection() throws JMSException, NamingException
     {
         return (TopicConnection)getConnection();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1fc001fe/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/transaction/CommitRollbackTest.java
----------------------------------------------------------------------
diff --git a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/transaction/CommitRollbackTest.java
b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/transaction/CommitRollbackTest.java
index 9583c90..d3339d7 100644
--- a/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/transaction/CommitRollbackTest.java
+++ b/systests/qpid-systests-jms_1.1/src/test/java/org/apache/qpid/systests/jms_1_1/transaction/CommitRollbackTest.java
@@ -533,6 +533,51 @@ public class CommitRollbackTest extends JmsTestBase
     }
 
     @Test
+    public void rollbackWithinMessageListener() throws Exception
+    {
+        Queue queue = createQueue(getTestName());
+        Connection connection = getConnection();
+        try
+        {
+            final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
+            final MessageConsumer consumer = session.createConsumer(queue);
+            Utils.sendMessages(session, queue, 2);
+            connection.start();
+            final CountDownLatch receiveLatch = new CountDownLatch(2);
+            final AtomicInteger receiveCounter = new AtomicInteger();
+            final AtomicReference<Throwable> messageListenerThrowable = new AtomicReference<>();
+            consumer.setMessageListener(message -> {
+                try
+                {
+                    if (receiveCounter.incrementAndGet()<3)
+                    {
+                        session.rollback();
+                    }
+                    else
+                    {
+                        session.commit();
+                        receiveLatch.countDown();
+                    }
+                }
+                catch (Throwable e)
+                {
+                    messageListenerThrowable.set(e);
+                }
+            });
+
+            assertTrue("Timeout waiting for messages",
+                       receiveLatch.await(getReceiveTimeout() * 4, TimeUnit.MILLISECONDS));
+            assertNull("Exception occurred: " + messageListenerThrowable.get(),
+                       messageListenerThrowable.get());
+            assertEquals("Unexpected number of received messages", 4, receiveCounter.get());
+        }
+        finally
+        {
+            connection.close();
+        }
+    }
+
+    @Test
     public void exhaustedPrefetchInTransaction() throws Exception
     {
         final int maxPrefetch = 2;
@@ -646,7 +691,7 @@ public class CommitRollbackTest extends JmsTestBase
             transactedSession.commit();
             fail("Commit on closed connection should throw IllegalStateException!");
         }
-        catch(IllegalStateException e)
+        catch (IllegalStateException e)
         {
             // passed
         }
@@ -723,6 +768,4 @@ public class CommitRollbackTest extends JmsTestBase
             connection.close();
         }
     }
-
-
 }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1fc001fe/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
b/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
deleted file mode 100644
index 20e57e7..0000000
--- a/systests/src/test/java/org/apache/qpid/test/unit/close/MessageConsumerCloseTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- *
- * 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.apache.qpid.test.unit.close;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.Session;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-public class MessageConsumerCloseTest  extends QpidBrokerTestCase
-{
-    private volatile Exception _exception;
-
-    /**
-     * JMS Session says "The content of a transaction's input and output units is simply
those messages that have
-     * been produced and consumed within the session's current transaction.".  Closing a
consumer must not therefore
-     * prevent previously received messages from being committed.
-     */
-    public void testConsumerCloseAndSessionCommit() throws Exception
-    {
-        Connection connection = getConnection();
-        connection.start();
-        final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-        Destination destination = createTestQueue(session);
-        MessageConsumer consumer1 = session.createConsumer(destination);
-        sendMessage(session, destination, 2);
-
-
-        Message message = consumer1.receive(RECEIVE_TIMEOUT);
-        assertNotNull("First message is not received", message);
-        assertEquals("First message unexpected has unexpected property", 0, message.getIntProperty(INDEX));
-        consumer1.close();
-
-        session.commit();
-
-        MessageConsumer consumer2 = session.createConsumer(destination);
-        message = consumer2.receive(RECEIVE_TIMEOUT);
-        assertNotNull("Second message is not received", message);
-        assertEquals("Second message unexpected has unexpected property", 1, message.getIntProperty(INDEX));
-
-        message = consumer2.receive(100l);
-        assertNull("Unexpected third message", message);
-    }
-
-
-    public void testConsumerCloseAndSessionRollback() throws Exception
-    {
-        Connection connection = getConnection();
-        final CountDownLatch receiveLatch = new CountDownLatch(1);
-        final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-        Destination destination = createTestQueue(session);
-        MessageConsumer consumer = session.createConsumer(destination);
-        sendMessage(session, destination, 2);
-        connection.start();
-        consumer.setMessageListener(new MessageListener()
-        {
-            @Override
-            public void onMessage(Message message)
-            {
-                try
-                {
-                    receiveLatch.countDown();
-                    session.rollback();
-                }
-                catch (JMSException e)
-                {
-                    _exception = e;
-                }
-            }
-        });
-        boolean messageReceived = receiveLatch.await(1l, TimeUnit.SECONDS);
-        consumer.close();
-
-        assertNull("Exception occurred on rollback:" + _exception, _exception);
-        assertTrue("Message is not received", messageReceived);
-
-        consumer = session.createConsumer(destination);
-        final CountDownLatch receiveLatch2 = new CountDownLatch(2);
-        consumer.setMessageListener(new MessageListener()
-        {
-            @Override
-            public void onMessage(Message message)
-            {
-                receiveLatch2.countDown();
-            }
-        });
-        assertTrue( receiveLatch2.await(1l, TimeUnit.SECONDS));
-    }
-
-    public void testPrefetchedMessagesReleasedOnConsumerClose() throws Exception
-    {
-        Connection connection = getConnection();
-        final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-        Destination destination = createTestQueue(session);
-        MessageConsumer consumer = session.createConsumer(destination);
-
-        sendMessage(session, destination, 3);
-
-        connection.start();
-
-        Message msg1 = consumer.receive(1000);
-        assertNotNull("Message one was null", msg1);
-        assertEquals("Message one has unexpected content", 0, msg1.getIntProperty(INDEX));
-        session.commit();
-
-        // Messages two and three will have been prefetched by the consumer.
-        // Closing the consumer must make the available for delivery elsewhere
-
-        consumer.close();
-
-        MessageConsumer consumer2 = session.createConsumer(destination);
-
-        Message msg2 = consumer2.receive(1000);
-        Message msg3 = consumer2.receive(1000);
-        assertNotNull("Message two was null", msg2);
-        assertEquals("Message two has unexpected content", 1, msg2.getIntProperty(INDEX));
-
-        assertNotNull("Message three was null", msg3);
-        assertEquals("Message three has unexpected content", 2, msg3.getIntProperty(INDEX));
-        session.commit();
-    }
-
-    public void testMessagesReceivedBeforeConsumerCloseAreRedeliveredAfterRollback() throws
Exception
-    {
-        Connection connection = getConnection();
-        final Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
-
-        Destination destination = createTestQueue(session);
-        MessageConsumer consumer = session.createConsumer(destination);
-
-        int messageNumber = 4;
-        connection.start();
-        sendMessage(session, destination, messageNumber);
-
-        for(int i = 0; i < messageNumber/2 ; i++)
-        {
-            Message message = consumer.receive(RECEIVE_TIMEOUT);
-            assertNotNull("Message [" + i +"] was null", message);
-            assertEquals("Message [" + i +"] has unexpected content", i, message.getIntProperty(INDEX));
-        }
-
-        consumer.close();
-
-        session.rollback();
-
-        MessageConsumer consumer2 = session.createConsumer(destination);
-
-        for(int i = 0; i < messageNumber ; i++)
-        {
-            Message message = consumer2.receive(RECEIVE_TIMEOUT);
-            assertNotNull("Message [" + i +"] was null", message);
-            assertEquals("Message [" + i +"] has unexpected content", i, message.getIntProperty(INDEX));
-        }
-
-        session.commit();
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/1fc001fe/systests/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
----------------------------------------------------------------------
diff --git a/systests/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
b/systests/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
deleted file mode 100644
index f4d4ebe..0000000
--- a/systests/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * 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.apache.qpid.test.unit.close;
-
-import javax.jms.Session;
-import javax.jms.Topic;
-import javax.jms.TopicConnection;
-import javax.jms.TopicPublisher;
-import javax.jms.TopicSession;
-
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
-/**
- * @author Apache Software Foundation
- */
-public class TopicPublisherCloseTest extends QpidBrokerTestCase
-{
-
-    @Override
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-    }
-
-
-    @Override
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-    }
-
-    public void testAllMethodsThrowAfterConnectionClose() throws Exception
-    {
-        TopicConnection connection =   (TopicConnection) getConnection();
-
-        Topic destination1 = createTopic(connection, "t1");
-        TopicSession session1 = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
-        TopicPublisher pub = session1.createPublisher(destination1);
-        connection.close();
-        try
-        {
-            pub.getDeliveryMode();
-            fail("Expected exception not thrown");
-        }
-        catch (javax.jms.IllegalStateException e)
-        {
-            // PASS
-        }
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message