camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r789062 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/component/bean/ main/java/org/apache/camel/component/file/ main/java/org/apache/camel/processor/interceptor/ test/java/org/apache/camel/processor/ test/java/org/apache/cam...
Date Sun, 28 Jun 2009 07:47:19 GMT
Author: davsclaus
Date: Sun Jun 28 07:47:19 2009
New Revision: 789062

URL: http://svn.apache.org/viewvc?rev=789062&view=rev
Log:
CAMEL-1759: Added more unit tests. Fixed CS.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTraceTest.java
      - copied, changed from r789058, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTraceTest.java
      - copied, changed from r789058, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/DefaultParameterMappingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/DefaultParameterMappingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/DefaultParameterMappingStrategy.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/DefaultParameterMappingStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/bean/DefaultParameterMappingStrategy.java
Sun Jun 28 07:47:19 2009
@@ -19,13 +19,13 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Message;
 import org.apache.camel.TypeConverter;
-import org.apache.camel.CamelContext;
-import org.apache.camel.spi.Registry;
 import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.spi.Registry;
 
 /**
  * Represents the strategy used to figure out how to map a message exchange to a POJO method
invocation

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileExchange.java
Sun Jun 28 07:47:19 2009
@@ -54,15 +54,15 @@
 
     public void exchangePolled(Exchange exchange) {
         GenericFile<T> file = getGenericFile();
-        if (file != null)
-        {
+        if (file != null) {
             try {
                 // load content into memory
                 file.getBinding().loadContent(exchange, file);
             } catch (IOException e) {
-                throw new RuntimeExchangeException("Cannot load content of file: " 
-                    + file.getAbsoluteFilePath(), exchange, e);
+                throw new RuntimeExchangeException("Cannot load content of file: "
+                        + file.getAbsoluteFilePath(), exchange, e);
             }
         }
     }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
Sun Jun 28 07:47:19 2009
@@ -21,8 +21,8 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
-import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.RouteNode;
+import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.TraceableUnitOfWork;
 import org.apache.camel.util.MessageHelper;
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
Sun Jun 28 07:47:19 2009
@@ -187,7 +187,8 @@
         if (index == 0) {
             // yes its first time then do some special to log and trace the start of onException
             Expression exp = new Expression() {
-                public <T> T evaluate(Exchange exchange, Class<T> type) {
+                @SuppressWarnings("unchecked")
+                public Object evaluate(Exchange exchange, Class type) {
                     String label = "OnException";
                     if (exchange.getProperty(Exchange.EXCEPTION_CAUGHT) != null) {
                         label += "[" + exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class).getClass().getSimpleName()
+ "]";
@@ -226,7 +227,8 @@
             if (index == 0) {
                 // yes its first time then do some special to log and trace the start of
onCompletion
                 Expression exp = new Expression() {
-                    public <T> T evaluate(Exchange exchange, Class<T> type) {
+                    @SuppressWarnings("unchecked")
+                    public Object evaluate(Exchange exchange, Class type) {
                         String label = "OnCompletion[" + exchange.getProperty(Exchange.CORRELATION_ID)
+ "]";
                         return exchange.getContext().getTypeConverter().convertTo(type, label);
                     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
Sun Jun 28 07:47:19 2009
@@ -62,8 +62,6 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                context.setTracing(true);
-
                 // START SNIPPET: e1
                 // define a global on completion that is invoked when the exchage is complete
                 onCompletion().to("log:global").to("mock:sync");

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTraceTest.java
(from r789058, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTraceTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTraceTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java&r1=789058&r2=789062&rev=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/OnCompletionGlobalTraceTest.java
Sun Jun 28 07:47:19 2009
@@ -22,15 +22,18 @@
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.interceptor.TraceEventMessage;
+import org.apache.camel.processor.interceptor.Tracer;
 
 /**
  * @version $Revision$
  */
