You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2009/12/22 14:34:16 UTC

svn commit: r893163 - in /camel/trunk: camel-core/src/test/java/org/apache/camel/component/file/ components/camel-spring/src/test/java/org/apache/camel/spring/file/ components/camel-spring/src/test/resources/org/apache/camel/spring/file/

Author: davsclaus
Date: Tue Dec 22 13:34:16 2009
New Revision: 893163

URL: http://svn.apache.org/viewvc?rev=893163&view=rev
Log:
CAMEL-2309: Add unit test based on user issue.

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveIssueTest.java
      - copied, changed from r892726, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml
      - copied, changed from r892726, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileRouteTest-context.xml
Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveIssueTest.java (from r892726, camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveIssueTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveIssueTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java&r1=892726&r2=893163&rev=893163&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveIssueTest.java Tue Dec 22 13:34:16 2009
@@ -27,7 +27,7 @@
 /**
  * @version $Revision$
  */
-public class FileConsumerPreMoveTest extends ContextTestSupport {
+public class FileConsumerPreMoveIssueTest extends ContextTestSupport {
 
     @Override
     protected void setUp() throws Exception {
@@ -44,32 +44,23 @@
         assertMockEndpointsSatisfied();
     }
 
-    public void testPreMoveSameFileTwice() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceivedInAnyOrder("Hello World", "Hello Again World");
-
-        template.sendBodyAndHeader("file://target/premove", "Hello World", Exchange.FILE_NAME, "hello.txt");
-        // give time for consumer to process this file before we drop the next file
-        Thread.sleep(2000);
-        template.sendBodyAndHeader("file://target/premove", "Hello Again World", Exchange.FILE_NAME, "hello.txt");
-
-        assertMockEndpointsSatisfied();
-    }
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/premove?preMove=work/work-${file:name}")
-                    .process(new Processor() {
-                        public void process(Exchange exchange) throws Exception {
-                            File pre = new File("target/premove/work/work-hello.txt").getAbsoluteFile();
-                            assertTrue("Pre move file should exist", pre.exists());
-                        }
-                    })
+                from("file://target/premove?preMove=before/${file:name.noext}-moved.${file:ext}")
+                    .process(new MyPreMoveCheckerProcessor())
                     .to("mock:result");
             }
         };
     }
-}
+
+    public static class MyPreMoveCheckerProcessor implements Processor {
+
+        public void process(Exchange exchange) throws Exception {
+            File pre = new File("target/premove/before/hello-moved.txt").getAbsoluteFile();
+            assertTrue("Pre move file should exist", pre.exists());
+        }
+    }
+}
\ No newline at end of file

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java?rev=893163&r1=893162&r2=893163&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerPreMoveTest.java Tue Dec 22 13:34:16 2009
@@ -62,14 +62,17 @@
             @Override
             public void configure() throws Exception {
                 from("file://target/premove?preMove=work/work-${file:name}")
-                    .process(new Processor() {
-                        public void process(Exchange exchange) throws Exception {
-                            File pre = new File("target/premove/work/work-hello.txt").getAbsoluteFile();
-                            assertTrue("Pre move file should exist", pre.exists());
-                        }
-                    })
+                    .process(new MyPreMoveCheckerProcessor())
                     .to("mock:result");
             }
         };
     }
+
+    public static class MyPreMoveCheckerProcessor implements Processor {
+
+        public void process(Exchange exchange) throws Exception {
+            File pre = new File("target/premove/work/work-hello.txt").getAbsoluteFile();
+            assertTrue("Pre move file should exist", pre.exists());
+        }
+    }
 }

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java?rev=893163&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java Tue Dec 22 13:34:16 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.file;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.FileConsumerPreMoveIssueTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringFileConsumerPreMoveIssueTest extends FileConsumerPreMoveIssueTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java?rev=893163&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java Tue Dec 22 13:34:16 2009
@@ -0,0 +1,33 @@
+/**
+ * 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.spring.file;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.file.FileConsumerPreMoveTest;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+/**
+ * @version $Revision$
+ */
+public class SpringFileConsumerPreMoveTest extends FileConsumerPreMoveTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml");
+    }
+
+}

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml?rev=893163&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml Tue Dec 22 13:34:16 2009
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="file://target/premove?preMove=before/${file:name.noext}-moved.${file:ext}"/>
+            <process ref="checker"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+
+    <bean id="checker" class="org.apache.camel.component.file.FileConsumerPreMoveIssueTest$MyPreMoveCheckerProcessor"/>
+
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml (from r892726, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileRouteTest-context.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileRouteTest-context.xml&r1=892726&r2=893163&rev=893163&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileRouteTest-context.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml Tue Dec 22 13:34:16 2009
@@ -22,19 +22,14 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: example -->
     <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <template id="camelTemplate"/>
-
         <route>
-            <from ref="inputFile"/>
+            <from uri="file://target/premove?preMove=work/work-${file:name}"/>
+            <process ref="checker"/>
             <to uri="mock:result"/>
         </route>
     </camelContext>
 
-    <bean id="inputFile" class="org.apache.camel.component.file.FileEndpoint">
-        <property name="file" value="target/test-default-inbox"/>
-    </bean>
-    <!-- END SNIPPET: example -->
+    <bean id="checker" class="org.apache.camel.component.file.FileConsumerPreMoveTest$MyPreMoveCheckerProcessor"/>
 
 </beans>