Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 471DB10C27 for ; Thu, 22 Aug 2013 14:09:33 +0000 (UTC) Received: (qmail 49641 invoked by uid 500); 22 Aug 2013 14:09:33 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 49563 invoked by uid 500); 22 Aug 2013 14:09:32 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 49551 invoked by uid 99); 22 Aug 2013 14:09:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Aug 2013 14:09:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5D2D98C2BFD; Thu, 22 Aug 2013 14:09:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davsclaus@apache.org To: commits@camel.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: CAMEL-6574: Added unit test Date: Thu, 22 Aug 2013 14:09:31 +0000 (UTC) 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 Authored: Thu Aug 22 16:04:32 2013 +0200 Committer: Claus Ibsen 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"); + } + }; + } + +}