Author: davsclaus
Date: Thu Dec 16 16:24:30 2010
New Revision: 1050041

URL: http://svn.apache.org/viewvc?rev=1050041&view=rev
Log:
Added test based on user forum issue.

Added:
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
      - copied, changed from r1049805, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
Modified:
    
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java

Added: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java?rev=1050041&view=auto
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
 (added)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest.java
 Thu Dec 16 16:24:30 2010
@@ -0,0 +1,29 @@
+/**
+ * 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.component.file.remote;
+
+/**
+ * @version $Revision: 889125 $
+ */
+public class FtpProducerFileExistOverrideNotEagerDeleteTargetFileTwoUploadTest 
extends FtpProducerFileExistOverrideTwoUploadTest {
+
+    protected String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort() + 
"/exist?password=admin&tempPrefix=upload-&fileExist=Override&disconnect=true&eagerDeleteTargetFile=false";
+    }
+
+}
+

Modified: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java?rev=1050041&r1=1050040&r2=1050041&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
 Thu Dec 16 16:24:30 2010
@@ -35,8 +35,6 @@ public class FtpProducerFileExistOverrid
     @Before
     public void setUp() throws Exception {
         super.setUp();
-        deleteDirectory("target/exist");
-
         template.sendBodyAndHeader(getFtpUrl(), "Hello World", 
Exchange.FILE_NAME, "hello.txt");
     }
 

Copied: 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
 (from r1049805, 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java)
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java&r1=1049805&r2=1050041&rev=1050041&view=diff
==============================================================================
--- 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTest.java
 (original)
+++ 
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpProducerFileExistOverrideTwoUploadTest.java
 Thu Dec 16 16:24:30 2010
@@ -16,48 +16,47 @@
  */
 package org.apache.camel.component.file.remote;
 
+import java.io.File;
+
 import org.apache.camel.Exchange;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.junit.Before;
 import org.junit.Test;
 
 /**
  * @version $Revision$
  */
-public class FtpProducerFileExistOverrideTest extends FtpServerTestSupport {
-
-    private String getFtpUrl() {
-        return "ftp://ad...@localhost:"; + getPort() + 
"/exist?password=admin&delay=2000&noop=true&fileExist=Override";
-    }
+public class FtpProducerFileExistOverrideTwoUploadTest extends 
FtpServerTestSupport {
 
-    @Override
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        deleteDirectory("target/exist");
-
-        template.sendBodyAndHeader(getFtpUrl(), "Hello World", 
Exchange.FILE_NAME, "hello.txt");
+    protected String getFtpUrl() {
+        return "ftp://ad...@localhost:"; + getPort() + 
"/exist?password=admin&tempPrefix=upload-&fileExist=Override&disconnect=true";
     }
 
     @Test
     public void testOverride() throws Exception {
-        MockEndpoint mock = getMockEndpoint("mock:result");
-        mock.expectedBodiesReceived("Bye World");
-        mock.expectedFileExists(FTP_ROOT_DIR + "exist/hello.txt", "Bye World");
+        template.sendBodyAndHeader(getFtpUrl(), "Hello World", 
Exchange.FILE_NAME, "hello.txt");
+
+        // the 1st file should be stored
+        File file = new File(FTP_ROOT_DIR + 
"exist/hello.txt").getAbsoluteFile();
+        assertTrue(file.exists());
+
+        String body = context.getTypeConverter().convertTo(String.class, file);
+        assertEquals("Hello World", body);
+
+        // just wait a bit before upload 2nd file
+        Thread.sleep(1000);
 
         template.sendBodyAndHeader(getFtpUrl(), "Bye World", 
Exchange.FILE_NAME, "hello.txt");
 
-        assertMockEndpointsSatisfied();
+        // the 2nd file should also exists as we stored with override
+        file = new File(FTP_ROOT_DIR + "exist/hello.txt").getAbsoluteFile();
+        assertTrue(file.exists());
+
+        body = context.getTypeConverter().convertTo(String.class, file);
+        assertEquals("Bye World", body);
     }
 
     @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            @Override
-            public void configure() throws Exception {
-                from(getFtpUrl()).to("mock:result");
-            }
-        };
+    public boolean isUseRouteBuilder() {
+        return false;
     }
 }
\ No newline at end of file


Reply via email to