You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/08/06 09:55:38 UTC
svn commit: r683151 - in /activemq/camel/trunk/components/camel-ftp/src:
main/java/org/apache/camel/component/file/remote/ test/data/ftpbinarytest/
test/java/org/apache/camel/component/file/remote/
Author: ningjiang
Date: Wed Aug 6 00:55:37 2008
New Revision: 683151
URL: http://svn.apache.org/viewvc?rev=683151&view=rev
Log:
Applied the svn properties on camel-ftp
Modified:
activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/data/ftpbinarytest/logo2.png (props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java (contents, props changed)
activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java (contents, props changed)
Modified: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java Wed Aug 6 00:55:37 2008
@@ -1,102 +1,102 @@
-/**
- * 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.io.IOException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.net.ftp.FTPClient;
-
-/**
- * Utility methods for FTP.
- */
-public final class FtpUtils {
- private static final transient Log LOG = LogFactory.getLog(FtpUtils.class);
-
- private FtpUtils() {
- }
-
- public static void connect(FTPClient client, RemoteFileConfiguration config) throws IOException {
- String host = config.getHost();
- int port = config.getPort();
- String username = config.getUsername();
-
- client.connect(host, port);
- if (username != null) {
- client.login(username, config.getPassword());
- } else {
- client.login("anonymous", null);
- }
- client.setFileType(config.isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
- }
-
- public static void disconnect(FTPClient client) throws IOException {
- if (client.isConnected()) {
- client.disconnect();
- }
- }
-
- public static FTPClient createNewFtpClient() {
- return new FTPClient();
- }
-
- public static boolean buildDirectory(FTPClient ftpClient, String dirName) throws IOException {
- String originalDirectory = ftpClient.printWorkingDirectory();
-
- boolean success = false;
- try {
- // maybe the full directory already exsits
- success = ftpClient.changeWorkingDirectory(dirName);
- if (!success) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Trying to build remote directory: " + dirName);
- }
- success = ftpClient.makeDirectory(dirName);
- if (!success) {
- // we are here if the server side doesn't create intermediate folders
- // so create the folder one by one
- buildDirectoryChunks(ftpClient, dirName);
- }
- }
- } finally {
- // change back to original directory
- ftpClient.changeWorkingDirectory(originalDirectory);
- }
-
- return success;
- }
-
- public static boolean buildDirectoryChunks(FTPClient ftpClient, String dirName) throws IOException {
- final StringBuilder sb = new StringBuilder(dirName.length());
- final String[] dirs = dirName.split("\\/");
-
- boolean success = false;
- for (String dir : dirs) {
- sb.append(dir).append('/');
- String directory = sb.toString();
- if (LOG.isTraceEnabled()) {
- LOG.trace("Trying to build remote directory: " + directory);
- }
-
- success = ftpClient.makeDirectory(directory);
- }
-
- return success;
- }
-
-}
+/**
+ * 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.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.net.ftp.FTPClient;
+
+/**
+ * Utility methods for FTP.
+ */
+public final class FtpUtils {
+ private static final transient Log LOG = LogFactory.getLog(FtpUtils.class);
+
+ private FtpUtils() {
+ }
+
+ public static void connect(FTPClient client, RemoteFileConfiguration config) throws IOException {
+ String host = config.getHost();
+ int port = config.getPort();
+ String username = config.getUsername();
+
+ client.connect(host, port);
+ if (username != null) {
+ client.login(username, config.getPassword());
+ } else {
+ client.login("anonymous", null);
+ }
+ client.setFileType(config.isBinary() ? FTPClient.BINARY_FILE_TYPE : FTPClient.ASCII_FILE_TYPE);
+ }
+
+ public static void disconnect(FTPClient client) throws IOException {
+ if (client.isConnected()) {
+ client.disconnect();
+ }
+ }
+
+ public static FTPClient createNewFtpClient() {
+ return new FTPClient();
+ }
+
+ public static boolean buildDirectory(FTPClient ftpClient, String dirName) throws IOException {
+ String originalDirectory = ftpClient.printWorkingDirectory();
+
+ boolean success = false;
+ try {
+ // maybe the full directory already exsits
+ success = ftpClient.changeWorkingDirectory(dirName);
+ if (!success) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Trying to build remote directory: " + dirName);
+ }
+ success = ftpClient.makeDirectory(dirName);
+ if (!success) {
+ // we are here if the server side doesn't create intermediate folders
+ // so create the folder one by one
+ buildDirectoryChunks(ftpClient, dirName);
+ }
+ }
+ } finally {
+ // change back to original directory
+ ftpClient.changeWorkingDirectory(originalDirectory);
+ }
+
+ return success;
+ }
+
+ public static boolean buildDirectoryChunks(FTPClient ftpClient, String dirName) throws IOException {
+ final StringBuilder sb = new StringBuilder(dirName.length());
+ final String[] dirs = dirName.split("\\/");
+
+ boolean success = false;
+ for (String dir : dirs) {
+ sb.append(dir).append('/');
+ String directory = sb.toString();
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Trying to build remote directory: " + directory);
+ }
+
+ success = ftpClient.makeDirectory(directory);
+ }
+
+ return success;
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpUtils.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/data/ftpbinarytest/logo2.png
------------------------------------------------------------------------------
--- svn:mime-type (original)
+++ svn:mime-type Wed Aug 6 00:55:37 2008
@@ -1 +1 @@
-application/octet-stream
+image/png
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java Wed Aug 6 00:55:37 2008
@@ -1,85 +1,85 @@
-/**
- * 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.io.File;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test to test consumer.deleteFile option.
- */
-public class FromFtpDeleteFileTest extends FtpServerTestSupport {
-
- private String port = "20022";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/deletefile?password=admin&binary=false&consumer.deleteFile=true";
-
- public String getPort() {
- return port;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- prepareFtpServer();
- }
-
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want to unit
- // test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint(ftpUrl);
- Exchange exchange = endpoint.createExchange();
- exchange.getIn().setBody("Hello World this file will be deleted");
- exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
- Producer producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
-
- // assert file is created
- File file = new File("./res/home/deletefile/hello.txt");
- file = file.getAbsoluteFile();
- assertTrue("The file should exists", file.exists());
- }
-
- public void testPollFileAndShouldBeDeleted() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Hello World this file will be deleted");
-
- mock.assertIsSatisfied();
-
- // assert the file is deleted
- File file = new File("./res/home/deletefile/hello.txt");
- file = file.getAbsoluteFile();
- assertFalse("The file should have been deleted", file.exists());
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
-}
+/**
+ * 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.io.File;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to test consumer.deleteFile option.
+ */
+public class FromFtpDeleteFileTest extends FtpServerTestSupport {
+
+ private String port = "20022";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/deletefile?password=admin&binary=false&consumer.deleteFile=true";
+
+ public String getPort() {
+ return port;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ prepareFtpServer();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want to unit
+ // test that we can pool and store as a local file
+ Endpoint endpoint = context.getEndpoint(ftpUrl);
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World this file will be deleted");
+ exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
+
+ // assert file is created
+ File file = new File("./res/home/deletefile/hello.txt");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should exists", file.exists());
+ }
+
+ public void testPollFileAndShouldBeDeleted() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World this file will be deleted");
+
+ mock.assertIsSatisfied();
+
+ // assert the file is deleted
+ File file = new File("./res/home/deletefile/hello.txt");
+ file = file.getAbsoluteFile();
+ assertFalse("The file should have been deleted", file.exists());
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpDeleteFileTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java Wed Aug 6 00:55:37 2008
@@ -1,80 +1,80 @@
-/**
- * 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.io.File;
-import java.io.FileOutputStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Unit test to verify exclusive read - that we do not poll files that is in progress of being written.
- */
-public class FromFtpExclusiveReadTest extends FtpServerTestSupport {
-
- private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
-
- private String port = "20090";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=true&consumer.delay=500";
-
- public String getPort() {
- return port;
- }
-
- // TODO: Not possible to test in single JVM
- public void testPollFileWhileSlowFileIsBeingWritten() throws Exception {
- /*deleteDirectory("./res/home");
- createDirectory("./res/home/slowfile");
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Hello WorldLine #0Line #1Line #2Bye World");
-
- createSlowFile();
-
- mock.assertIsSatisfied();*/
- }
-
- private void createSlowFile() throws Exception {
- LOG.info("Creating a slow file ...");
- File file = new File("./res/home/slowfile/hello.txt");
- FileOutputStream fos = new FileOutputStream(file);
- fos.write("Hello World".getBytes());
- for (int i = 0; i < 3; i++) {
- Thread.sleep(1000);
- fos.write(("Line #" + i).getBytes());
- LOG.info("Appending to slowfile");
- }
- fos.write("Bye World".getBytes());
- fos.close();
- LOG.info("... done creating slowfile");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
- private static void createDirectory(String s) {
- File file = new File(s);
- file.mkdirs();
- }
-}
+/**
+ * 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.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Unit test to verify exclusive read - that we do not poll files that is in progress of being written.
+ */
+public class FromFtpExclusiveReadTest extends FtpServerTestSupport {
+
+ private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
+
+ private String port = "20090";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=true&consumer.delay=500";
+
+ public String getPort() {
+ return port;
+ }
+
+ // TODO: Not possible to test in single JVM
+ public void testPollFileWhileSlowFileIsBeingWritten() throws Exception {
+ /*deleteDirectory("./res/home");
+ createDirectory("./res/home/slowfile");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello WorldLine #0Line #1Line #2Bye World");
+
+ createSlowFile();
+
+ mock.assertIsSatisfied();*/
+ }
+
+ private void createSlowFile() throws Exception {
+ LOG.info("Creating a slow file ...");
+ File file = new File("./res/home/slowfile/hello.txt");
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write("Hello World".getBytes());
+ for (int i = 0; i < 3; i++) {
+ Thread.sleep(1000);
+ fos.write(("Line #" + i).getBytes());
+ LOG.info("Appending to slowfile");
+ }
+ fos.write("Bye World".getBytes());
+ fos.close();
+ LOG.info("... done creating slowfile");
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
+ private static void createDirectory(String s) {
+ File file = new File(s);
+ file.mkdirs();
+ }
+}
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpExclusiveReadTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java Wed Aug 6 00:55:37 2008
@@ -1,87 +1,87 @@
-/**
- * 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.io.File;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test to test consumer.moveNamePostfix option.
- */
-public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
-
- private String port = "20031";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
- + "&consumer.moveNamePostfix=.old";
-
- public String getPort() {
- return port;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- deleteDirectory("./res/home/movefile");
- prepareFtpServer();
- }
-
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want to unit
- // test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint(ftpUrl);
- Exchange exchange = endpoint.createExchange();
- exchange.getIn().setBody("Hello World this file will be moved");
- exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
- Producer producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
-
- // assert file is created
- File file = new File("./res/home/movefile/hello.txt");
- file = file.getAbsoluteFile();
- assertTrue("The file should exists", file.exists());
- }
-
- public void testPollFileAndShouldBeMoved() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Hello World this file will be moved");
-
- mock.assertIsSatisfied();
-
- // assert the file is deleted
- File file = new File("./res/home/movefile/hello.txt.old");
- file = file.getAbsoluteFile();
- assertTrue("The file should have been moved", file.exists());
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
+/**
+ * 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.io.File;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to test consumer.moveNamePostfix option.
+ */
+public class FromFtpMoveFilePostfixTest extends FtpServerTestSupport {
+
+ private String port = "20031";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
+ + "&consumer.moveNamePostfix=.old";
+
+ public String getPort() {
+ return port;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deleteDirectory("./res/home/movefile");
+ prepareFtpServer();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want to unit
+ // test that we can pool and store as a local file
+ Endpoint endpoint = context.getEndpoint(ftpUrl);
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World this file will be moved");
+ exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
+
+ // assert file is created
+ File file = new File("./res/home/movefile/hello.txt");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should exists", file.exists());
+ }
+
+ public void testPollFileAndShouldBeMoved() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World this file will be moved");
+
+ mock.assertIsSatisfied();
+
+ // assert the file is deleted
+ File file = new File("./res/home/movefile/hello.txt.old");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should have been moved", file.exists());
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePostfixTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java Wed Aug 6 00:55:37 2008
@@ -1,87 +1,87 @@
-/**
- * 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.io.File;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test to test consumer.moveNamePrefix option.
- */
-public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
-
- private String port = "20030";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
- + "&consumer.moveNamePrefix=done/";
-
- public String getPort() {
- return port;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- deleteDirectory("./res/home/movefile");
- prepareFtpServer();
- }
-
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want to unit
- // test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint(ftpUrl);
- Exchange exchange = endpoint.createExchange();
- exchange.getIn().setBody("Hello World this file will be moved");
- exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
- Producer producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
-
- // assert file is created
- File file = new File("./res/home/movefile/hello.txt");
- file = file.getAbsoluteFile();
- assertTrue("The file should exists", file.exists());
- }
-
- public void testPollFileAndShouldBeMoved() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Hello World this file will be moved");
-
- mock.assertIsSatisfied();
-
- // assert the file is deleted
- File file = new File("./res/home/movefile/done/hello.txt");
- file = file.getAbsoluteFile();
- assertTrue("The file should have been moved", file.exists());
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
+/**
+ * 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.io.File;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to test consumer.moveNamePrefix option.
+ */
+public class FromFtpMoveFilePrefixTest extends FtpServerTestSupport {
+
+ private String port = "20030";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
+ + "&consumer.moveNamePrefix=done/";
+
+ public String getPort() {
+ return port;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deleteDirectory("./res/home/movefile");
+ prepareFtpServer();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want to unit
+ // test that we can pool and store as a local file
+ Endpoint endpoint = context.getEndpoint(ftpUrl);
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World this file will be moved");
+ exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
+
+ // assert file is created
+ File file = new File("./res/home/movefile/hello.txt");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should exists", file.exists());
+ }
+
+ public void testPollFileAndShouldBeMoved() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World this file will be moved");
+
+ mock.assertIsSatisfied();
+
+ // assert the file is deleted
+ File file = new File("./res/home/movefile/done/hello.txt");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should have been moved", file.exists());
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFilePrefixTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java Wed Aug 6 00:55:37 2008
@@ -1,87 +1,87 @@
-/**
- * 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.io.File;
-
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test to test both consumer.moveNamePrefix and consumer.moveNamePostfix options.
- */
-public class FromFtpMoveFileTest extends FtpServerTestSupport {
-
- private String port = "20032";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
- + "&consumer.moveNamePrefix=done/sub2/&consumer.moveNamePostfix=.old";
-
- public String getPort() {
- return port;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- deleteDirectory("./res/home/movefile");
- prepareFtpServer();
- }
-
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating a file on the server that we want to unit
- // test that we can pool and store as a local file
- Endpoint endpoint = context.getEndpoint(ftpUrl);
- Exchange exchange = endpoint.createExchange();
- exchange.getIn().setBody("Hello World this file will be moved");
- exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
- Producer producer = endpoint.createProducer();
- producer.start();
- producer.process(exchange);
- producer.stop();
-
- // assert file is created
- File file = new File("./res/home/movefile/hello.txt");
- file = file.getAbsoluteFile();
- assertTrue("The file should exists", file.exists());
- }
-
- public void testPollFileAndShouldBeMoved() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
- mock.expectedBodiesReceived("Hello World this file will be moved");
-
- mock.assertIsSatisfied();
-
- // assert the file is deleted
- File file = new File("./res/home/movefile/done/sub2/hello.txt.old");
- file = file.getAbsoluteFile();
- assertTrue("The file should have been moved", file.exists());
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
+/**
+ * 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.io.File;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test to test both consumer.moveNamePrefix and consumer.moveNamePostfix options.
+ */
+public class FromFtpMoveFileTest extends FtpServerTestSupport {
+
+ private String port = "20032";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/movefile?password=admin&binary=false"
+ + "&consumer.moveNamePrefix=done/sub2/&consumer.moveNamePostfix=.old";
+
+ public String getPort() {
+ return port;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ deleteDirectory("./res/home/movefile");
+ prepareFtpServer();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating a file on the server that we want to unit
+ // test that we can pool and store as a local file
+ Endpoint endpoint = context.getEndpoint(ftpUrl);
+ Exchange exchange = endpoint.createExchange();
+ exchange.getIn().setBody("Hello World this file will be moved");
+ exchange.getIn().setHeader(FileComponent.HEADER_FILE_NAME, "hello.txt");
+ Producer producer = endpoint.createProducer();
+ producer.start();
+ producer.process(exchange);
+ producer.stop();
+
+ // assert file is created
+ File file = new File("./res/home/movefile/hello.txt");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should exists", file.exists());
+ }
+
+ public void testPollFileAndShouldBeMoved() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+ mock.expectedBodiesReceived("Hello World this file will be moved");
+
+ mock.assertIsSatisfied();
+
+ // assert the file is deleted
+ File file = new File("./res/home/movefile/done/sub2/hello.txt.old");
+ file = file.getAbsoluteFile();
+ assertTrue("The file should have been moved", file.exists());
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpMoveFileTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java Wed Aug 6 00:55:37 2008
@@ -1,64 +1,64 @@
-/**
- * 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.io.File;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Unit test to verify polling a server with no files to poll.
- */
-public class FromFtpNoFilesTest extends FtpServerTestSupport {
-
- private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
-
- private String port = "20020";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&binary=false&consumer.exclusiveReadLock=true&consumer.delay=500";
-
- public String getPort() {
- return port;
- }
-
- public void testPoolIn3SecondsButNoFiles() throws Exception {
- deleteDirectory("./res/home");
- createDirectory("./res/home/slowfile");
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(0);
-
- Thread.sleep(3 * 1000L);
-
- mock.assertIsSatisfied();
- }
-
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
- private static void createDirectory(String s) {
- File file = new File(s);
- file.mkdirs();
- }
+/**
+ * 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.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Unit test to verify polling a server with no files to poll.
+ */
+public class FromFtpNoFilesTest extends FtpServerTestSupport {
+
+ private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
+
+ private String port = "20020";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&binary=false&consumer.exclusiveReadLock=true&consumer.delay=500";
+
+ public String getPort() {
+ return port;
+ }
+
+ public void testPoolIn3SecondsButNoFiles() throws Exception {
+ deleteDirectory("./res/home");
+ createDirectory("./res/home/slowfile");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(0);
+
+ Thread.sleep(3 * 1000L);
+
+ mock.assertIsSatisfied();
+ }
+
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
+ private static void createDirectory(String s) {
+ File file = new File(s);
+ file.mkdirs();
+ }
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNoFilesTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java Wed Aug 6 00:55:37 2008
@@ -1,84 +1,84 @@
-/**
- * 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.io.File;
-import java.io.FileOutputStream;
-
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Unit test to verify *NON* exclusive read.
- */
-public class FromFtpNonExclusiveReadTest extends FtpServerTestSupport {
-
- private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
-
- private String port = "20027";
- private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=false&consumer.delay=500";
-
- public String getPort() {
- return port;
- }
-
- public void testPollFileWhileSlowFileIsBeingWrittenUsingNonExclusiveRead() throws Exception {
- deleteDirectory("./res/home");
- createDirectory("./res/home/slowfile");
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(1);
-
- createSlowFile();
-
- mock.assertIsSatisfied();
-
- // we read only part of the file as we dont have exclusive read and thus read part of the
- // file currently in progress of being written - so we get only the Hello World part
- String body = mock.getExchanges().get(0).getIn().getBody(String.class);
- assertFalse("Should not get the entire file", body.endsWith("Bye World"));
- }
-
- private void createSlowFile() throws Exception {
- LOG.info("Creating a slow file ...");
- File file = new File("./res/home/slowfile/hello.txt");
- FileOutputStream fos = new FileOutputStream(file);
- fos.write("Hello World".getBytes());
- for (int i = 0; i < 3; i++) {
- Thread.sleep(1000);
- fos.write(("Line #" + i).getBytes());
- LOG.info("Appending to slowfile");
- }
- fos.write("Bye World".getBytes());
- fos.close();
- LOG.info("... done creating slowfile");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
- private static void createDirectory(String s) {
- File file = new File(s);
- file.mkdirs();
- }
+/**
+ * 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.io.File;
+import java.io.FileOutputStream;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Unit test to verify *NON* exclusive read.
+ */
+public class FromFtpNonExclusiveReadTest extends FtpServerTestSupport {
+
+ private static final Log LOG = LogFactory.getLog(FromFtpExclusiveReadTest.class);
+
+ private String port = "20027";
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/slowfile?password=admin&consumer.exclusiveReadLock=false&consumer.delay=500";
+
+ public String getPort() {
+ return port;
+ }
+
+ public void testPollFileWhileSlowFileIsBeingWrittenUsingNonExclusiveRead() throws Exception {
+ deleteDirectory("./res/home");
+ createDirectory("./res/home/slowfile");
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
+ createSlowFile();
+
+ mock.assertIsSatisfied();
+
+ // we read only part of the file as we dont have exclusive read and thus read part of the
+ // file currently in progress of being written - so we get only the Hello World part
+ String body = mock.getExchanges().get(0).getIn().getBody(String.class);
+ assertFalse("Should not get the entire file", body.endsWith("Bye World"));
+ }
+
+ private void createSlowFile() throws Exception {
+ LOG.info("Creating a slow file ...");
+ File file = new File("./res/home/slowfile/hello.txt");
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write("Hello World".getBytes());
+ for (int i = 0; i < 3; i++) {
+ Thread.sleep(1000);
+ fos.write(("Line #" + i).getBytes());
+ LOG.info("Appending to slowfile");
+ }
+ fos.write("Bye World".getBytes());
+ fos.close();
+ LOG.info("... done creating slowfile");
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
+ private static void createDirectory(String s) {
+ File file = new File(s);
+ file.mkdirs();
+ }
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FromFtpNonExclusiveReadTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java?rev=683151&r1=683150&r2=683151&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java (original)
+++ activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java Wed Aug 6 00:55:37 2008
@@ -1,68 +1,68 @@
-/**
- * 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 org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.file.FileComponent;
-import org.apache.camel.component.mock.MockEndpoint;
-
-/**
- * Unit test that ftp consumer will exclude pre and postfixes
- */
-public class FtpConsumerExcludeNameTest extends FtpServerTestSupport {
-
- private String port = "20095";
-
- private String ftpUrl = "ftp://admin@localhost:" + port + "/excludename?password=admin"
- + "&consumer.excludedNamePrefix=secret&consumer.excludedNamePostfix=xml";
-
- public void testExludePreAndPostfixes() throws Exception {
- MockEndpoint mock = getMockEndpoint("mock:result");
- mock.expectedMessageCount(2);
- mock.expectedBodiesReceived("Report 1", "Report 2");
- mock.assertIsSatisfied();
- }
-
- public String getPort() {
- return port;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- prepareFtpServer();
- }
-
- private void prepareFtpServer() throws Exception {
- // prepares the FTP Server by creating files on the server that we want to unit
- // test that we can pool and store as a local file
- String ftpUrl = "ftp://admin@localhost:" + port + "/excludename/?password=admin";
- template.sendBodyAndHeader(ftpUrl, "Hello World", FileComponent.HEADER_FILE_NAME, "hello.xml");
- template.sendBodyAndHeader(ftpUrl, "Report 1", FileComponent.HEADER_FILE_NAME, "report1.txt");
- template.sendBodyAndHeader(ftpUrl, "Bye World", FileComponent.HEADER_FILE_NAME, "secret.txt");
- template.sendBodyAndHeader(ftpUrl, "Report 2", FileComponent.HEADER_FILE_NAME, "report2.txt");
- }
-
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- public void configure() throws Exception {
- from(ftpUrl).to("mock:result");
- }
- };
- }
-
+/**
+ * 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 org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.file.FileComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+
+/**
+ * Unit test that ftp consumer will exclude pre and postfixes
+ */
+public class FtpConsumerExcludeNameTest extends FtpServerTestSupport {
+
+ private String port = "20095";
+
+ private String ftpUrl = "ftp://admin@localhost:" + port + "/excludename?password=admin"
+ + "&consumer.excludedNamePrefix=secret&consumer.excludedNamePostfix=xml";
+
+ public void testExludePreAndPostfixes() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(2);
+ mock.expectedBodiesReceived("Report 1", "Report 2");
+ mock.assertIsSatisfied();
+ }
+
+ public String getPort() {
+ return port;
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ prepareFtpServer();
+ }
+
+ private void prepareFtpServer() throws Exception {
+ // prepares the FTP Server by creating files on the server that we want to unit
+ // test that we can pool and store as a local file
+ String ftpUrl = "ftp://admin@localhost:" + port + "/excludename/?password=admin";
+ template.sendBodyAndHeader(ftpUrl, "Hello World", FileComponent.HEADER_FILE_NAME, "hello.xml");
+ template.sendBodyAndHeader(ftpUrl, "Report 1", FileComponent.HEADER_FILE_NAME, "report1.txt");
+ template.sendBodyAndHeader(ftpUrl, "Bye World", FileComponent.HEADER_FILE_NAME, "secret.txt");
+ template.sendBodyAndHeader(ftpUrl, "Report 2", FileComponent.HEADER_FILE_NAME, "report2.txt");
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() throws Exception {
+ from(ftpUrl).to("mock:result");
+ }
+ };
+ }
+
}
\ No newline at end of file
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-ftp/src/test/java/org/apache/camel/component/file/remote/FtpConsumerExcludeNameTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date