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 2011/12/30 09:16:57 UTC
svn commit: r1225769 - in /camel/trunk/tests/camel-itest/src/test:
java/org/apache/camel/itest/ftp/ resources/org/apache/camel/itest/ftp/
Author: ningjiang
Date: Fri Dec 30 08:16:56 2011
New Revision: 1225769
URL: http://svn.apache.org/viewvc?rev=1225769&view=rev
Log:
CAMEL-4837 use dynamic port number with ftp itest
Modified:
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpXQueryTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest.java
camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFtpEndpointTest.java
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest-context.xml
camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFtpEndpointTest-context.xml
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpAndHttpRecipientListInterceptSendToEndpointIssueTest.java Fri Dec 30 08:16:56 2011
@@ -19,6 +19,7 @@ package org.apache.camel.itest.ftp;
import java.io.File;
import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
@@ -27,18 +28,28 @@ import org.apache.ftpserver.ftplet.UserM
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
import org.apache.ftpserver.usermanager.impl.PropertiesUserManager;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
*
*/
public class FtpAndHttpRecipientListInterceptSendToEndpointIssueTest extends CamelTestSupport {
+ protected static int ftpPort;
+ protected static int httpPort;
protected FtpServer ftpServer;
+
+
+ @BeforeClass
+ public static void initPort() throws Exception {
+ ftpPort = AvailablePortFinder.getNextAvailable(20126);
+ httpPort = AvailablePortFinder.getNextAvailable(9193);
+ }
@Test
public void testFtpAndHttpIssue() throws Exception {
- String ftp = "ftp:localhost:20126/myapp?password=admin&username=admin";
- String http = "http://localhost:9193/myapp";
+ String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
+ String http = "http://localhost:" + httpPort + "/myapp";
getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
getMockEndpoint("mock:foo").expectedBodiesReceived("Hello World");
@@ -61,7 +72,7 @@ public class FtpAndHttpRecipientListInte
.recipientList(header("foo"))
.to("mock:result");
- from("jetty:http://0.0.0.0:9193/myapp")
+ from("jetty:http://0.0.0.0:" + httpPort + "/myapp")
.transform().constant("Bye World");
from("seda:foo").to("mock:foo");
@@ -94,7 +105,7 @@ public class FtpAndHttpRecipientListInte
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
- factory.setPort(20126);
+ factory.setPort(ftpPort);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpXQueryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpXQueryTest.java?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpXQueryTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/FtpXQueryTest.java Fri Dec 30 08:16:56 2011
@@ -21,6 +21,7 @@ import java.io.File;
import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
@@ -29,14 +30,21 @@ import org.apache.ftpserver.ftplet.UserM
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
import org.apache.ftpserver.usermanager.impl.PropertiesUserManager;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
*
*/
public class FtpXQueryTest extends CamelTestSupport {
+ protected static int ftpPort;
protected FtpServer ftpServer;
- private String ftp = "ftp:localhost:20127/myapp?password=admin&username=admin";
+ private String ftp = "ftp:localhost:" + ftpPort + "/myapp?password=admin&username=admin";
+
+ @BeforeClass
+ public static void initPort() throws Exception {
+ ftpPort = AvailablePortFinder.getNextAvailable(20127);
+ }
@Test
public void testXQueryFromFtp() throws Exception {
@@ -97,7 +105,7 @@ public class FtpXQueryTest extends Camel
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
- factory.setPort(20127);
+ factory.setPort(ftpPort);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest.java?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest.java Fri Dec 30 08:16:56 2011
@@ -23,6 +23,7 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory;
@@ -43,6 +44,14 @@ import org.springframework.test.context.
*/
@ContextConfiguration
public class SpringFileAntPathMatcherRemoteFileFilterTest extends AbstractJUnit4SpringContextTests {
+
+ private static int ftpPort = AvailablePortFinder.getNextAvailable(20123);
+ static {
+ //set them as system properties so Spring can use the property placeholder
+ //things to set them into the URL's in the spring contexts
+ System.setProperty("SpringFileAntPathMatcherRemoteFileFilterTest.ftpPort", Integer.toString(ftpPort));
+ }
+
protected FtpServer ftpServer;
protected String expectedBody = "Godday World";
@@ -91,7 +100,7 @@ public class SpringFileAntPathMatcherRem
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
- factory.setPort(20123);
+ factory.setPort(ftpPort);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
Modified: camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFtpEndpointTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFtpEndpointTest.java?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFtpEndpointTest.java (original)
+++ camel/trunk/tests/camel-itest/src/test/java/org/apache/camel/itest/ftp/SpringFtpEndpointTest.java Fri Dec 30 08:16:56 2011
@@ -23,6 +23,7 @@ import org.apache.camel.EndpointInject;
import org.apache.camel.Exchange;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.AvailablePortFinder;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.filesystem.nativefs.NativeFileSystemFactory;
@@ -42,6 +43,12 @@ import org.springframework.test.context.
*/
@ContextConfiguration
public class SpringFtpEndpointTest extends AbstractJUnit4SpringContextTests {
+ private static int ftpPort = AvailablePortFinder.getNextAvailable(20125);
+ static {
+ //set them as system properties so Spring can use the property placeholder
+ //things to set them into the URL's in the spring contexts
+ System.setProperty("SpringFtpEndpointTest.ftpPort", Integer.toString(ftpPort));
+ }
protected FtpServer ftpServer;
@Autowired
@@ -87,7 +94,7 @@ public class SpringFtpEndpointTest exten
serverFactory.setFileSystem(fsf);
ListenerFactory factory = new ListenerFactory();
- factory.setPort(20125);
+ factory.setPort(ftpPort);
serverFactory.addListener("default", factory.createListener());
ftpServer = serverFactory.createServer();
Modified: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest-context.xml?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest-context.xml (original)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFileAntPathMatcherRemoteFileFilterTest-context.xml Fri Dec 30 08:16:56 2011
@@ -23,11 +23,12 @@
">
<!-- START SNIPPET: example -->
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<camelContext xmlns="http://camel.apache.org/schema/spring">
<template id="camelTemplate"/>
<!-- use myFilter as filter to allow setting ANT paths for which files to scan for -->
- <endpoint id="myFTPEndpoint" uri="ftp://admin@localhost:20123/antpath?password=admin&recursive=true&delay=10000&initialDelay=2000&filter=#myAntFilter"/>
+ <endpoint id="myFTPEndpoint" uri="ftp://admin@localhost:${SpringFileAntPathMatcherRemoteFileFilterTest.ftpPort}/antpath?password=admin&recursive=true&delay=10000&initialDelay=2000&filter=#myAntFilter"/>
<route>
<from ref="myFTPEndpoint"/>
Modified: camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFtpEndpointTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFtpEndpointTest-context.xml?rev=1225769&r1=1225768&r2=1225769&view=diff
==============================================================================
--- camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFtpEndpointTest-context.xml (original)
+++ camel/trunk/tests/camel-itest/src/test/resources/org/apache/camel/itest/ftp/SpringFtpEndpointTest-context.xml Fri Dec 30 08:16:56 2011
@@ -23,6 +23,7 @@
">
<!-- START SNIPPET: e1 -->
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<bean id="myFTPEndpoint" class="org.apache.camel.component.file.remote.FtpEndpoint">
<property name="camelContext" ref="camel"/>
<property name="configuration" ref="ftpConfig"/>
@@ -36,7 +37,7 @@
<bean id="ftpConfig" class="org.apache.camel.component.file.remote.FtpConfiguration">
<property name="host" value="localhost"/>
- <property name="port" value="20125"/>
+ <property name="port" value="${SpringFtpEndpointTest.ftpPort}"/>
<property name="username" value="admin"/>
<property name="password" value="admin"/>
<property name="protocol" value="ftp"/>