qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rupertlssm...@apache.org
Subject svn commit: r546190 [3/6] - in /incubator/qpid/branches/M2/java: ./ broker/ client/ client/example/ client/src/main/java/org/apache/qpid/client/ client/src/main/java/org/apache/qpid/client/failover/ client/src/main/java/org/apache/qpid/client/handler/ ...
Date Mon, 11 Jun 2007 16:44:10 GMT
Modified: incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java (original)
+++ incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java Mon Jun 11 09:43:57 2007
@@ -7,9 +7,9 @@
  * 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
@@ -20,13 +20,15 @@
  */
 package org.apache.qpid.jms.failover;
 
-import org.apache.log4j.Logger;
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 public class FailoverRoundRobinServers implements FailoverMethod
 {
-    private static final Logger _logger = Logger.getLogger(FailoverRoundRobinServers.class);
+    private static final Logger _logger = LoggerFactory.getLogger(FailoverRoundRobinServers.class);
 
     /** The default number of times to cycle through all servers */
     public static final int DEFAULT_CYCLE_RETRIES = 0;
@@ -72,7 +74,7 @@
 
         _connectionDetails = connectionDetails;
 
-        //There is no current broker at startup so set it to -1.
+        // There is no current broker at startup so set it to -1.
         _currentBrokerIndex = -1;
 
         String cycleRetries = _connectionDetails.getFailoverOption(ConnectionURL.OPTIONS_FAILOVER_CYCLE);
@@ -104,9 +106,8 @@
 
     public boolean failoverAllowed()
     {
-       return  ((_currentCycleRetries < _cycleRetries)
-                    || (_currentServerRetry < _serverRetries)
-                    || (_currentBrokerIndex < (_connectionDetails.getBrokerCount() - 1)));
+        return ((_currentCycleRetries < _cycleRetries) || (_currentServerRetry < _serverRetries)
+                || (_currentBrokerIndex < (_connectionDetails.getBrokerCount() - 1)));
     }
 
     public void attainedConnection()
@@ -125,8 +126,6 @@
         return _connectionDetails.getBrokerDetails(_currentBrokerIndex);
     }
 
-
-
     public BrokerDetails getNextBrokerDetails()
     {
         if (_currentBrokerIndex == (_connectionDetails.getBrokerCount() - 1))
@@ -137,7 +136,7 @@
                 {
                     _currentBrokerIndex = 0;
 
-                    setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex ));
+                    setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
 
                     _logger.info("First run using " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
                 }
@@ -151,15 +150,15 @@
             else
             {
                 _currentCycleRetries++;
-                //failed to connect to first broker
+                // failed to connect to first broker
                 _currentBrokerIndex = 0;
 
-                setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex ));
+                setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
 
                 // This is zero rather than -1 as we are already retrieving the details.
                 _currentServerRetry = 0;
             }
-            //else - should force client to stop as max retries has been reached.
+            // else - should force client to stop as max retries has been reached.
         }
         else
         {
@@ -169,7 +168,7 @@
                 {
                     _currentBrokerIndex = 0;
 
-                    setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex ));
+                    setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
 
                     _logger.info("First run using " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
                 }
@@ -177,13 +176,14 @@
                 {
                     _logger.info("Retrying " + _connectionDetails.getBrokerDetails(_currentBrokerIndex));
                 }
+
                 _currentServerRetry++;
             }
             else
             {
                 _currentBrokerIndex++;
 
-                 setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex ));
+                setBroker(_connectionDetails.getBrokerDetails(_currentBrokerIndex));
                 // This is zero rather than -1 as we are already retrieving the details.
                 _currentServerRetry = 0;
             }
@@ -192,7 +192,6 @@
         return _connectionDetails.getBrokerDetails(_currentBrokerIndex);
     }
 
-
     public void setBroker(BrokerDetails broker)
     {
 
@@ -246,12 +245,13 @@
         sb.append(_currentBrokerIndex);
         sb.append("\n");
 
-        for(int i=0; i < _connectionDetails.getBrokerCount() ; i++)
+        for (int i = 0; i < _connectionDetails.getBrokerCount(); i++)
         {
             if (i == _currentBrokerIndex)
             {
                 sb.append(">");
             }
+
             sb.append(_connectionDetails.getBrokerDetails(i));
             sb.append("\n");
         }

Modified: incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java (original)
+++ incubator/qpid/branches/M2/java/client/src/main/java/org/apache/qpid/jndi/PropertiesFileInitialContextFactory.java Mon Jun 11 09:43:57 2007
@@ -7,9 +7,9 @@
  * 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
@@ -20,38 +20,40 @@
  */
 package org.apache.qpid.jndi;
 
-import java.io.BufferedInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-
-import org.apache.log4j.Logger;
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQHeadersExchange;
 import org.apache.qpid.client.AMQQueue;
 import org.apache.qpid.client.AMQTopic;
+import org.apache.qpid.exchange.ExchangeDefaults;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.url.AMQBindingURL;
 import org.apache.qpid.url.BindingURL;
 import org.apache.qpid.url.URLSyntaxException;
-import org.apache.qpid.exchange.ExchangeDefaults;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class PropertiesFileInitialContextFactory implements InitialContextFactory
 {
-    protected final Logger _logger = Logger.getLogger(PropertiesFileInitialContextFactory.class);
+    protected final Logger _logger = LoggerFactory.getLogger(PropertiesFileInitialContextFactory.class);
 
     private String CONNECTION_FACTORY_PREFIX = "connectionfactory.";
     private String DESTINATION_PREFIX = "destination.";
@@ -78,7 +80,7 @@
             if (file != null)
             {
                 _logger.info("Loading Properties from:" + file);
-                //Load the properties specified
+                // Load the properties specified
                 Properties p = new Properties();
 
                 p.load(new BufferedInputStream(new FileInputStream(file)));
@@ -93,8 +95,7 @@
         }
         catch (IOException ioe)
         {
-            _logger.warn("Unable to load property file specified in Provider_URL:" +
-                         environment.get(Context.PROVIDER_URL));
+            _logger.warn("Unable to load property file specified in Provider_URL:" + environment.get(Context.PROVIDER_URL));
         }
 
         createConnectionFactories(data, environment);
@@ -109,7 +110,7 @@
     }
 
     // Implementation methods
-    //-------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     protected ReadOnlyContext createContext(Map data, Hashtable environment)
     {
         return new ReadOnlyContext(environment, data);
@@ -200,6 +201,7 @@
         {
             _logger.warn("Unable to createFactories:" + urlse);
         }
+
         return null;
     }
 
@@ -216,6 +218,7 @@
         catch (URLSyntaxException urlse)
         {
             _logger.warn("Unable to destination:" + urlse);
+
             return null;
         }
 
@@ -226,6 +229,7 @@
         catch (IllegalArgumentException iaw)
         {
             _logger.warn("Binding: '" + binding + "' not supported");
+
             return null;
         }
     }
