camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r821684 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/model/ test/java/org/apache/camel/component/file/ test/java/org/apache/camel/issues/
Date Mon, 05 Oct 2009 04:52:37 GMT
Author: davsclaus
Date: Mon Oct  5 04:52:37 2009
New Revision: 821684

URL: http://svn.apache.org/viewvc?rev=821684&view=rev
Log:
Fixed unit test

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
  (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FromFileMoveFileIfProcessFailsTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=821684&r1=821683&r2=821684&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Mon
Oct  5 04:52:37 2009
@@ -171,10 +171,8 @@
         // init the channel
         channel.initChannel(this, routeContext);
 
-        ProcessorDefinition defn = (ProcessorDefinition) this;
-
         // set the error handler, must be done after init as we can set the error handler
as first in the chain
-        if (defn instanceof TryDefinition || defn instanceof CatchDefinition || defn instanceof
FinallyDefinition) {
+        if (this instanceof TryDefinition || this instanceof CatchDefinition || this instanceof
FinallyDefinition) {
             // do not use error handler for try .. catch .. finally blocks as it will handle
errors itself
             return channel;
         } else {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FromFileMoveFileIfProcessFailsTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FromFileMoveFileIfProcessFailsTest.java?rev=821684&r1=821683&r2=821684&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FromFileMoveFileIfProcessFailsTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FromFileMoveFileIfProcessFailsTest.java
Mon Oct  5 04:52:37 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.file;
 
-import java.io.File;
-
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -29,8 +27,6 @@
  */
 public class FromFileMoveFileIfProcessFailsTest extends ContextTestSupport {
 
-    private String body = "Hello World this file will NOT be moved";
-
     @Override
     protected void setUp() throws Exception {
         deleteDirectory("./target/movefile");
@@ -38,28 +34,19 @@
     }
 
     public void testPollFileAndShouldNotBeMoved() throws Exception {
-        template.sendBodyAndHeader("file://target/movefile", body, Exchange.FILE_NAME, "hello.txt");
+        template.sendBodyAndHeader("file://target/movefile", "Hello World", Exchange.FILE_NAME,
"hello.txt");
 
-        MockEndpoint mock = getMockEndpoint("mock:error");
-        mock.expectedBodiesReceived(body);
+        MockEndpoint mock = getMockEndpoint("mock:foo");
+        mock.expectedBodiesReceived("Hello World");
+        mock.expectedFileExists("target/movefile/error/hello.txt", "Hello World");
 
         mock.assertIsSatisfied();
-
-        // give time to NOT delete file
-        Thread.sleep(200);
-
-        // assert the file is moved
-        File file = new File("./target/movefile/error/hello.txt");
-        file = file.getAbsoluteFile();
-        assertTrue("The file should have been moved", file.exists());
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                errorHandler(deadLetterChannel("mock:error").maximumRedeliveries(2).redeliverDelay(0).logStackTrace(false).handled(false));
-
-                from("file://target/movefile?moveFailed=error").process(new Processor() {
+                from("file://target/movefile?moveFailed=error").to("mock:foo").process(new
Processor() {
                     public void process(Exchange exchange) throws Exception {
                         throw new IllegalArgumentException("Forced by unittest");
                     }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java?rev=821684&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
Mon Oct  5 04:52:37 2009
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.issues;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Route;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class CoarseGrainedProcessorDefinitionIssueTest extends ContextTestSupport {
+
+    public void testCoarseGrainedProcessorDefinition() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+
+        Route route = context.getRoutes().get(0);
+
+        // TODO: drill down the route and check that Channel have
+        // the fine grained processor definition assigned
+        // this also helps the tracer as it now can better pin point it exact location
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").delay(500).to("direct:foo").to("mock:result");
+            }
+        };
+    }
+}

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/CoarseGrainedProcessorDefinitionIssueTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message