Author: ritchiem
Date: Tue Dec 19 08:14:28 2006
New Revision: 488715

URL: http://svn.apache.org/viewvc?view=rev&rev=488715
Log:
Maven output clean up.
Mainly removed exception stack traces from expected exceptions.

Modified:
    
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java

Modified: 
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java?view=diff&rev=488715&r1=488714&r2=488715
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
 (original)
+++ 
incubator/qpid/trunk/qpid/java/systests/src/test/java/org/apache/qpid/server/exchange/ReturnUnroutableMandatoryMessageTest.java
 Tue Dec 19 08:14:28 2006
@@ -6,6 +6,7 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.util.TestApplicationRegistry;
 import org.apache.qpid.client.*;
+import org.apache.qpid.client.transport.TransportConnection;
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 import org.apache.qpid.exchange.ExchangeDefaults;
@@ -38,12 +39,14 @@
     protected void setUp() throws Exception
     {
         super.setUp();
+        TransportConnection.createVMBroker(1);
         ApplicationRegistry.initialise(new TestApplicationRegistry(), 1);
     }
 
     protected void tearDown() throws Exception
     {
         super.tearDown();
+        TransportConnection.killAllVMBrokers();
     }
 
     /**
@@ -56,13 +59,14 @@
         _bouncedMessageList.clear();
         Connection con = new AMQConnection("vm://:1", "guest", "guest", 
"consumer1", "/test");
 
+
         AMQSession consumerSession = (AMQSession) con.createSession(false, 
Session.CLIENT_ACKNOWLEDGE);
 
-        AMQHeadersExchange queue = new AMQHeadersExchange(new 
AMQBindingURL(ExchangeDefaults.HEADERS_EXCHANGE_CLASS+"://"+ExchangeDefaults.HEADERS_EXCHANGE_NAME+"/test/queue1?"+
 BindingURL.OPTION_ROUTING_KEY+"='F0000=1'"));
+        AMQHeadersExchange queue = new AMQHeadersExchange(new 
AMQBindingURL(ExchangeDefaults.HEADERS_EXCHANGE_CLASS + "://" + 
ExchangeDefaults.HEADERS_EXCHANGE_NAME + "/test/queue1?" + 
BindingURL.OPTION_ROUTING_KEY + "='F0000=1'"));
         FieldTable ft = new PropertyFieldTable();
-        ft.setString("F1000","1");
-        MessageConsumer consumer = consumerSession.createConsumer(queue, 
AMQSession.DEFAULT_PREFETCH_LOW_MARK, AMQSession.DEFAULT_PREFETCH_HIGH_MARK, 
false, false, (String)null, ft);
-        
+        ft.setString("F1000", "1");
+        MessageConsumer consumer = consumerSession.createConsumer(queue, 
AMQSession.DEFAULT_PREFETCH_LOW_MARK, AMQSession.DEFAULT_PREFETCH_HIGH_MARK, 
false, false, (String) null, ft);
+
         //force synch to ensure the consumer has resulted in a bound queue
         ((AMQSession) 
consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, 
ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
 
@@ -76,49 +80,45 @@
         con2.start();
 
 
-        MessageProducer nonMandatoryProducer = 
producerSession.createProducer(queue,false,false);
+        MessageProducer nonMandatoryProducer = 
producerSession.createProducer(queue, false, false);
         MessageProducer mandatoryProducer = 
producerSession.createProducer(queue);
 
-
         // First test - should neither be bounced nor routed
         _logger.info("Sending non-routable non-mandatory message");
-        TextMessage msg1 =  producerSession.createTextMessage("msg1");
+        TextMessage msg1 = producerSession.createTextMessage("msg1");
         nonMandatoryProducer.send(msg1);
 
         // Second test - should be bounced
         _logger.info("Sending non-routable mandatory message");
-        TextMessage msg2 =  producerSession.createTextMessage("msg2");
+        TextMessage msg2 = producerSession.createTextMessage("msg2");
         mandatoryProducer.send(msg2);
 
         // Third test - should be routed
         _logger.info("Sending routable message");
-        TextMessage msg3 =  producerSession.createTextMessage("msg3");
-        msg3.setStringProperty("F1000","1");
+        TextMessage msg3 = producerSession.createTextMessage("msg3");
+        msg3.setStringProperty("F1000", "1");
         mandatoryProducer.send(msg3);
 
 
-
         _logger.info("Starting consumer connection");
         con.start();
         TextMessage tm = (TextMessage) consumer.receive(1000L);
 
-        assertTrue("No message routed to receiver",tm != null);
-        assertTrue("Wrong message routed to receiver: 
"+tm.getText(),"msg3".equals(tm.getText()));
+        assertTrue("No message routed to receiver", tm != null);
+        assertTrue("Wrong message routed to receiver: " + tm.getText(), 
"msg3".equals(tm.getText()));
 
         try
         {
             Thread.sleep(1000L);
         }
-        catch(InterruptedException e)
+        catch (InterruptedException e)
         {
             ;
         }
 
-        assertTrue("Wrong number of messages bounced (expect 1): 
"+_bouncedMessageList.size(),_bouncedMessageList.size()==1);
+        assertTrue("Wrong number of messages bounced (expect 1): " + 
_bouncedMessageList.size(), _bouncedMessageList.size() == 1);
         Message m = _bouncedMessageList.get(0);
-        assertTrue("Wrong message bounced: 
"+m.toString(),m.toString().contains("msg2"));
-
-
+        assertTrue("Wrong message bounced: " + m.toString(), 
m.toString().contains("msg2"));
 
 
         con.close();
@@ -129,18 +129,23 @@
 
     public static junit.framework.Test suite()
     {
-        return new VMBrokerSetup(new 
junit.framework.TestSuite(ReturnUnroutableMandatoryMessageTest.class));
+        return new 
junit.framework.TestSuite(ReturnUnroutableMandatoryMessageTest.class);
     }
 
     public void onException(JMSException jmsException)
     {
-        _logger.warn("Caught exception on producer: ",jmsException);
+
         Exception linkedException = jmsException.getLinkedException();
-        if(linkedException instanceof AMQNoRouteException)
+        if (linkedException instanceof AMQNoRouteException)
         {
             AMQNoRouteException noRoute = (AMQNoRouteException) 
linkedException;
             Message bounced = (Message) noRoute.getUndeliveredMessage();
             _bouncedMessageList.add(bounced);
+            _logger.info("Caught expected NoRouteException");
+        }
+        else
+        {
+            _logger.warn("Caught exception on producer: ", jmsException);
         }
     }
 }


Reply via email to