@@ -235,17 +239,15 @@
      */
     protected Queue createQueue(Object value)
     {
-        if(value instanceof AMQShortString)
+        if (value instanceof AMQShortString)
         {
             return new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_NAME, (AMQShortString) value);
         }
         else if (value instanceof String)
-
         {
             return new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_NAME, new AMQShortString((String) value));
         }
         else if (value instanceof BindingURL)
-
         {
             return new AMQQueue((BindingURL) value);
         }
@@ -258,16 +260,15 @@
      */
     protected Topic createTopic(Object value)
     {
-        if(value instanceof AMQShortString)
+        if (value instanceof AMQShortString)
         {
-            return new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_NAME, (AMQShortString)value);
+            return new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_NAME, (AMQShortString) value);
         }
         else if (value instanceof String)
         {
             return new AMQTopic(ExchangeDefaults.TOPIC_EXCHANGE_NAME, new AMQShortString((String) value));
         }
         else if (value instanceof BindingURL)
-
         {
             return new AMQTopic((BindingURL) value);
         }
@@ -293,7 +294,7 @@
     }
 
     // Properties
-    //-------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     public String getConnectionPrefix()
     {
         return CONNECTION_FACTORY_PREFIX;

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/DispatcherTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/DispatcherTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/DispatcherTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/DispatcherTest.java Mon Jun 11 09:43:57 2007
@@ -20,9 +20,13 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -36,11 +40,9 @@
 import javax.naming.Context;
 import javax.naming.spi.InitialContextFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+import java.util.Hashtable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery queue
@@ -56,7 +58,7 @@
  */
 public class DispatcherTest extends TestCase
 {
-    private static final Logger _logger = Logger.getLogger(DispatcherTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(DispatcherTest.class);
 
     Context _context;
 
@@ -68,8 +70,8 @@
     MessageProducer _producer;
     Session _clientSession, _producerSession;
 
-    private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(1); //all messages Sent Lock
-    private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(1); //all messages Sent Lock
+    private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(1); // all messages Sent Lock
+    private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(1); // all messages Sent Lock
 
     private volatile boolean _connectionStopped = false;
 
@@ -89,14 +91,14 @@
 
         Queue queue = (Queue) _context.lookup("queue");
 
-        //Create Client 1
+        // Create Client 1
         _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         _consumer = _clientSession.createConsumer(queue);
 
-        //Create Producer
+        // Create Producer
         _producerConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _producerConnection.start();
@@ -109,7 +111,6 @@
         {
             _producer.send(_producerSession.createTextMessage("Message " + msg));
         }
-
     }
 
     protected void tearDown() throws Exception
@@ -122,67 +123,63 @@
         TransportConnection.killAllVMBrokers();
     }
 
-
     public void testAsynchronousRecieve()
     {
-
         _logger.info("Test Start");
 
-
         assertTrue(!((AMQConnection) _clientConnection).started());
 
-        //Set default Message Listener
+        // Set default Message Listener
         try
         {
             _consumer.setMessageListener(new MessageListener()
-            {
-                public void onMessage(Message message)
                 {
-                    _logger.info("Client 1 ML 1 Received Message(" + _receivedCount + "):" + message);
+                    public void onMessage(Message message)
+                    {
+                        _logger.info("Client 1 ML 1 Received Message(" + _receivedCount + "):" + message);
 
-                    _receivedCount++;
+                        _receivedCount++;
 
-                    if (_receivedCount == MSG_COUNT)
-                    {
-                        _allFirstMessagesSent.countDown();
-                    }
+                        if (_receivedCount == MSG_COUNT)
+                        {
+                            _allFirstMessagesSent.countDown();
+                        }
 
-                    if (_connectionStopped)
-                    {
-                        _logger.info("Running with Message:" + _receivedCount);
-                    }
+                        if (_connectionStopped)
+                        {
+                            _logger.info("Running with Message:" + _receivedCount);
+                        }
 
-                    if (_connectionStopped && _allFirstMessagesSent.getCount() == 0)
-                    {
-                        _receivedCountWhileStopped++;
-                    }
+                        if (_connectionStopped && (_allFirstMessagesSent.getCount() == 0))
+                        {
+                            _receivedCountWhileStopped++;
+                        }
 
-                    if (_allFirstMessagesSent.getCount() == 0)
-                    {
-                        if (_receivedCount == MSG_COUNT * 2)
+                        if (_allFirstMessagesSent.getCount() == 0)
                         {
-                            _allSecondMessagesSent.countDown();
+                            if (_receivedCount == (MSG_COUNT * 2))
+                            {
+                                _allSecondMessagesSent.countDown();
+                            }
                         }
                     }
-                }
-            });
-            
+                });
+
             assertTrue("Connecion should not be started", !((AMQConnection) _clientConnection).started());
-            _clientConnection.start();            
+            _clientConnection.start();
         }
         catch (JMSException e)
         {
             _logger.error("Error Setting Default ML on consumer1");
         }
 
-
         try
         {
             _allFirstMessagesSent.await(1000, TimeUnit.MILLISECONDS);
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
 
         try
@@ -196,7 +193,6 @@
             _logger.error("Error stopping connection");
         }
 
-
         try
         {
             _logger.error("Send additional messages");
@@ -211,14 +207,13 @@
             _logger.error("Unable to send additional messages", e);
         }
 
-
         try
         {
             Thread.sleep(1000);
         }
         catch (InterruptedException e)
         {
-            //ignore
+            // ignore
         }
 
         try
@@ -233,7 +228,6 @@
             _logger.error("Error Setting Better ML on consumer1", e);
         }
 
