camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [4/8] git commit: Fixed test on CI servers
Date Mon, 07 Oct 2013 07:16:57 GMT
Fixed test on CI servers


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d7653ff3
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d7653ff3
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d7653ff3

Branch: refs/heads/master
Commit: d7653ff3ac56622b40ee6990b0ad349a140dfd1e
Parents: 90073a2
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Oct 7 09:15:56 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Oct 7 09:15:56 2013 +0200

----------------------------------------------------------------------
 .../component/jsch/ScpServerTestSupport.java    |  6 +--
 .../component/jsch/ScpSimpleProduceTest.java    | 55 +++++++++-----------
 2 files changed, 29 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d7653ff3/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
index f31dfa7..c207742 100644
--- a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
+++ b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpServerTestSupport.java
@@ -86,8 +86,8 @@ public abstract class ScpServerTestSupport extends CamelTestSupport {
     @Override
     @Before
     public void setUp() throws Exception {
-        File root = new File(getScpPath());
-        root.mkdirs(); // implicitly create sshd home dir
+        deleteDirectory(getScpPath());
+        createDirectory(getScpPath());
 
         setupComplete = startSshd();
         setupKnownHosts();
@@ -109,6 +109,7 @@ public abstract class ScpServerTestSupport extends CamelTestSupport {
             }
         }
         FileUtil.deleteFile(new File(knownHostsFile));
+        deleteDirectory(getScpPath());
     }
 
     protected final String getScpPath() {
@@ -121,7 +122,6 @@ public abstract class ScpServerTestSupport extends CamelTestSupport {
         return "scp://localhost:" + getPort() + "/" + getScpPath();
     }
 
-
     @SuppressWarnings("unchecked")
     protected boolean startSshd() {
         sshd = SshServer.setUpDefaultServer();

http://git-wip-us.apache.org/repos/asf/camel/blob/d7653ff3/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
index 524ca8e..27c58e5 100644
--- a/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
+++ b/components/camel-jsch/src/test/java/org/apache/camel/component/jsch/ScpSimpleProduceTest.java
@@ -16,72 +16,72 @@
  */
 package org.apache.camel.component.jsch;
 
-import java.io.File;
-
 import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
 import org.junit.Assume;
 import org.junit.Ignore;
 import org.junit.Test;
 
 public class ScpSimpleProduceTest extends ScpServerTestSupport {
-    
+
     @Override
-    public boolean isUseRouteBuilder() {
-        return false;
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("file:" + getScpPath() + "?recursive=true&delete=true")
+                    .convertBodyTo(String.class)
+                    .to("mock:result");
+            }
+        };
     }
 
     @Test
     public void testScpSimpleProduce() throws Exception {
         Assume.assumeTrue(this.isSetupComplete());
 
+        getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
+
         String uri = getScpUri() + "?username=admin&password=admin&knownHostsFile="
+ getKnownHostsFile();
         template.sendBodyAndHeader(uri, "Hello World", Exchange.FILE_NAME, "hello.txt");
-        Thread.sleep(1000);
 
-        File file = new File(getScpPath() + "/hello.txt");
-        assertFileExists(file.getAbsolutePath());
-        assertEquals("Hello World", context.getTypeConverter().convertTo(String.class, file));
+        assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testScpSimpleSubPathProduce() throws Exception {
         Assume.assumeTrue(this.isSetupComplete());
 
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
+
         String uri = getScpUri() + "?username=admin&password=admin&knownHostsFile="
+ getKnownHostsFile();
         template.sendBodyAndHeader(uri, "Bye World", Exchange.FILE_NAME, "mysub/bye.txt");
-        Thread.sleep(1000);
 
-        File file = new File(getScpPath() + "/mysub/bye.txt");
-        assertFileExists(file.getAbsolutePath());
-        assertEquals("Bye World", context.getTypeConverter().convertTo(String.class, file));
+        assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testScpSimpleTwoSubPathProduce() throws Exception {
         Assume.assumeTrue(this.isSetupComplete());
 
+        getMockEndpoint("mock:result").expectedBodiesReceived("Farewell World");
+
         String uri = getScpUri() + "?username=admin&password=admin&knownHostsFile="
+ getKnownHostsFile();
         template.sendBodyAndHeader(uri, "Farewell World", Exchange.FILE_NAME, "mysub/mysubsub/farewell.txt");
-        Thread.sleep(1000);
 
-        File file = new File(getScpPath() + "/mysub/mysubsub/farewell.txt");
-        assertFileExists(file.getAbsolutePath());
-        assertEquals("Farewell World", context.getTypeConverter().convertTo(String.class,
file));
+        assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testScpProduceChmod() throws Exception {
         Assume.assumeTrue(this.isSetupComplete());
 
+        getMockEndpoint("mock:result").expectedBodiesReceived("Bonjour Monde");
+
         String uri = getScpUri() + "?username=admin&password=admin&chmod=640&knownHostsFile="
+ getKnownHostsFile();
         template.sendBodyAndHeader(uri, "Bonjour Monde", Exchange.FILE_NAME, "monde.txt");
-        Thread.sleep(1000);
 
-        File file = new File(getScpPath() + "/monde.txt");
-        assertFileExists(file.getAbsolutePath());
-        // Mina sshd we use for testing ignores file perms;
-        // assertFalse("File should not have execute rights: " + file, file.canExecute());
-        assertEquals("Bonjour Monde", context.getTypeConverter().convertTo(String.class,
file));
+        assertMockEndpointsSatisfied();
     }
 
     @Test
@@ -89,14 +89,11 @@ public class ScpSimpleProduceTest extends ScpServerTestSupport {
     public void testScpProducePrivateKey() throws Exception {
         Assume.assumeTrue(this.isSetupComplete());
 
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
         String uri = getScpUri() + "?username=admin&privateKeyFile=src/test/resources/camel-key.priv&privateKeyFilePassphrase=password&knownHostsFile="
+ getKnownHostsFile();
         template.sendBodyAndHeader(uri, "Hallo Welt", Exchange.FILE_NAME, "welt.txt");
-        Thread.sleep(1000);
 
-        File file = new File(getScpPath() + "/welt.txt");
-        assertFileExists(file.getAbsolutePath());
-        // Mina sshd we use for testing ignores file perms;
-        // assertFalse("File should not have execute rights: " + file, file.canExecute());
-        assertEquals("Hallo Welt", context.getTypeConverter().convertTo(String.class, file));
+        assertMockEndpointsSatisfied();
     }
 }


Mime
View raw message