fix potential NPE

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1490311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2013-06-06 14:51:52 +00:00
parent c161033abb
commit bfed9df3b7
1 changed files with 3 additions and 11 deletions

View File

@ -72,7 +72,6 @@ public class AmqpTransformerTest {
amqpSession.close(); amqpSession.close();
amqpConnection.close(); amqpConnection.close();
// receive with openwire JMS // receive with openwire JMS
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort);
Connection openwireConn = factory.createConnection(); Connection openwireConn = factory.createConnection();
@ -95,10 +94,9 @@ public class AmqpTransformerTest {
c.close(); c.close();
session.close(); session.close();
openwireConn.close(); openwireConn.close();
} }
@Test(timeout=30000) @Test(timeout = 30000)
public void testRawTransformation() throws Exception { public void testRawTransformation() throws Exception {
// default is native // default is native
@ -120,7 +118,6 @@ public class AmqpTransformerTest {
amqpSession.close(); amqpSession.close();
amqpConnection.close(); amqpConnection.close();
// receive with openwire JMS // receive with openwire JMS
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort);
Connection openwireConn = factory.createConnection(); Connection openwireConn = factory.createConnection();
@ -139,15 +136,13 @@ public class AmqpTransformerTest {
assertTrue("Didn't use the correct transformation, expected NATIVE", nativeTransformationUsed); assertTrue("Didn't use the correct transformation, expected NATIVE", nativeTransformationUsed);
assertEquals(2, message.getJMSDeliveryMode()); assertEquals(2, message.getJMSDeliveryMode());
// should not equal 7 (should equal the default) because "raw" does not map // should not equal 7 (should equal the default) because "raw" does not map
// headers // headers
assertEquals(4, message.getJMSPriority()); assertEquals(4, message.getJMSPriority());
c.close(); c.close();
session.close(); session.close();
openwireConn.close(); openwireConn.close();
} }
@Test @Test
@ -171,7 +166,6 @@ public class AmqpTransformerTest {
amqpSession.close(); amqpSession.close();
amqpConnection.close(); amqpConnection.close();
// receive with openwire JMS // receive with openwire JMS
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort); ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://0.0.0.0:" + openwirePort);
Connection openwireConn = factory.createConnection(); Connection openwireConn = factory.createConnection();
@ -193,7 +187,6 @@ public class AmqpTransformerTest {
c.close(); c.close();
session.close(); session.close();
openwireConn.close(); openwireConn.close();
} }
public Connection createAmqpConnection() throws JMSException { public Connection createAmqpConnection() throws JMSException {
@ -209,14 +202,13 @@ public class AmqpTransformerTest {
return connection; return connection;
} }
public void startBrokerWithAmqpTransport(String amqpUrl) throws Exception { public void startBrokerWithAmqpTransport(String amqpUrl) throws Exception {
brokerService = new BrokerService(); brokerService = new BrokerService();
brokerService.setPersistent(false); brokerService.setPersistent(false);
brokerService.setAdvisorySupport(false); brokerService.setAdvisorySupport(false);
brokerService.setDeleteAllMessagesOnStartup(true); brokerService.setDeleteAllMessagesOnStartup(true);
TransportConnector connector = brokerService.addConnector(amqpUrl); TransportConnector connector = brokerService.addConnector(amqpUrl);
amqpPort = connector.getConnectUri().getPort(); amqpPort = connector.getConnectUri().getPort();
connector = brokerService.addConnector("tcp://0.0.0.0:0"); connector = brokerService.addConnector("tcp://0.0.0.0:0");
openwirePort = connector.getConnectUri().getPort(); openwirePort = connector.getConnectUri().getPort();