servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r649435 - in /servicemix/smx3/branches/servicemix-3.2.2: core/servicemix-core/src/main/java/org/apache/servicemix/components/util/ deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/ deployables/serviceengines...
Date Fri, 18 Apr 2008 09:49:10 GMT
Author: ffang
Date: Fri Apr 18 02:49:08 2008
New Revision: 649435

URL: http://svn.apache.org/viewvc?rev=649435&view=rev
Log:
sync up changes to 3.2.2 release branch

Modified:
    servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/TraceComponent.java
    servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java
    servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-quartz/src/test/java/org/apache/servicemix/quartz/QuartzComponentTest.java

Modified: servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/TraceComponent.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/TraceComponent.java?rev=649435&r1=649434&r2=649435&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/TraceComponent.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2.2/core/servicemix-core/src/main/java/org/apache/servicemix/components/util/TraceComponent.java
Fri Apr 18 02:49:08 2008
@@ -19,6 +19,7 @@
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.MessagingException;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 
 import org.apache.commons.logging.Log;
@@ -54,8 +55,14 @@
         this.sourceTransformer = sourceTransformer;
     }
 
+    /** 
+     * Intercepts the {@link MessageExchange} to output the message and its 
+     * properties for debugging purposes. 
+     * 
+     * @param exchange A JBI {@link MessageExchange} between two endpoints
+     */
     public void onMessageExchange(MessageExchange exchange) throws MessagingException {
-        // lets dump the incoming message
+        // lets dump the incoming message  
         NormalizedMessage message = exchange.getMessage("in");
         if (message == null) {
             log.warn("Received null message from exchange: " + exchange);
@@ -66,7 +73,40 @@
             } catch (TransformerException e) {
                 log.error("Failed to turn message body into text: " + e, e);
             }
+            outputProperties(message);
         }
         done(exchange);
+    }
+    
+    /**
+     * Outputs the properties on the {@link NormalizedMessage}. Properties of 
+     * type {@link Source} are transformed to a {@link String} before 
+     * being output.
+     *
+     * @param message The {@link NormalizedMessage} to be processed
+     */
+    @SuppressWarnings("unchecked")
+    protected void outputProperties(NormalizedMessage message) {
+        // Loop over all the properties on the normalized message 
+        for (Object o : message.getPropertyNames()) {
+            // NormalizedMessage API does not use generics. This interface is
+            // written in Java older than 5.0. On the basis of other methods and
+            // the default implementation of this interface we can assume that
+            // only String keys are allowed.
+            String key = (String) o;
+            try {
+                Object contents = message.getProperty(key);
+                // Is this the only value type that we would like to treat
+                // differently? The default behavior is to invoke toString() on
+                // the object.
+                if (contents instanceof Source) {
+                    contents = getSourceTransformer().toString((Source) contents);
+                }
+
+                log.info("Value for property '" + key + "' is: " + contents);
+            } catch (TransformerException e) {
+                log.error("Failed to turn property '" + key + "' value into text: " + e,
e);
+            }
+        }
     }
 }

Modified: servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java?rev=649435&r1=649434&r2=649435&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-eip/src/test/java/org/apache/servicemix/eip/SpringConfigurationTest.java
Fri Apr 18 02:49:08 2008
@@ -57,7 +57,8 @@
         ActivationSpec as = new ActivationSpec();
         as.setComponentName("client");
         ServiceMixClient client = new DefaultServiceMixClient(jbi, as);
-        
+
+        Thread.sleep(2000);
         int nbMsgs = 100;
         for (int i = 0; i < nbMsgs; i++) {
             InOnly me = client.createInOnlyExchange();
@@ -66,9 +67,11 @@
                     "<test xmlns=\"http://test\"><echo/><world/><earth/></test>"));
             client.send(me);
         }
+        Thread.sleep(2000);
         for (int i = 0; i < nbMsgs; i++) {
             client.receive();
         }
+        Thread.sleep(2000);
         ((Receiver) getBean("trace1")).getMessageList().assertMessagesReceived(1 * nbMsgs);
         ((Receiver) getBean("trace2")).getMessageList().assertMessagesReceived(1 * nbMsgs);
         ((Receiver) getBean("trace3")).getMessageList().assertMessagesReceived(1 * nbMsgs);
@@ -76,7 +79,7 @@
         ((Receiver) getBean("trace5")).getMessageList().assertMessagesReceived(1 * nbMsgs);
         
         // Wait for all messages to be processed
-        Thread.sleep(50);
+        Thread.sleep(2000);
     }
 
     protected AbstractXmlApplicationContext createBeanFactory() {

Modified: servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-quartz/src/test/java/org/apache/servicemix/quartz/QuartzComponentTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-quartz/src/test/java/org/apache/servicemix/quartz/QuartzComponentTest.java?rev=649435&r1=649434&r2=649435&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-quartz/src/test/java/org/apache/servicemix/quartz/QuartzComponentTest.java
(original)
+++ servicemix/smx3/branches/servicemix-3.2.2/deployables/serviceengines/servicemix-quartz/src/test/java/org/apache/servicemix/quartz/QuartzComponentTest.java
Fri Apr 18 02:49:08 2008
@@ -49,16 +49,16 @@
         
         jbi.start();
 
-        Thread.sleep(200);
+        Thread.sleep(1000);
         assertTrue(receiver.getMessageList().flushMessages().size() > 0);
         
         quartz.stop();
+        Thread.sleep(1000);
         receiver.getMessageList().flushMessages();
-        Thread.sleep(200);
         assertEquals(0, receiver.getMessageList().flushMessages().size());
         
         quartz.start();
-        Thread.sleep(200);
+        Thread.sleep(1000);
         assertTrue(receiver.getMessageList().flushMessages().size() > 0);
 
         jbi.shutDown();



Mime
View raw message