Author: rgodfrey
Date: Thu Dec  1 14:33:24 2016
New Revision: 1772214

URL: http://svn.apache.org/viewvc?rev=1772214&view=rev
Log:
QPID-7546 : BrokerClosesClientConnectionTest

Modified:
    
qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
    qpid/java/trunk/test-profiles/Java10Excludes
    qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes

Modified: 
qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java?rev=1772214&r1=1772213&r2=1772214&view=diff
==============================================================================
--- 
qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
 (original)
+++ 
qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/client/connection/BrokerClosesClientConnectionTest.java
 Thu Dec  1 14:33:24 2016
@@ -192,24 +192,108 @@ public class BrokerClosesClientConnectio
     private void assertConnectionCloseWasReported(Exception exception, Class<? 
extends Exception> linkedExceptionClass)
     {
         assertNotNull("Did not receive exception", exception);
-        assertNotNull("Exception should have a cause", exception.getCause());
-        assertEquals("Unexpected exception cause", linkedExceptionClass, 
exception.getCause().getClass());
+        if(!isBroker10())
+        {
+            assertNotNull("Exception should have a cause", 
exception.getCause());
+            assertEquals("Unexpected exception cause", linkedExceptionClass, 
exception.getCause().getClass());
+        }
     }
 
     private void assertJmsObjectsClosed()
     {
-        assertTrue("Connection should be marked as closed", ((AMQConnection) 
_connection).isClosed());
-        assertTrue("Session should be marked as closed", ((AMQSession) 
_session).isClosed());
-        assertTrue("Producer should be marked as closed", 
((BasicMessageProducer) _producer).isClosed());
-        assertTrue("Consumer should be marked as closed", 
((BasicMessageConsumer) _consumer).isClosed());
+        assertTrue("Connection should be marked as closed", 
connectionIsClosed());
+        assertTrue("Session should be marked as closed", sessionIsClosed());
+        assertTrue("Producer should be marked as closed", producerIsClosed());
+        assertTrue("Consumer should be marked as closed", consumerIsClosed());
+    }
+
+    private boolean producerIsClosed()
+    {
+        if(isBroker10())
+        {
+            try
+            {
+                _producer.setPriority(7);
+                return false;
+            }
+            catch (JMSException e)
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return ((BasicMessageProducer) _producer).isClosed();
+        }
+
+    }
+
+    private boolean sessionIsClosed()
+    {
+        if(isBroker10())
+        {
+            try
+            {
+                _session.createProducer(null);
+                return false;
+            }
+            catch (JMSException e)
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return ((AMQSession) _session).isClosed();
+        }
+    }
+
+    private boolean connectionIsClosed()
+    {
+        if(isBroker10())
+        {
+            try
+            {
+                _connection.stop();
+                return false;
+            }
+            catch (JMSException e)
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return ((AMQConnection) _connection).isClosed();
+        }
     }
 
     private void assertJmsObjectsOpen()
     {
-        assertFalse("Connection should not be marked as closed", 
((AMQConnection) _connection).isClosed());
-        assertFalse("Session should not be marked as closed", ((AMQSession) 
_session).isClosed());
-        assertFalse("Producer should not be marked as closed", 
((BasicMessageProducer) _producer).isClosed());
-        assertFalse("Consumer should not be marked as closed", 
((BasicMessageConsumer) _consumer).isClosed());
+        assertFalse("Connection should not be marked as closed", 
connectionIsClosed());
+        assertFalse("Session should not be marked as closed", 
sessionIsClosed());
+        assertFalse("Producer should not be marked as closed", 
producerIsClosed());
+        assertFalse("Consumer should not be marked as closed", 
consumerIsClosed());
+    }
+
+    private boolean consumerIsClosed()
+    {
+        if(isBroker10())
+        {
+            try
+            {
+                _consumer.getMessageSelector();
+                return false;
+            }
+            catch (JMSException e)
+            {
+                return true;
+            }
+        }
+        else
+        {
+            return ((BasicMessageConsumer) _consumer).isClosed();
+        }
     }
 
     private final class RecordingExceptionListener implements ExceptionListener
