camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject git commit: CAMEL-6574: Added unit test
Date Thu, 22 Aug 2013 14:09:31 GMT
Updated Branches:
  refs/heads/master d23719f39 -> d8c482277


CAMEL-6574: Added unit test


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

Branch: refs/heads/master
Commit: d8c4822775a043869754dba90279ab21cfe5fa7d
Parents: d23719f
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu Aug 22 16:04:32 2013 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu Aug 22 16:09:20 2013 +0200

----------------------------------------------------------------------
 ...leConsumerIdempotentKeyChangedIssueTest.java | 60 +++++++++++++++++
 ...tpConsumerIdempotentKeyChangedIssueTest.java | 69 ++++++++++++++++++++
 2 files changed, 129 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d8c48227/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssueTest.java
b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssueTest.java
new file mode 100644
index 0000000..9430df1
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerIdempotentKeyChangedIssueTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+
+public class FileConsumerIdempotentKeyChangedIssueTest extends ContextTestSupport {
+
+    private Endpoint endpoint;
+
+    public void testFile() throws Exception {
+        getMockEndpoint("mock:file").expectedBodiesReceived("Hello World");
+
+        template.sendBodyAndHeader(endpoint, "Hello World", Exchange.FILE_NAME, "hello.txt");
+        assertMockEndpointsSatisfied();
+        oneExchangeDone.matches(5, TimeUnit.SECONDS);
+
+        resetMocks();
+        getMockEndpoint("mock:file").expectedBodiesReceived("Hello World Again");
+
+        template.sendBodyAndHeader(endpoint, "Hello World Again", Exchange.FILE_NAME, "hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                endpoint = endpoint("file:target/changed?noop=true&readLock=changed"
+                        + "&idempotentKey=${file:onlyname}-${file:size}-${date:file:yyyyMMddHHmmss}");
+
+                from(endpoint)
+                    .convertBodyTo(String.class)
+                    .to("log:file")
+                    .to("mock:file");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/d8c48227/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
----------------------------------------------------------------------
diff --git a/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
new file mode 100644
index 0000000..58e7f64
--- /dev/null
+++ b/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerIdempotentKeyChangedIssueTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.NotifyBuilder;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.Test;
+
+public class FtpConsumerIdempotentKeyChangedIssueTest extends FtpServerTestSupport {
+
+    private String getFtpUrl() {
+        return "ftp://admin@localhost:" + getPort() + "/idempotent?password=admin&readLock=changed"
+                + "&idempotentKey=${file:onlyname}-${file:size}-${date:file:yyyyMMddHHmmss}";
+    }
+
+    private Endpoint endpoint;
+
+    @Test
+    public void testIdempotent() throws Exception {
+        NotifyBuilder oneExchangeDone = new NotifyBuilder(context).whenDone(1).create();
+
+        getMockEndpoint("mock:file").expectedBodiesReceived("Hello World");
+
+        template.sendBodyAndHeader(endpoint, "Hello World", Exchange.FILE_NAME, "hello.txt");
+        assertMockEndpointsSatisfied();
+
+        oneExchangeDone.matches(5, TimeUnit.SECONDS);
+
+        resetMocks();
+        getMockEndpoint("mock:file").expectedBodiesReceived("Hello World Again");
+
+        template.sendBodyAndHeader(endpoint, "Hello World Again", Exchange.FILE_NAME, "hello.txt");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                endpoint = endpoint(getFtpUrl());
+
+                from(endpoint)
+                        .convertBodyTo(String.class)
+                        .to("log:file")
+                        .to("mock:file");
+            }
+        };
+    }
+
+}


Mime
View raw message