activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r577882 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/broker/ test/java/org/apache/activemq/ test/java/org/apache/activemq/broker/ test/java/org/apache/activemq/test/
Date Thu, 20 Sep 2007 19:11:45 GMT
Author: chirino
Date: Thu Sep 20 12:11:44 2007
New Revision: 577882

URL: http://svn.apache.org/viewvc?rev=577882&view=rev
Log:
Better broker shutdown handling and also better test support.

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/StubConnection.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?rev=577882&r1=577881&r2=577882&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Thu Sep 20 12:11:44 2007
@@ -313,36 +313,34 @@
 
     public Response service(Command command) {
         Response response = null;
-        if (broker.getBrokerService().isStarted()) {
-            boolean responseRequired = command.isResponseRequired();
-            int commandId = command.getCommandId();
-            try {
-                response = command.visit(this);
-            } catch (Throwable e) {
-                if (responseRequired) {
-                    if (SERVICELOG.isDebugEnabled() && e.getClass() != BrokerStoppedException.class)
{
-                        SERVICELOG.debug("Error occured while processing sync command: "
+ e, e);
-                    }
-                    response = new ExceptionResponse(e);
-                } else {
-                    serviceException(e);
-                }
-            }
+        boolean responseRequired = command.isResponseRequired();
+        int commandId = command.getCommandId();
+        try {
+            response = command.visit(this);
+        } catch (Throwable e) {
             if (responseRequired) {
-                if (response == null) {
-                    response = new Response();
+                if (SERVICELOG.isDebugEnabled() && e.getClass() != BrokerStoppedException.class)
{
+                    SERVICELOG.debug("Error occured while processing sync command: " + e,
e);
                 }
-                response.setCorrelationId(commandId);
+                response = new ExceptionResponse(e);
+            } else {
+                serviceException(e);
             }
-            // The context may have been flagged so that the response is not
-            // sent.
-            if (context != null) {
-                if (context.isDontSendReponse()) {
-                    context.setDontSendReponse(false);
-                    response = null;
-                }
-                context = null;
+        }
+        if (responseRequired) {
+            if (response == null) {
+                response = new Response();
+            }
+            response.setCorrelationId(commandId);
+        }
+        // The context may have been flagged so that the response is not
+        // sent.
+        if (context != null) {
+            if (context.isDontSendReponse()) {
+                context.setDontSendReponse(false);
+                response = null;
             }
+            context = null;
         }
         return response;
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTestSupport.java?rev=577882&r1=577881&r2=577882&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTestSupport.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsTestSupport.java Thu
Sep 20 12:11:44 2007
@@ -124,6 +124,7 @@
                 conn.close();
             } catch (Throwable e) {
             }
+            iter.remove();
         }
         broker.stop();
         super.tearDown();

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java?rev=577882&r1=577881&r2=577882&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/BrokerTestSupport.java
Thu Sep 20 12:11:44 2007
@@ -347,7 +347,7 @@
                 return;
             }
             if (o instanceof MessageDispatch && ((MessageDispatch)o).getMessage()
!= null) {
-                fail("Received a message.");
+                fail("Received a message: "+((MessageDispatch)o).getMessage().getMessageId());
             }
         }
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/StubConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/StubConnection.java?rev=577882&r1=577881&r2=577882&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/StubConnection.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/broker/StubConnection.java
Thu Sep 20 12:11:44 2007
@@ -29,6 +29,7 @@
 import org.apache.activemq.transport.DefaultTransportListener;
 import org.apache.activemq.transport.Transport;
 import org.apache.activemq.transport.TransportFactory;
+import org.apache.activemq.transport.TransportListener;
 import org.apache.activemq.util.JMSExceptionSupport;
 import org.apache.activemq.util.ServiceSupport;
 
@@ -38,6 +39,7 @@
     private Connection connection;
     private Transport transport;
     private boolean shuttingDown;
+    private TransportListener listener;
 
     public StubConnection(BrokerService broker) throws Exception {
         this(TransportFactory.connect(broker.getVmConnectorURI()));
@@ -62,6 +64,9 @@
             }
 
             public void onException(IOException error) {
+                if (listener != null) {
+                    listener.onException(error);
+                }
                 if (!shuttingDown) {
                     error.printStackTrace();
                 }
@@ -71,6 +76,9 @@
     }
 
     protected void dispatch(Object command) throws InterruptedException, IOException {
+        if (listener != null) {
+            listener.onCommand(command);
+        }
         dispatchQueue.put(command);
     }
 
@@ -139,5 +147,13 @@
             }
             ServiceSupport.dispose(transport);
         }
+    }
+
+    public TransportListener getListener() {
+        return listener;
+    }
+
+    public void setListener(TransportListener listener) {
+        this.listener = listener;
     }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java?rev=577882&r1=577881&r2=577882&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/test/JmsSendReceiveTestSupport.java
Thu Sep 20 12:11:44 2007
@@ -33,6 +33,8 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
+import junit.framework.AssertionFailedError;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -167,7 +169,15 @@
 
         for (int i = 0; i < data.length; i++) {
             Message received = receivedMessages.get(i);
-            assertMessageValid(i, received);
+            try {
+                assertMessageValid(i, received);
+            } catch (AssertionFailedError e) {
+                for (int j = 0; j < data.length; j++) {
+                    Message m = receivedMessages.get(j);
+                    System.out.println(j+" => "+m.getJMSMessageID());
+                }
+                throw e;
+            }
         }
     }
 



Mime
View raw message