-
         _logger.info("Waiting upto 2 seconds for messages");
 
         try
@@ -242,16 +236,14 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
 
         assertEquals("Messages not received correctly", 0, _allFirstMessagesSent.getCount());
         assertEquals("Messages not received correctly", 0, _allSecondMessagesSent.getCount());
         assertEquals("Client didn't get all messages", MSG_COUNT * 2, _receivedCount);
         assertEquals("Messages received while stopped is not 0", 0, _receivedCountWhileStopped);
-
     }
-
 
     public static junit.framework.Test suite()
     {

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerImmediatePrefetch.java Mon Jun 11 09:43:57 2007
@@ -20,27 +20,6 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.naming.Context;
-import javax.naming.spi.InitialContextFactory;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
-
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
  * queue <p/> The message delivery process: Mina puts a message on _queue in AMQSession and the dispatcher thread
@@ -52,16 +31,11 @@
  */
 public class MessageListenerMultiConsumerImmediatePrefetch extends MessageListenerMultiConsumerTest
 {
-
-
     protected void setUp() throws Exception
     {
-
         System.setProperty(AMQSession.IMMEDIATE_PREFETCH, "true");
         super.setUp();
-
     }
-
 
     public static junit.framework.Test suite()
     {

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerMultiConsumerTest.java Mon Jun 11 09:43:57 2007
@@ -20,9 +20,13 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -35,11 +39,9 @@
 import javax.naming.Context;
 import javax.naming.spi.InitialContextFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+import java.util.Hashtable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
@@ -52,7 +54,7 @@
  */
 public class MessageListenerMultiConsumerTest extends TestCase
 {
-    private static final Logger _logger = Logger.getLogger(MessageListenerMultiConsumerTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(MessageListenerMultiConsumerTest.class);
 
     Context _context;
 
@@ -64,8 +66,7 @@
     private MessageConsumer _consumer2;
     private Session _clientSession1;
     private Queue _queue;
-    private final CountDownLatch _allMessagesSent = new CountDownLatch(2); //all messages Sent Lock
-
+    private final CountDownLatch _allMessagesSent = new CountDownLatch(2); // all messages Sent Lock
 
     protected void setUp() throws Exception
     {
@@ -77,13 +78,13 @@
         Hashtable<String, String> env = new Hashtable<String, String>();
 
         env.put("connectionfactory.connection", "amqp://guest:guest@MLT_ID/test?brokerlist='vm://:1'");
-        env.put("queue.queue", "direct://amq.direct//"+this.getClass().getName());
+        env.put("queue.queue", "direct://amq.direct//" + this.getClass().getName());
 
         _context = factory.getInitialContext(env);
 
         _queue = (Queue) _context.lookup("queue");
 
-        //Create Client 1
+        // Create Client 1
         _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _clientConnection.start();
@@ -92,17 +93,16 @@
 
         _consumer1 = _clientSession1.createConsumer(_queue);
 
-        //Create Client 2
+        // Create Client 2
         Session clientSession2 = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         _consumer2 = clientSession2.createConsumer(_queue);
 
-        //Create Producer
+        // Create Producer
         Connection producerConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         producerConnection.start();
 
-
         Session producerSession = producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         MessageProducer producer = producerSession.createProducer(_queue);
@@ -124,18 +124,18 @@
         TransportConnection.killAllVMBrokers();
     }
 
-
     public void testRecieveInterleaved() throws Exception
     {
         int msg = 0;
         int MAX_LOOPS = MSG_COUNT * 2;
-        for (int loops = 0; msg < MSG_COUNT || loops < MAX_LOOPS; loops++)
+        for (int loops = 0; (msg < MSG_COUNT) || (loops < MAX_LOOPS); loops++)
         {
 
             if (_consumer1.receive(100) != null)
             {
                 msg++;
             }
+
             if (_consumer2.receive(100) != null)
             {
                 msg++;
@@ -145,39 +145,37 @@
         assertEquals("Not all messages received.", MSG_COUNT, msg);
     }
 
-
     public void testAsynchronousRecieve() throws Exception
     {
         _consumer1.setMessageListener(new MessageListener()
-        {
-            public void onMessage(Message message)
             {
-                _logger.info("Client 1 Received Message(" + receivedCount1 + "):" + message);
+                public void onMessage(Message message)
+                {
+                    _logger.info("Client 1 Received Message(" + receivedCount1 + "):" + message);
 
-                receivedCount1++;
+                    receivedCount1++;
 
-                if (receivedCount1 == MSG_COUNT / 2)
-                {
-                    _allMessagesSent.countDown();
-                }
+                    if (receivedCount1 == (MSG_COUNT / 2))
+                    {
+                        _allMessagesSent.countDown();
+                    }
 
-            }
-        });
+                }
+            });
 
         _consumer2.setMessageListener(new MessageListener()
-        {
-            public void onMessage(Message message)
             {
-                _logger.info("Client 2 Received Message(" + receivedCount2 + "):" + message);
-
-                receivedCount2++;
-                if (receivedCount2 == MSG_COUNT / 2)
+                public void onMessage(Message message)
                 {
-                    _allMessagesSent.countDown();
-                }
-            }
-        });
+                    _logger.info("Client 2 Received Message(" + receivedCount2 + "):" + message);
 
+                    receivedCount2++;
+                    if (receivedCount2 == (MSG_COUNT / 2))
+                    {
+                        _allMessagesSent.countDown();
+                    }
+                }
+            });
 
         _logger.info("Waiting upto 2 seconds for messages");
 
@@ -187,7 +185,7 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
 
         assertEquals(MSG_COUNT, receivedCount1 + receivedCount2);
@@ -195,34 +193,37 @@
 
     public void testRecieveC2Only() throws Exception
     {
-        if (!Boolean.parseBoolean(System.getProperties().
-                getProperty(AMQSession.IMMEDIATE_PREFETCH, AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
+        if (
+            !Boolean.parseBoolean(
+                    System.getProperties().getProperty(AMQSession.IMMEDIATE_PREFETCH,
+                        AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
         {
             _logger.info("Performing Receive only on C2");
             for (int msg = 0; msg < MSG_COUNT; msg++)
             {
-                assertTrue(MSG_COUNT + " msg should be received. Only received:" + msg,
-                           _consumer2.receive(1000) != null);
+                assertTrue(MSG_COUNT + " msg should be received. Only received:" + msg, _consumer2.receive(1000) != null);
             }
         }
     }
 
     public void testRecieveBoth() throws Exception
     {
-        if (!Boolean.parseBoolean(System.getProperties().
-                getProperty(AMQSession.IMMEDIATE_PREFETCH, AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
+        if (
+            !Boolean.parseBoolean(
+                    System.getProperties().getProperty(AMQSession.IMMEDIATE_PREFETCH,
+                        AMQSession.IMMEDIATE_PREFETCH_DEFAULT)))
         {
             _logger.info("Performing Receive only with two consumers on one session ");
 
             MessageConsumer consumer2 = _clientSession1.createConsumer(_queue);
 
-            for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+            for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
             {
 
                 assertTrue(_consumer1.receive() != null);
             }
 
-            for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+            for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
             {
                 assertTrue(consumer2.receive() != null);
             }
@@ -231,19 +232,18 @@
         {
             _logger.info("Performing Receive only on both C1 and C2");
 
-            for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+            for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
             {
 
                 assertTrue(_consumer1.receive() != null);
             }
 
-            for (int msg = 0; msg < MSG_COUNT / 2; msg++)
+            for (int msg = 0; msg < (MSG_COUNT / 2); msg++)
             {
                 assertTrue(_consumer2.receive() != null);
             }
         }
     }
-
 
     public static junit.framework.Test suite()
     {

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/MessageListenerTest.java Mon Jun 11 09:43:57 2007
@@ -14,15 +14,19 @@
  *  "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.    
+ *  under the License.
+ *
  *
- * 
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -35,13 +39,9 @@
 import javax.naming.Context;
 import javax.naming.spi.InitialContextFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
-import org.apache.qpid.url.BindingURL;
-import org.apache.qpid.url.AMQBindingURL;
+import java.util.Hashtable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
@@ -54,7 +54,7 @@
  */
 public class MessageListenerTest extends TestCase implements MessageListener
 {
-    private static final Logger _logger = Logger.getLogger(MessageListenerTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(MessageListenerTest.class);
 
     Context _context;
 
@@ -73,6 +73,7 @@
         {
             TransportConnection.createVMBroker(1);
         }
+
         InitialContextFactory factory = new PropertiesFileInitialContextFactory();
 
         Hashtable<String, String> env = new Hashtable<String, String>();
@@ -84,7 +85,7 @@
 
         Queue queue = (Queue) _context.lookup("queue");
 
-        //Create Client
+        // Create Client
         _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _clientConnection.start();
@@ -93,7 +94,7 @@
 
         _consumer = clientSession.createConsumer(queue);
 
-        //Create Producer
+        // Create Producer
 
         Connection producerConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
@@ -123,7 +124,6 @@
         }
     }
 
-
     public void testSynchronousRecieve() throws Exception
     {
         for (int msg = 0; msg < MSG_COUNT; msg++)
@@ -144,9 +144,9 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
-        //Should have recieved all async messages
+        // Should have recieved all async messages
         assertEquals(MSG_COUNT, receivedCount);
 
     }
@@ -156,11 +156,11 @@
 
         _logger.error("Test disabled as initial receive is not called first");
         // Perform initial receive to start connection
-//         assertTrue(_consumer.receive(2000) != null);
-//         receivedCount++;
+        // assertTrue(_consumer.receive(2000) != null);
+        // receivedCount++;
 
         // Sleep to ensure remaining 4 msgs end up on _synchronousQueue
-//         Thread.sleep(1000);
+        // Thread.sleep(1000);
 
         // Set the message listener and wait for the messages to come in.
         _consumer.setMessageListener(this);
@@ -173,13 +173,12 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
-        //Should have recieved all async messages
+        // Should have recieved all async messages
         assertEquals(MSG_COUNT, receivedCount);
 
     }
-
 
     public void onMessage(Message message)
     {

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/client/ResetMessageListenerTest.java Mon Jun 11 09:43:57 2007
@@ -20,9 +20,13 @@
  */
 package org.apache.qpid.client;
 
-import java.util.Hashtable;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -36,11 +40,9 @@
 import javax.naming.Context;
 import javax.naming.spi.InitialContextFactory;
 
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.jndi.PropertiesFileInitialContextFactory;
+import java.util.Hashtable;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
 /**
  * QPID-293 Setting MessageListener after connection has started can cause messages to be "lost" on a internal delivery
@@ -53,7 +55,7 @@
  */
 public class ResetMessageListenerTest extends TestCase
 {
-    private static final Logger _logger = Logger.getLogger(ResetMessageListenerTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(ResetMessageListenerTest.class);
 
     Context _context;
 
@@ -67,8 +69,8 @@
     MessageProducer _producer;
     Session _clientSession, _producerSession;
 
-    private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(2); //all messages Sent Lock
-    private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(2); //all messages Sent Lock
+    private final CountDownLatch _allFirstMessagesSent = new CountDownLatch(2); // all messages Sent Lock
+    private final CountDownLatch _allSecondMessagesSent = new CountDownLatch(2); // all messages Sent Lock
 
     protected void setUp() throws Exception
     {
@@ -88,17 +90,17 @@
 
         Queue queue = (Queue) _context.lookup("queue");
 
-        //Create Client 1
+        // Create Client 1
         _clientConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _clientSession = _clientConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         _consumer1 = _clientSession.createConsumer(queue);
 
-        //Create Client 2 on same session
+        // Create Client 2 on same session
         _consumer2 = _clientSession.createConsumer(queue);
 
-        //Create Producer
+        // Create Producer
         _producerConnection = ((ConnectionFactory) _context.lookup("connection")).createConnection();
 
         _producerConnection.start();
@@ -129,57 +131,55 @@
         TransportConnection.killAllVMBrokers();
     }
 
-
     public void testAsynchronousRecieve()
     {
 
         _logger.info("Test Start");
 
-        //Set default Message Listener
+        // Set default Message Listener
         try
         {
             _consumer1.setMessageListener(new MessageListener()
-            {
-                public void onMessage(Message message)
                 {
-                    _logger.info("Client 1 ML 1 Received Message(" + receivedCount1ML1 + "):" + message);
-
-                    receivedCount1ML1++;
-                    if (receivedCount1ML1 == MSG_COUNT / 2)
+                    public void onMessage(Message message)
                     {
-                        _allFirstMessagesSent.countDown();
+                        _logger.info("Client 1 ML 1 Received Message(" + receivedCount1ML1 + "):" + message);
+
+                        receivedCount1ML1++;
+                        if (receivedCount1ML1 == (MSG_COUNT / 2))
+                        {
+                            _allFirstMessagesSent.countDown();
+                        }
                     }
-                }
-            });
+                });
         }
         catch (JMSException e)
         {
             _logger.error("Error Setting Default ML on consumer1");
         }
 
-
         try
         {
             _consumer2.setMessageListener(new MessageListener()
-            {
-                public void onMessage(Message message)
                 {
-                    _logger.info("Client 2 Received Message(" + receivedCount2 + "):" + message);
-
-                    receivedCount2++;
-                    if (receivedCount2 == MSG_COUNT / 2)
+                    public void onMessage(Message message)
                     {
-                        _logger.info("Client 2 received all its messages1");
-                        _allFirstMessagesSent.countDown();
-                    }
+                        _logger.info("Client 2 Received Message(" + receivedCount2 + "):" + message);
 
-                    if (receivedCount2 == MSG_COUNT)
-                    {
-                        _logger.info("Client 2 received all its messages2");
-                        _allSecondMessagesSent.countDown();
+                        receivedCount2++;
+                        if (receivedCount2 == (MSG_COUNT / 2))
+                        {
+                            _logger.info("Client 2 received all its messages1");
+                            _allFirstMessagesSent.countDown();
+                        }
+
+                        if (receivedCount2 == MSG_COUNT)
+                        {
+                            _logger.info("Client 2 received all its messages2");
+                            _allSecondMessagesSent.countDown();
+                        }
                     }
-                }
-            });
+                });
 
             _clientConnection.start();
         }
@@ -189,7 +189,6 @@
 
         }
 
-
         try
         {
             _allFirstMessagesSent.await(1000, TimeUnit.MILLISECONDS);
@@ -197,7 +196,7 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
 
         try
@@ -213,18 +212,18 @@
         try
         {
             _consumer1.setMessageListener(new MessageListener()
-            {
-                public void onMessage(Message message)
                 {
-                    _logger.info("Client 1 ML2 Received Message(" + receivedCount1ML1 + "):" + message);
-
-                    receivedCount1ML2++;
-                    if (receivedCount1ML2 == MSG_COUNT / 2)
+                    public void onMessage(Message message)
                     {
-                        _allSecondMessagesSent.countDown();
+                        _logger.info("Client 1 ML2 Received Message(" + receivedCount1ML1 + "):" + message);
+
+                        receivedCount1ML2++;
+                        if (receivedCount1ML2 == (MSG_COUNT / 2))
+                        {
+                            _allSecondMessagesSent.countDown();
+                        }
                     }
-                }
-            });
+                });
 
             _clientConnection.start();
         }
@@ -260,10 +259,9 @@
         }
         catch (InterruptedException e)
         {
-            //do nothing
+            // do nothing
         }
     }
-
 
     public static junit.framework.Test suite()
     {

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/ack/RecoverTest.java Mon Jun 11 09:43:57 2007
@@ -19,32 +19,30 @@
  */
 package org.apache.qpid.test.unit.ack;
 
-import java.util.concurrent.atomic.AtomicInteger;
+import junit.framework.TestCase;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.framing.AMQShortString;
+import org.apache.qpid.jms.Session;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import javax.jms.Connection;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
 import javax.jms.Queue;
-
 import javax.jms.TextMessage;
 
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.framing.AMQShortString;
-import org.apache.qpid.jms.Session;
+import java.util.concurrent.atomic.AtomicInteger;
 
 public class RecoverTest extends TestCase
 {
-    private static final Logger _logger = Logger.getLogger(RecoverTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(RecoverTest.class);
 
     private Exception _error;
     private AtomicInteger count;
@@ -64,16 +62,17 @@
         count = null;
     }
 
-
     public void testRecoverResendsMsgs() throws Exception
     {
         AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "test");
 
         Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-        Queue queue = new AMQQueue(consumerSession.getDefaultQueueExchangeName(),new AMQShortString("someQ"), new AMQShortString("someQ"), false, true);
+        Queue queue =
+            new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("someQ"),
+                new AMQShortString("someQ"), false, true);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
-        //force synch to ensure the consumer has resulted in a bound queue
-        //((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
+        // force synch to ensure the consumer has resulted in a bound queue
+        // ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
         // This is the default now
 
         AMQConnection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "test");
@@ -122,16 +121,17 @@
         con.close();
     }
 
-
     public void testRecoverResendsMsgsAckOnEarlier() throws Exception
     {
         AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "test");
 
         Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-        Queue queue = new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("someQ"), new AMQShortString("someQ"), false, true);
+        Queue queue =
+            new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("someQ"),
+                new AMQShortString("someQ"), false, true);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
-        //force synch to ensure the consumer has resulted in a bound queue
-        //((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
+        // force synch to ensure the consumer has resulted in a bound queue
+        // ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.DIRECT_EXCHANGE_NAME, ExchangeDefaults.DIRECT_EXCHANGE_CLASS);
         // This is the default now
 
         AMQConnection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "test");
@@ -164,7 +164,6 @@
         TextMessage tm4 = (TextMessage) consumer.receive(3000);
         assertEquals("msg4", tm4.getText());
 
-
         _logger.info("Received redelivery of two messages. calling acknolwedgeThis() first of those message");
         ((org.apache.qpid.jms.Message) tm3).acknowledgeThis();
 
@@ -180,7 +179,6 @@
         // all acked so no messages to be delivered
         consumerSession.recover();
 
-
         tm = (TextMessage) consumer.receiveNoWait();
         assertNull(tm);
         _logger.info("No messages redelivered as is expected");
@@ -193,8 +191,12 @@
         AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "test");
 
         Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-        Queue queue = new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q1"), new AMQShortString("Q1"), false, true);
-        Queue queue2 = new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q2"), new AMQShortString("Q2"), false, true);
+        Queue queue =
+            new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q1"), new AMQShortString("Q1"),
+                false, true);
+        Queue queue2 =
+            new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q2"), new AMQShortString("Q2"),
+                false, true);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
         MessageConsumer consumer2 = consumerSession.createConsumer(queue2);
 
@@ -232,68 +234,72 @@
         AMQConnection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "test");
 
         final Session consumerSession = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        Queue queue = new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q3"), new AMQShortString("Q3"), false, true);
+        Queue queue =
+            new AMQQueue(consumerSession.getDefaultQueueExchangeName(), new AMQShortString("Q3"), new AMQShortString("Q3"),
+                false, true);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
         MessageProducer producer = consumerSession.createProducer(queue);
         producer.send(consumerSession.createTextMessage("hello"));
 
-
         final Object lock = new Object();
 
         consumer.setMessageListener(new MessageListener()
-        {
-
-
-
-            public void onMessage(Message message)
             {
-                try
+
+                public void onMessage(Message message)
                 {
-                    count.incrementAndGet();
-                    if (count.get() == 1)
+                    try
                     {
-                        if(message.getJMSRedelivered())
+                        count.incrementAndGet();
+                        if (count.get() == 1)
                         {
-                            setError(new Exception("Message marked as redilvered on what should be first delivery attempt"));
+                            if (message.getJMSRedelivered())
+                            {
+                                setError(
+                                    new Exception("Message marked as redilvered on what should be first delivery attempt"));
+                            }
+
+                            consumerSession.recover();
                         }
-                        consumerSession.recover();
-                    }
-                    else if (count.get() == 2)
-                    {
-                        if(!message.getJMSRedelivered())
+                        else if (count.get() == 2)
                         {
-                            setError(new Exception("Message not marked as redilvered on what should be second delivery attempt"));
+                            if (!message.getJMSRedelivered())
+                            {
+                                setError(
+                                    new Exception(
+                                        "Message not marked as redilvered on what should be second delivery attempt"));
+                            }
+                        }
+                        else
+                        {
+                            System.err.println(message);
+                            fail("Message delivered too many times!: " + count);
                         }
                     }
-                    else
+                    catch (JMSException e)
                     {
-                        System.err.println(message);
-                        fail("Message delivered too many times!: " + count);
+                        _logger.error("Error recovering session: " + e, e);
+                        setError(e);
+                    }
+
+                    synchronized (lock)
+                    {
+                        lock.notify();
                     }
                 }
-                catch (JMSException e)
-                {
-                    _logger.error("Error recovering session: " + e, e);
-                    setError(e);
-                }
-                synchronized(lock)
-                {
-                    lock.notify();
-                }
-            }
-        });
+            });
 
         con.start();
 
         long waitTime = 300000L;
         long waitUntilTime = System.currentTimeMillis() + waitTime;
 
