svn commit: r735733 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/processor/interceptor/ components/camel-jms/src/test/java/org/apache/camel/component/jms/ components/camel-jp...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r735733 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/processor/interceptor/ components/camel-jms/src/test/java/org/apache/camel/component/jms/ components/camel-jp...

davsclaus-2
Author: davsclaus
Date: Mon Jan 19 07:45:43 2009
New Revision: 735733

URL: http://svn.apache.org/viewvc?rev=735733&view=rev
Log:
CAMEL-1255: Added jpa trace event. Added assert not null in batch processor since I get a NPE. Added jms unit tests based on end user having a problem. Removed TODO in code.

Added:
    activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java
      - copied, changed from r735663, activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
    activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/processor/interceptor/JpaTraceEventMessage.java
    activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamComponent.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=735733&r1=735732&r2=735733&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java Mon Jan 19 07:45:43 2009
@@ -25,6 +25,7 @@
 import org.apache.camel.impl.LoggingExceptionHandler;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.spi.ExceptionHandler;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.ServiceHelper;
 
 /**
@@ -49,6 +50,8 @@
     private BatchSender sender;
     
     public BatchProcessor(Processor processor, Collection<Exchange> collection) {
+        ObjectHelper.notNull(processor, "processor");
+        ObjectHelper.notNull(collection, "collection");
         this.processor = processor;
         this.collection = collection;
         this.sender = new BatchSender();

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java?rev=735733&r1=735732&r2=735733&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceEventMessage.java Mon Jan 19 07:45:43 2009
@@ -31,8 +31,8 @@
 public final class DefaultTraceEventMessage implements Serializable, TraceEventMessage {
 
     private Date timestamp;
-    private String previousNode;
     private String fromEndpointUri;
+    private String previousNode;
     private String toNode;
     private String exchangeId;
     private String shortExchangeId;
@@ -41,6 +41,7 @@
     private String headers;
     private String body;
     private String bodyType;
+    private String outHeaders;
     private String outBody;
     private String outBodyType;
     private String causedByException;
@@ -70,8 +71,11 @@
         this.headers = in.getHeaders().isEmpty() ? null : in.getHeaders().toString();
         this.body = MessageHelper.extractBodyAsString(in);
         this.bodyType = MessageHelper.getBodyTypeName(in);
-        this.outBody = MessageHelper.extractBodyAsString(out);
-        this.outBodyType = MessageHelper.getBodyTypeName(out);
+        if (out != null) {
+            this.outHeaders = out.getHeaders().isEmpty() ? null : out.getHeaders().toString();
+            this.outBody = MessageHelper.extractBodyAsString(out);
+            this.outBodyType = MessageHelper.getBodyTypeName(out);
+        }
         this.causedByException = exchange.getException() != null ? exchange.getException().toString() : null;
     }
 
@@ -149,6 +153,14 @@
         return outBodyType;
     }
 
+    public String getOutHeaders() {
+        return outHeaders;
+    }
+
+    public void setOutHeaders(String outHeaders) {
+        this.outHeaders = outHeaders;
+    }
+
     public String getCausedByException() {
         return causedByException;
     }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java?rev=735733&r1=735732&r2=735733&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DefaultTraceFormatter.java Mon Jan 19 07:45:43 2009
@@ -38,6 +38,7 @@
     private boolean showHeaders = true;
     private boolean showBody = true;
     private boolean showBodyType = true;
+    private boolean showOutHeaders;
     private boolean showOutBody;
     private boolean showOutBodyType;
     private boolean showException = true;
@@ -66,6 +67,9 @@
         if (showBody) {
             sb.append(", Body:").append(MessageHelper.extractBodyAsString(in));
         }
+        if (showOutHeaders && out != null) {
+            sb.append(", OutHeaders:").append(out.getHeaders());
+        }
         if (showOutBodyType && out != null) {
             sb.append(", OutBodyType:").append(MessageHelper.getBodyTypeName(out));
         }
@@ -135,6 +139,14 @@
         this.showHeaders = showHeaders;
     }
 
+    public boolean isShowOutHeaders() {
+        return showOutHeaders;
+    }
+
+    public void setShowOutHeaders(boolean showOutHeaders) {
+        this.showOutHeaders = showOutHeaders;
+    }
+
     public boolean isShowProperties() {
         return showProperties;
     }

Copied: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java (from r735663, activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java?p2=activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java&p1=activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java&r1=735663&r2=735733&rev=735733&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsTest.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/FileRouteToJmsToFileTest.java Mon Jan 19 07:45:43 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.jms;
 
+import java.io.File;
 import javax.jms.ConnectionFactory;
 
 import org.apache.activemq.ActiveMQConnectionFactory;
@@ -29,22 +30,25 @@
 
 
 /**
- * Unit test that we can produce JMS message from files
+ * Unit test that we can do file over JMS to file.
  */
