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 2010/05/11 11:17:05 UTC
svn commit: r943060 - in /camel/trunk:
camel-core/src/main/java/org/apache/camel/component/file/
camel-core/src/test/java/org/apache/camel/component/file/
camel-core/src/test/java/org/apache/camel/component/file/stress/
components/camel-ftp/src/test/ja...
Author: davsclaus
Date: Tue May 11 09:17:04 2010
New Revision: 943060
URL: http://svn.apache.org/viewvc?rev=943060&view=rev
Log:
CAMEL-2708: Applied patch with thanks to Gert V. Fixed async tests on other boxes.
Added:
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java (with props)
camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java
- copied, changed from r943033, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java
camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java
Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java?rev=943060&r1=943059&r2=943060&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java Tue May 11 09:17:04 2010
@@ -472,9 +472,9 @@ public abstract class GenericFileEndpoin
String name = file.isAbsolute() ? file.getAbsoluteFilePath() : file.getRelativeFilePath();
// skip leading endpoint configured directory
- String endpointPath = getConfiguration().getDirectory();
+ String endpointPath = getConfiguration().getDirectory() + getFileSeparator();
if (ObjectHelper.isNotEmpty(endpointPath) && name.startsWith(endpointPath)) {
- name = ObjectHelper.after(name, getConfiguration().getDirectory() + File.separator);
+ name = ObjectHelper.after(name, endpointPath);
}
// adjust filename
Added: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java?rev=943060&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java Tue May 11 09:17:04 2010
@@ -0,0 +1,61 @@
+/**
+ * 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 org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * @version $Revision$
+ */
+public class FileConsumerRelativeFileNameTest extends ContextTestSupport {
+
+ @Override
+ protected void setUp() throws Exception {
+ deleteDirectory("target/filename-consumer");
+ super.setUp();
+ // the file name is also starting with target/filename-consumer
+ template.sendBodyAndHeader("file:target/filename-consumer", "Hello World",
+ Exchange.FILE_NAME, "target/filename-consumer-hello.txt");
+ template.sendBodyAndHeader("file:target/filename-consumer", "Bye World",
+ Exchange.FILE_NAME, "target/filename-consumer-bye.txt");
+ }
+
+ public void testValidFilenameOnExchange() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ // should have file name header set
+ mock.allMessages().header(Exchange.FILE_NAME).isNotNull();
+ // and expect name to contain target/filename-consumer-XXX.txt
+ mock.message(0).header(Exchange.FILE_NAME).isEqualTo("target/filename-consumer-bye.txt");
+ mock.message(1).header(Exchange.FILE_NAME).isEqualTo("target/filename-consumer-hello.txt");
+
+ assertMockEndpointsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("file:target/filename-consumer?recursive=true&sortBy=file:name").to("mock:result");
+ }
+ };
+ }
+}
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerRelativeFileNameTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java?rev=943060&r1=943059&r2=943060&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockLockFileTest.java Tue May 11 09:17:04 2010
@@ -35,7 +35,7 @@ public class FileAsyncStressReadLockLock
// leverage the fact that we can limit to max 50 files per poll
// this will result in polling again and potentially picking up files
// that already are in progress
- from("file:target/filestress?maxMessagesPerPoll=50&readLock=lockFile")
+ from("file:target/filestress?maxMessagesPerPoll=50&readLock=lockFile").routeId("foo").noAutoStartup()
.threads(10)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java?rev=943060&r1=943059&r2=943060&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockNoneTest.java Tue May 11 09:17:04 2010
@@ -35,7 +35,7 @@ public class FileAsyncStressReadLockNone
// leverage the fact that we can limit to max 50 files per poll
// this will result in polling again and potentially picking up files
// that already are in progress
- from("file:target/filestress?maxMessagesPerPoll=50&readLock=none")
+ from("file:target/filestress?maxMessagesPerPoll=50&readLock=none").routeId("foo").noAutoStartup()
.threads(10)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java?rev=943060&r1=943059&r2=943060&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressReadLockRenameTest.java Tue May 11 09:17:04 2010
@@ -35,7 +35,7 @@ public class FileAsyncStressReadLockRena
// leverage the fact that we can limit to max 50 files per poll
// this will result in polling again and potentially picking up files
// that already are in progress
- from("file:target/filestress?maxMessagesPerPoll=50&readLock=rename")
+ from("file:target/filestress?maxMessagesPerPoll=50&readLock=rename").routeId("foo").noAutoStartup()
.threads(10)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java?rev=943060&r1=943059&r2=943060&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/file/stress/FileAsyncStressTest.java Tue May 11 09:17:04 2010
@@ -41,6 +41,9 @@ public class FileAsyncStressTest extends
}
public void testAsyncStress() throws Exception {
+ // start route when all the files have been written
+ context.startRoute("foo");
+
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(100);
mock.setResultWaitTime(20000);
@@ -56,7 +59,7 @@ public class FileAsyncStressTest extends
// leverage the fact that we can limit to max 50 files per poll
// this will result in polling again and potentially picking up files
// that already are in progress
- from("file:target/filestress?maxMessagesPerPoll=50")
+ from("file:target/filestress?maxMessagesPerPoll=50").routeId("foo").noAutoStartup()
.threads(10)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
Copied: camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java (from r943033, camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java?p2=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java&p1=camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java&r1=943033&r2=943060&rev=943060&view=diff
==============================================================================
--- camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerDisconnectTest.java (original)
+++ camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerRelativeFileNameTest.java Tue May 11 09:17:04 2010
@@ -16,19 +16,22 @@
*/
package org.apache.camel.component.file.remote;
+import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;
-public class FtpConsumerDisconnectTest extends FtpServerTestSupport {
+public class FtpConsumerRelativeFileNameTest extends FtpServerTestSupport {
private String getFtpUrl() {
- return "ftp://admin@localhost:" + getPort() + "/done?password=admin&disconnect=true&delay=5000";
+ return "ftp://admin@localhost:" + getPort() + "/target/filename-consumer?password=admin&recursive=true&sortBy=file:name";
}
@Override
public void setUp() throws Exception {
super.setUp();
- sendFile(getFtpUrl(), "Hello World", "claus.txt");
+ sendFile(getFtpUrl(), "Hello World", "target/filename-consumer-hello.txt");
+ sendFile(getFtpUrl(), "Bye World", "target/filename-consumer-bye.txt");
}
@Override
@@ -42,8 +45,15 @@ public class FtpConsumerDisconnectTest e
}
@Test
- public void testDisconnectOnDone() throws Exception {
- getMockEndpoint("mock:result").expectedMessageCount(1);
+ public void testValidFilenameOnExchange() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ // should have file name header set
+ mock.allMessages().header(Exchange.FILE_NAME).isNotNull();
+ // and expect name to contain target/filename-consumer-XXX.txt
+ mock.message(0).header(Exchange.FILE_NAME).isEqualTo("target/filename-consumer-bye.txt");
+ mock.message(1).header(Exchange.FILE_NAME).isEqualTo("target/filename-consumer-hello.txt");
+
assertMockEndpointsSatisfied();
// give time for ftp consumer to disconnect