-        synchronized(lock)
+        synchronized (lock)
         {
-            while((count.get() <= 1) && (waitTime > 0))
+            while ((count.get() <= 1) && (waitTime > 0))
             {
                 lock.wait(waitTime);
-                if(count.get() <= 1)
+                if (count.get() <= 1)
                 {
                     waitTime = waitUntilTime - System.currentTimeMillis();
                 }
@@ -302,15 +308,16 @@
 
         Thread.sleep(1000);
 
-        if(count.get() != 2)
+        if (count.get() != 2)
         {
             System.err.println("Count != 2 : " + count);
         }
-            assertTrue(count.get() == 2);
+
+        assertTrue(count.get() == 2);
 
         con.close();
 
-        if(_error != null)
+        if (_error != null)
         {
             throw _error;
         }

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java Mon Jun 11 09:43:57 2007
@@ -6,9 +6,9 @@
  * 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
@@ -19,9 +19,20 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.mina.common.ByteBuffer;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.message.JMSBytesMessage;
+import org.apache.qpid.testutil.VMBrokerSetup;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
@@ -34,21 +45,13 @@
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.mina.common.ByteBuffer;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.message.JMSBytesMessage;
-import org.apache.qpid.testutil.VMBrokerSetup;
-import org.apache.log4j.Logger;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 public class BytesMessageTest extends TestCase implements MessageListener
 {
-    private static final Logger _logger = Logger.getLogger(BytesMessageTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(BytesMessageTest.class);
 
     private Connection _connection;
     private Destination _destination;
@@ -102,7 +105,7 @@
 
     void send(int count) throws JMSException
     {
-        //create a publisher
+        // create a publisher
         MessageProducer producer = _session.createProducer(_destination);
         for (int i = 0; i < count; i++)
         {
@@ -115,7 +118,7 @@
             }
             catch (MessageNotReadableException mnwe)
             {
-                //normal execution
+                // normal execution
             }
 
             byte[] data = ("Message " + i).getBytes();
@@ -127,7 +130,7 @@
 
     void waitFor(int count) throws InterruptedException
     {
-        synchronized(received)
+        synchronized (received)
         {
             while (received.size() < count)
             {
@@ -146,8 +149,7 @@
             buffer.get(data);
             actual.add(data);
 
-
-            //Check Body Write Status
+            // Check Body Write Status
             try
             {
                 m.writeBoolean(true);
@@ -155,7 +157,7 @@
             }
             catch (MessageNotWriteableException mnwe)
             {
-                //normal execution
+                // normal execution
             }
 
             m.clearBody();
@@ -169,8 +171,7 @@
                 Assert.fail("Message should be writeable");
             }
 
-
-            //Check property write status
+            // Check property write status
             try
             {
                 m.setStringProperty("test", "test");
@@ -178,7 +179,7 @@
             }
             catch (MessageNotWriteableException mnwe)
             {
-                //normal execution
+                // normal execution
             }
 
             m.clearProperties();
@@ -219,6 +220,7 @@
         {
             errors.add("Found " + actual.next() + " but no more expected values.");
         }
+
         if (!errors.isEmpty())
         {
             throw new RuntimeException(errors.toString());
@@ -231,6 +233,7 @@
         {
             throw new RuntimeException("Expected length " + expected.length + " got " + actual.length);
         }
+
         for (int i = 0; i < expected.length; i++)
         {
             if (expected[i] != actual[i])
@@ -242,7 +245,7 @@
 
     public void onMessage(Message message)
     {
-        synchronized(received)
+        synchronized (received)
         {
             received.add((JMSBytesMessage) message);
             received.notify();

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/FieldTableMessageTest.java Mon Jun 11 09:43:57 2007
@@ -7,9 +7,9 @@
  * 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
@@ -20,19 +20,10 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import java.io.IOException;
-import java.util.ArrayList;
-
-import javax.jms.BytesMessage;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-
 import junit.framework.TestCase;
 
-import org.apache.log4j.Logger;
 import org.apache.mina.common.ByteBuffer;
+
 import org.apache.qpid.client.AMQConnection;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQQueue;
@@ -43,10 +34,21 @@
 import org.apache.qpid.framing.FieldTableFactory;
 import org.apache.qpid.testutil.VMBrokerSetup;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
 public class FieldTableMessageTest extends TestCase implements MessageListener
 {
-
-    private static final Logger _logger = Logger.getLogger(FieldTableMessageTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(FieldTableMessageTest.class);
 
     private AMQConnection _connection;
     private AMQDestination _destination;
@@ -67,10 +69,9 @@
         super.tearDown();
     }
 
-
     private void init(AMQConnection connection) throws Exception
     {
-        init(connection, new AMQQueue(connection,randomize("FieldTableMessageTest"), true));
+        init(connection, new AMQQueue(connection, randomize("FieldTableMessageTest"), true));
     }
 
     private void init(AMQConnection connection, AMQDestination destination) throws Exception
@@ -79,11 +80,11 @@
         _destination = destination;
         _session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
 
-        //set up a slow consumer
+        // set up a slow consumer
         _session.createConsumer(destination).setMessageListener(this);
         connection.start();
 
-        //_expected = new FieldTableTest().load("FieldTableTest2.properties");
+        // _expected = new FieldTableTest().load("FieldTableTest2.properties");
         _expected = load();
     }
 
@@ -111,7 +112,7 @@
 
     void send(int count) throws JMSException, IOException
     {
-        //create a publisher
+        // create a publisher
         MessageProducer producer = _session.createProducer(_destination);
         for (int i = 0; i < count; i++)
         {
@@ -123,7 +124,7 @@
 
     void waitFor(int count) throws InterruptedException
     {
-        synchronized(received)
+        synchronized (received)
         {
             while (received.size() < count)
             {
@@ -139,7 +140,7 @@
             ByteBuffer buffer = ((JMSBytesMessage) m).getData();
             FieldTable actual = FieldTableFactory.newFieldTable(buffer, buffer.remaining());
             for (String key : _expected.keys())
-            {                
+            {
                 assertEquals("Values for " + key + " did not match", _expected.getObject(key), actual.getObject(key));
             }
         }
@@ -147,7 +148,7 @@
 
     public void onMessage(Message message)
     {
-        synchronized(received)
+        synchronized (received)
         {
             received.add((JMSBytesMessage) message);
             received.notify();
@@ -162,9 +163,9 @@
     public static void main(String[] argv) throws Exception
     {
         FieldTableMessageTest test = new FieldTableMessageTest();
-        test._connectionString = argv.length == 0 ? "vm://:1" : argv[0];
+        test._connectionString = (argv.length == 0) ? "vm://:1" : argv[0];
         test.setUp();
-        test._count = argv.length > 1 ? Integer.parseInt(argv[1]) : 5;
+        test._count = (argv.length > 1) ? Integer.parseInt(argv[1]) : 5;
         test.test();
     }
 

Modified: incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java?view=diff&rev=546190&r1=546189&r2=546190
==============================================================================
--- incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java (original)
+++ incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/LargeMessageTest.java Mon Jun 11 09:43:57 2007
@@ -14,32 +14,36 @@
  *  "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.    
+ *  under the License.
+ *
  *
- * 
  */
 package org.apache.qpid.test.unit.basic;
 
 import junit.framework.TestCase;
-import org.apache.log4j.Logger;
+
 import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.transport.TransportConnection;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.jms.Destination;
-import javax.jms.Session;
-import javax.jms.MessageConsumer;
 import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.Session;
 import javax.jms.TextMessage;
-import java.util.List;
+
 import java.util.ArrayList;
+import java.util.List;
 
 public class LargeMessageTest extends TestCase
 {
-    private static final Logger _logger = Logger.getLogger(LargeMessageTest.class);
+    private static final Logger _logger = LoggerFactory.getLogger(LargeMessageTest.class);
 
     private AMQConnection _connection;
     private Destination _destination;
@@ -68,7 +72,7 @@
 
     private void init(AMQConnection connection) throws Exception
     {
-        Destination destination = new AMQQueue(connection,"LargeMessageTest", true);
+        Destination destination = new AMQQueue(connection, "LargeMessageTest", true);
         init(connection, destination);
     }
 
@@ -84,7 +88,7 @@
     // Test boundary of 1 packet to 2 packets
     public void test64kminus1()
     {
-        checkLargeMessage(64 * 1024 - 1);
+        checkLargeMessage((64 * 1024) - 1);
     }
 
     public void test64k()
@@ -94,13 +98,13 @@
 
     public void test64kplus1()
     {
-        checkLargeMessage(64 * 1024 + 1);
+        checkLargeMessage((64 * 1024) + 1);
     }
 
-    //Test packet boundary of 3 packtes
+    // Test packet boundary of 3 packtes
     public void test128kminus1()
     {
-        checkLargeMessage(128 * 1024 - 1);
+        checkLargeMessage((128 * 1024) - 1);
     }
 
     public void test128k()
@@ -110,7 +114,7 @@
 
     public void test128kplus1()
     {
-        checkLargeMessage(128 * 1024 + 1);
+        checkLargeMessage((128 * 1024) + 1);
     }
 
     // Testing larger messages
@@ -167,10 +171,10 @@
         {
             builder.append(ch);
 
-            if (i % 1000 == 0)
+            if ((i % 1000) == 0)
             {
                 ch++;
-                if (ch == 'z' + 1)
+                if (ch == ('z' + 1))
                 {
                     ch = 'a';
                 }
@@ -179,7 +183,6 @@
 
         return builder.toString();
     }
-
 
     public static junit.framework.Test suite()
     {



Mime
View raw message