-public class FileRouteToJmsTest extends ContextTestSupport {
+public class FileRouteToJmsToFileTest extends ContextTestSupport {
 
     protected String componentName = "activemq";
 
-    public void testRouteToFile() throws Exception {
+    public void testRouteFileToFile() throws Exception {
+        deleteDirectory("target/file2file");
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
-        mock.message(0).body().isInstanceOf(byte[].class);
-        mock.message(0).bodyAs(String.class).isEqualTo("Hello World");
 
-        deleteDirectory("target/routefromfile");
-        template.sendBodyAndHeader("file://target/routefromfile", "Hello World", FileComponent.HEADER_FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader("file://target/file2file/in", "Hello World", FileComponent.HEADER_FILE_NAME, "hello.txt");
 
         assertMockEndpointsSatisfied();
+        Thread.sleep(100);
+
+        File file = new File("./target/file2file/out/hello.txt");
+        file = file.getAbsoluteFile();
+        assertTrue("The file should exists", file.exists());
     }
 
     protected CamelContext createCamelContext() throws Exception {
@@ -59,9 +63,9 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                from("file://target/routefromfile").to("activemq:queue:hello");
+                from("file://target/file2file/in").to("activemq:queue:hello");
 
-                from("activemq:queue:hello").to("mock:result");
+                from("activemq:queue:hello").to("file://target/file2file/out", "mock:result");
             }
         };
     }

Modified: activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/processor/interceptor/JpaTraceEventMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/processor/interceptor/JpaTraceEventMessage.java?rev=735733&r1=735732&r2=735733&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/processor/interceptor/JpaTraceEventMessage.java (original)
+++ activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/processor/interceptor/JpaTraceEventMessage.java Mon Jan 19 07:45:43 2009
@@ -34,8 +34,8 @@
 
     protected Long id;
     protected Date timestamp;
-    protected String previousNode;
     protected String fromEndpointUri;
+    protected String previousNode;
     protected String toNode;
     protected String exchangeId;
     protected String shortExchangeId;
@@ -44,6 +44,7 @@
     protected String headers;
     protected String body;
     protected String bodyType;
+    protected String outHeaders;
     protected String outBody;
     protected String outBodyType;
     protected String causedByException;
@@ -165,6 +166,14 @@
         this.outBodyType = outBodyType;
     }
 
+    public String getOutHeaders() {
+        return outHeaders;
+    }
+
+    public void setOutHeaders(String outHeaders) {
+        this.outHeaders = outHeaders;
+    }
+
     public String getCausedByException() {
         return causedByException;
     }

Modified: activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamComponent.java?rev=735733&r1=735732&r2=735733&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamComponent.java (original)
+++ activemq/camel/trunk/components/camel-stream/src/main/java/org/apache/camel/component/stream/StreamComponent.java Mon Jan 19 07:45:43 2009
@@ -26,9 +26,6 @@
  */
 public class StreamComponent extends DefaultComponent {
 
-    // TODO: remove file and url support in this component. Will be removed in Camel 2.0
-    // (Should use other components for such needs.)
-
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map parameters)
         throws Exception {