Repository: qpid-jms Updated Branches: refs/heads/master fd0cd2c79 -> b23f531af
Some test cleanups and enhancements. Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/b23f531a Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/b23f531a Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/b23f531a Branch: refs/heads/master Commit: b23f531afd80b8dc680703585e6347cf0b38bfd9 Parents: fd0cd2c Author: Timothy Bish <tabish...@gmail.com> Authored: Fri Jan 9 17:56:54 2015 -0500 Committer: Timothy Bish <tabish...@gmail.com> Committed: Fri Jan 9 17:56:54 2015 -0500 ---------------------------------------------------------------------- .../jms/discovery/JmsDiscoveryProviderTest.java | 12 +++++-- .../qpid/jms/failover/JmsFailoverTest.java | 38 +++++++++++++------- .../qpid/jms/support/QpidJmsTestSupport.java | 27 ++++++++++++-- 3 files changed, 59 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b23f531a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsDiscoveryProviderTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsDiscoveryProviderTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsDiscoveryProviderTest.java index a117687..627b687 100644 --- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsDiscoveryProviderTest.java +++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/discovery/JmsDiscoveryProviderTest.java @@ -48,8 +48,16 @@ public class JmsDiscoveryProviderTest { @Before public void setup() throws Exception { broker = createBroker(); - broker.start(); - broker.waitUntilStarted(); + try { + broker.start(); + broker.waitUntilStarted(); + } catch (Exception e) { + try { + broker.stop(); + } catch (Exception ignore) {} + + throw e; + } } @After http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b23f531a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java ---------------------------------------------------------------------- diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java index d615f3d..64107d6 100644 --- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java +++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/failover/JmsFailoverTest.java @@ -19,6 +19,7 @@ package org.apache.qpid.jms.failover; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.net.URI; import java.util.concurrent.CountDownLatch; @@ -68,22 +69,38 @@ public class JmsFailoverTest extends AmqpTestSupport { connection.close(); } - @Test(timeout=60000, expected=JMSException.class) + @Test(timeout=60000) public void testStartupReconnectAttempts() throws Exception { URI brokerURI = new URI("failover://(amqp://localhost:61616)" + "?maxReconnectDelay=1000&startupMaxReconnectAttempts=5"); JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI); Connection connection = factory.createConnection(); - connection.start(); + try { + connection.start(); + fail("Should have thrown an exception of type JMSException"); + } catch (JMSException jmsEx) { + } catch (Exception unexpected) { + fail("Should have thrown a JMSException but threw: " + unexpected.getClass().getSimpleName()); + } finally { + connection.close(); + } } - @Test(timeout=60000, expected=JMSException.class) + @Test(timeout=60000) public void testStartupReconnectAttemptsMultipleHosts() throws Exception { URI brokerURI = new URI("failover://(amqp://localhost:61616,amqp://localhost:61617)" + "?maxReconnectDelay=1000&startupMaxReconnectAttempts=5"); JmsConnectionFactory factory = new JmsConnectionFactory(brokerURI); Connection connection = factory.createConnection(); - connection.start(); + try { + connection.start(); + fail("Should have thrown an exception of type JMSException"); + } catch (JMSException jmsEx) { + } catch (Exception unexpected) { + fail("Should have thrown a JMSException but threw: " + unexpected.getClass().getSimpleName()); + } finally { + connection.close(); + } } @Test(timeout=60000) @@ -100,7 +117,7 @@ public class JmsFailoverTest extends AmqpTestSupport { failed.countDown(); } }); - Connection connection = factory.createConnection(); + connection = factory.createConnection(); connection.start(); stopPrimaryBroker(); @@ -113,7 +130,7 @@ public class JmsFailoverTest extends AmqpTestSupport { public void testBasicStateRestoration() throws Exception { URI brokerURI = new URI(getAmqpFailoverURI() + "?maxReconnectDelay=1000"); - Connection connection = createAmqpConnection(brokerURI); + connection = createAmqpConnection(brokerURI); connection.start(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -136,8 +153,6 @@ public class JmsFailoverTest extends AmqpTestSupport { assertEquals(1, brokerService.getAdminView().getQueueSubscribers().length); assertEquals(1, brokerService.getAdminView().getQueueProducers().length); - - connection.close(); } @SuppressWarnings("unused") @@ -145,7 +160,7 @@ public class JmsFailoverTest extends AmqpTestSupport { public void testDurableSubscriberRestores() throws Exception { URI brokerURI = new URI(getAmqpFailoverURI() + "?maxReconnectDelay=1000"); - Connection connection = createAmqpConnection(brokerURI); + connection = createAmqpConnection(brokerURI); connection.setClientID(name.getMethodName()); connection.start(); @@ -180,8 +195,6 @@ public class JmsFailoverTest extends AmqpTestSupport { return brokerService.getAdminView().getDurableTopicSubscribers().length == 1; } })); - - connection.close(); } @Test(timeout=90000) @@ -189,7 +202,7 @@ public class JmsFailoverTest extends AmqpTestSupport { URI brokerURI = new URI("failover://(amqp://localhost:61616," + getBrokerAmqpConnectionURI() + ")?maxReconnectDelay=1000"); - Connection connection = createAmqpConnection(brokerURI); + connection = createAmqpConnection(brokerURI); connection.start(); final int MSG_COUNT = 10; @@ -216,7 +229,6 @@ public class JmsFailoverTest extends AmqpTestSupport { })); assertFalse(failed.getCount() == 0); - connection.close(); } // TODO - FIXME http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b23f531a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/support/QpidJmsTestSupport.java ---------------------------------------------------------------------- diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/support/QpidJmsTestSupport.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/support/QpidJmsTestSupport.java index f41c778..3580a89 100644 --- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/support/QpidJmsTestSupport.java +++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/support/QpidJmsTestSupport.java @@ -91,14 +91,35 @@ public class QpidJmsTestSupport { @After public void tearDown() throws Exception { LOG.info("========== tearDown " + getTestName() + " =========="); + Exception firstError = null; + if (connection != null) { - connection.close(); + try { + connection.close(); + } catch (Exception e) { + LOG.warn("Error detected on connection close in tearDown: {}", e.getMessage()); + firstError = e; + } } - stopPrimaryBroker(); + + try { + stopPrimaryBroker(); + } catch (Exception e) { + LOG.warn("Error detected on close of broker in tearDown: {}", e.getMessage()); + firstError = e; + } + for (BrokerService broker : brokers) { try { stopBroker(broker); - } catch (Exception ex) {} + } catch (Exception ex) { + LOG.warn("Error detected on close of broker in tearDown: {}", ex.getMessage()); + firstError = ex; + } + } + + if (firstError != null) { + throw firstError; } } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org