@@ -253,10 +337,11 @@ public class BrokerClosesClientConnectio
         Listener listener = new Listener();
 
         Session session = _connection.createSession(false, 
Session.CLIENT_ACKNOWLEDGE);
-        MessageConsumer consumer1 = session.createConsumer(getTestQueue());
+        final Queue testQueue = createTestQueue(session);
+        MessageConsumer consumer1 = session.createConsumer(testQueue);
         consumer1.setMessageListener(listener);
 
-        MessageProducer producer = _session.createProducer(getTestQueue());
+        MessageProducer producer = _session.createProducer(testQueue);
         producer.send(_session.createTextMessage("test message"));
 
         _connection.start();
@@ -276,14 +361,14 @@ public class BrokerClosesClientConnectio
 
         Connection connection2 = getConnection();
         Session session2 = connection2.createSession(false, 
Session.CLIENT_ACKNOWLEDGE);
-        MessageConsumer consumer2 = session2.createConsumer(getTestQueue());
+        MessageConsumer consumer2 = session2.createConsumer(testQueue);
         consumer2.setMessageListener(listener);
         connection2.start();
 
 
         Connection connection3 = getConnection();
         Session session3 = connection3.createSession(false, 
Session.CLIENT_ACKNOWLEDGE);
-        MessageConsumer consumer3 = session3.createConsumer(getTestQueue());
+        MessageConsumer consumer3 = session3.createConsumer(testQueue);
         consumer3.setMessageListener(listener);
         connection3.start();
 

Modified: qpid/java/trunk/test-profiles/Java10Excludes
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10Excludes?rev=1772214&r1=1772213&r2=1772214&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10Excludes (original)
+++ qpid/java/trunk/test-profiles/Java10Excludes Thu Dec  1 14:33:24 2016
@@ -155,11 +155,17 @@ org.apache.qpid.test.unit.client.Dynamic
 // this should probably be tested in a new protocol specific broker test
 org.apache.qpid.transport.ConnectionEstablishmentTest#*
 
+// test of 0-10 client specific behaviour
 org.apache.qpid.test.client.message.JMSDestinationTest#testReceiveResend
+// BURL specific tests
 
org.apache.qpid.test.client.message.JMSDestinationTest#testQueueWithBindingUrlUsingCustomExchange
 
org.apache.qpid.test.client.message.JMSDestinationTest#testQueueWithBindingUrlUsingAmqDirectExchange
 
org.apache.qpid.test.client.message.JMSDestinationTest#testQueueWithBindingUrlUsingDefaultExchange
 
+// test of 0-x client threading / exception handling
+org.apache.qpid.test.unit.close.JavaServerCloseRaceConditionTest#*
+
+
 
 
 

Modified: qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes?rev=1772214&r1=1772213&r2=1772214&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes (original)
+++ qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes Thu Dec  1 
14:33:24 2016
@@ -32,9 +32,7 @@ org.apache.qpid.server.security.acl.Exte
 org.apache.qpid.server.security.acl.ExhaustiveACLTest#*
 org.apache.qpid.server.queue.ModelTest#*
 org.apache.qpid.test.unit.topic.DurableSubscriptionTest#*
-org.apache.qpid.test.unit.close.JavaServerCloseRaceConditionTest#*
 org.apache.qpid.test.unit.client.MaxDeliveryCountTest#*
-org.apache.qpid.test.unit.client.connection.BrokerClosesClientConnectionTest#*
 org.apache.qpid.test.client.queue.LVQTest#*
 org.apache.qpid.systest.rest.ConnectionRestTest#*
 org.apache.qpid.systest.rest.MessagesRestTest#*



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

Reply via email to