-public class OnCompletionGlobalTest extends ContextTestSupport {
+public class OnCompletionGlobalTraceTest extends ContextTestSupport {
 
     public void testSynchronizeComplete() throws Exception {
         getMockEndpoint("mock:sync").expectedBodiesReceived("Bye World");
         getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
+        getMockEndpoint("mock:trace").expectedMessageCount(4);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Bye World");
@@ -38,11 +41,29 @@
         template.sendBody("direct:start", "Hello World");
 
         assertMockEndpointsSatisfied();
+
+        TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg4 = getMockEndpoint("mock:trace").getReceivedExchanges().get(3).getIn().getBody(TraceEventMessage.class);
+
+        assertEquals("direct:start", msg1.getFromEndpointUri());
+        assertTrue(msg1.getToNode().startsWith("org.apache.camel.processor.OnCompletionGlobalTraceTest"));
+
+        assertTrue(msg2.getPreviousNode().startsWith("org.apache.camel.processor.OnCompletionGlobalTraceTest"));
+        assertEquals("mock:result", msg2.getToNode());
+
+        assertTrue(msg3.getPreviousNode().startsWith("OnCompletion"));
+        assertEquals("log:global", msg3.getToNode());
+
+        assertEquals("log:global", msg4.getPreviousNode());
+        assertEquals("mock:sync", msg4.getToNode());
     }
 
     public void testSynchronizeFailure() throws Exception {
         getMockEndpoint("mock:sync").expectedMessageCount(1);
         getMockEndpoint("mock:sync").expectedPropertyReceived(Exchange.ON_COMPLETION, true);
+        getMockEndpoint("mock:trace").expectedMessageCount(3);
 
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(0);
@@ -55,6 +76,19 @@
         }
 
         assertMockEndpointsSatisfied();
+
+        TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
+
+        assertEquals("direct:start", msg1.getFromEndpointUri());
+        assertTrue(msg1.getToNode().startsWith("org.apache.camel.processor.OnCompletionGlobalTraceTest"));
+
+        assertTrue(msg2.getPreviousNode().startsWith("OnCompletion"));
+        assertEquals("log:global", msg2.getToNode());
+
+        assertEquals("log:global", msg3.getPreviousNode());
+        assertEquals("mock:sync", msg3.getToNode());
     }
 
     @Override
@@ -62,7 +96,9 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                context.setTracing(true);
+                Tracer tracer = new Tracer();
+                tracer.setDestinationUri("mock:trace");
+                context.addInterceptStrategy(tracer);
 
                 // START SNIPPET: e1
                 // define a global on completion that is invoked when the exchage is complete

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceableUnitOfWorkTest.java
Sun Jun 28 07:47:19 2009
@@ -21,9 +21,9 @@
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.RouteNode;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
-import org.apache.camel.RouteNode;
 import org.apache.camel.spi.TraceableUnitOfWork;
 
 /**

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java?rev=789062&r1=789061&r2=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java
Sun Jun 28 07:47:19 2009
@@ -41,8 +41,6 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                context.setTracing(true);
-
                 intercept().to("mock:intercepted");
 
                 from("direct:start")

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTraceTest.java
(from r789058, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTraceTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTraceTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java&r1=789058&r2=789062&rev=789062&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteTraceTest.java
Sun Jun 28 07:47:19 2009
@@ -18,11 +18,13 @@
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.processor.interceptor.TraceEventMessage;
+import org.apache.camel.processor.interceptor.Tracer;
 
 /**
  * @version $Revision$
  */
-public class InterceptSimpleRouteTest extends ContextTestSupport {
+public class InterceptSimpleRouteTraceTest extends ContextTestSupport {
 
     public void testIntercept() throws Exception {
         getMockEndpoint("mock:foo").expectedMessageCount(1);
@@ -30,10 +32,36 @@
         getMockEndpoint("mock:result").expectedMessageCount(1);
 
         getMockEndpoint("mock:intercepted").expectedMessageCount(3);
+        getMockEndpoint("mock:trace").expectedMessageCount(6);
 
         template.sendBody("direct:start", "Hello World");
 
         assertMockEndpointsSatisfied();
+
+        TraceEventMessage msg1 = getMockEndpoint("mock:trace").getReceivedExchanges().get(0).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg2 = getMockEndpoint("mock:trace").getReceivedExchanges().get(1).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg3 = getMockEndpoint("mock:trace").getReceivedExchanges().get(2).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg4 = getMockEndpoint("mock:trace").getReceivedExchanges().get(3).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg5 = getMockEndpoint("mock:trace").getReceivedExchanges().get(4).getIn().getBody(TraceEventMessage.class);
+        TraceEventMessage msg6 = getMockEndpoint("mock:trace").getReceivedExchanges().get(5).getIn().getBody(TraceEventMessage.class);
+
+        assertEquals("direct:start", msg1.getFromEndpointUri());
+        assertEquals("mock:intercepted", msg1.getToNode());
+
+        assertEquals("mock:intercepted", msg2.getPreviousNode());
+        assertEquals("mock:foo", msg2.getToNode());
+
+        assertEquals("mock:foo", msg3.getPreviousNode());
+        assertEquals("mock:intercepted", msg3.getToNode());
+
+        assertEquals("mock:intercepted", msg4.getPreviousNode());
+        assertEquals("mock:bar", msg4.getToNode());
+
+        assertEquals("mock:bar", msg5.getPreviousNode());
+        assertEquals("mock:intercepted", msg5.getToNode());
+
+        assertEquals("mock:intercepted", msg6.getPreviousNode());
+        assertEquals("mock:result", msg6.getToNode());
     }
 
     @Override
@@ -41,7 +69,9 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                context.setTracing(true);
+                Tracer tracer = new Tracer();
+                tracer.setDestinationUri("mock:trace");
+                context.addInterceptStrategy(tracer);
 
                 intercept().to("mock:intercepted");
 
@@ -50,4 +80,4 @@
             }
         };
     }
-}
+}
\ No newline at end of file



Mime
View raw message