servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ccust...@apache.org
Subject svn commit: r783962 - in /servicemix/components/bindings/servicemix-ftp/trunk: ./ src/main/java/org/apache/servicemix/ftp/ src/test/java/org/apache/servicemix/ftp/ src/test/resources/
Date Fri, 12 Jun 2009 00:20:45 GMT
Author: ccustine
Date: Fri Jun 12 00:20:45 2009
New Revision: 783962

URL: http://svn.apache.org/viewvc?rev=783962&view=rev
Log:
SMXCOMP-518 - Improve test coverage - ServiceMix :: FTP

Added:
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/AbstractFtpTestSupport.java
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpClientPoolTest.java
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/test-data.xml
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/users.properties
Modified:
    servicemix/components/bindings/servicemix-ftp/trunk/pom.xml
    servicemix/components/bindings/servicemix-ftp/trunk/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
    servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpSenderEndpointTest.java

Modified: servicemix/components/bindings/servicemix-ftp/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/pom.xml?rev=783962&r1=783961&r2=783962&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/pom.xml (original)
+++ servicemix/components/bindings/servicemix-ftp/trunk/pom.xml Fri Jun 12 00:20:45 2009
@@ -110,6 +110,18 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <dependency>
+      <groupId>org.apache.ftpserver</groupId>
+      <artifactId>ftpserver-core</artifactId>
+      <version>1.0.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-jcl</artifactId>
+      <version>1.5.2</version>
+      <scope>test</scope>
+    </dependency>
 
   </dependencies>
   
@@ -138,19 +150,29 @@
           </execution>
         </executions>
       </plugin>
+      <!-- exclude generated DefaultBootstrap class from Cobertura reports -->
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>cobertura-maven-plugin</artifactId>
         <configuration>
-          <excludes>
-            <!--  TODO - need an embedded FTP server to be able to properly test -->
-            <exclude>**/DynamicEndpointTest.java</exclude>
-            <exclude>**/PollDirectoryTest.java</exclude>
-            <exclude>**/SpringComponentTest.java</exclude>
-          </excludes>
+          <instrumentation>
+            <excludes>
+              <exclude>org/apache/servicemix/common/DefaultBootstrap.class</exclude>
+            </excludes>
+          </instrumentation>
         </configuration>
       </plugin>
     </plugins>
   </build>
-  
+
+
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>cobertura-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+
 </project>

Modified: servicemix/components/bindings/servicemix-ftp/trunk/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java?rev=783962&r1=783961&r2=783962&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
(original)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/main/java/org/apache/servicemix/ftp/FtpPollerEndpoint.java
Fri Jun 12 00:20:45 2009
@@ -117,7 +117,20 @@
         }
     }
 
-    public void start() throws Exception {
+    @Override
+	public synchronized void activate() throws Exception {
+		if (uri == null && clientPool != null) {
+			String str = "ftp://" + clientPool.getHost();
+			if (clientPool.getPort() >= 0) {
+				str += ":" + clientPool.getPort();
+			}
+			str += "/";
+			uri = new URI(str);
+		}
+		super.activate();
+	}
+
+	public void start() throws Exception {
         if (lockManager == null) {
             lockManager = createLockManager();
         }
@@ -134,14 +147,7 @@
                     clientPool.setPassword(infos[1]);
                 }
             }
-        } else {
-            String str = "ftp://" + clientPool.getHost();
-            if (clientPool.getPort() >= 0) {
-                str += ":" + clientPool.getPort();
-            }
-            str += "/";
-            uri = new URI(str);
-        }
+        } 
         
         // borrow client from pool
         FTPClient ftp = borrowClient();
@@ -512,7 +518,7 @@
                 } else {
                     Exception e = exchange.getError();
                     if (e == null) {
-                        e = new JBIException("Unkown error");
+                        e = new JBIException("Unknown error");
                     }
                     throw e;
                 }

Added: servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/AbstractFtpTestSupport.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/AbstractFtpTestSupport.java?rev=783962&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/AbstractFtpTestSupport.java
(added)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/AbstractFtpTestSupport.java
Fri Jun 12 00:20:45 2009
@@ -0,0 +1,242 @@
+/*
+ * 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.servicemix.ftp;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Scanner;
+
+import javax.naming.InitialContext;
+
+import junit.framework.TestCase;
+
+import org.apache.ftpserver.ConnectionConfigFactory;
+import org.apache.ftpserver.FtpServerFactory;
+import org.apache.ftpserver.ftplet.DefaultFtplet;
+import org.apache.ftpserver.ftplet.FtpException;
+import org.apache.ftpserver.ftplet.FtpRequest;
+import org.apache.ftpserver.ftplet.FtpSession;
+import org.apache.ftpserver.ftplet.Ftplet;
+import org.apache.ftpserver.ftplet.FtpletResult;
+import org.apache.ftpserver.impl.DefaultFtpServer;
+import org.apache.ftpserver.listener.ListenerFactory;
+import org.apache.ftpserver.usermanager.ClearTextPasswordEncryptor;
+import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.util.FileUtil;
+
+import edu.emory.mathcs.backport.java.util.Arrays;
+
+/**
+ * Base class for FTP tests that starts an FTP server and JBI container.
+ */
+public abstract class AbstractFtpTestSupport extends TestCase {
+
+	private static final String REQUEST_LOG = "requestLog";
+	public static final File TEST_DIR = new File("target/test");
+	public static final File RESOURCES = new File(System.getProperty(
+			"org.apache.servicemix.ftp.testResources", "target/test-classes"));
+
+	private static final File USERS_FILE = new File(RESOURCES,
+			"users.properties");
+
+	protected DefaultFtpServer server;
+	protected JBIContainer container;
+	protected DefaultServiceMixClient client;
+
+	@Override
+	protected void setUp() throws Exception {
+		createJbiContainer();
+		createSmxClient();
+		cleanDirs();
+		initDirs();
+		server = (DefaultFtpServer) createServerFactory().createServer();
+		server.start();
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		if (container != null) {
+			container.stop();
+			container.shutDown();
+			while (!container.isShutDown()) {
+				System.out.println("WAITING to shutdown...");
+			}
+		}
+		if (server != null) {
+			server.stop();
+		}
+		cleanDirs();
+	}
+
+	protected void createSmxClient() throws Exception {
+		client = new DefaultServiceMixClient(container);
+	}
+
+	protected void createJbiContainer() throws Exception {
+		container = new JBIContainer();
+		configureJbiContainer();
+		container.init();
+		container.start();
+	}
+
+	protected void configureJbiContainer() throws Exception {
+		container.setEmbedded(true);
+		container.setUseMBeanServer(false);
+		container.setCreateMBeanServer(false);
+		container.setCreateJmxConnector(false);
+		container.setMonitorInstallationDirectory(false);
+		container.setNamingContext(new InitialContext());
+		container.setFlowName("st");
+	}
+
+	protected void initDirs() throws Exception {
+		if (!TEST_DIR.mkdirs()) {
+			throw new Exception("Unable to create directory: " + TEST_DIR);
+		}
+	}
+
+	protected void cleanDirs() throws Exception {
+		if (!FileUtil.deleteFile(TEST_DIR)) {
+			throw new Exception("Unable to delete directory: " + TEST_DIR);
+		}
+	}
+
+	protected FtpServerFactory createServerFactory() {
+		FtpServerFactory serverFactory = new FtpServerFactory();
+		serverFactory.setConnectionConfig(new ConnectionConfigFactory()
+				.createConnectionConfig());
+
+		ListenerFactory listenerFactory = new ListenerFactory();
+		listenerFactory.setPort(0);
+		serverFactory.addListener("default", listenerFactory.createListener());
+
+		PropertiesUserManagerFactory userMgrFactory = new PropertiesUserManagerFactory();
+		userMgrFactory.setAdminName("admin");
+		userMgrFactory.setPasswordEncryptor(new ClearTextPasswordEncryptor());
+		userMgrFactory.setFile(USERS_FILE);
+
+		serverFactory.setUserManager(userMgrFactory.createUserManager());
+		serverFactory.setFtplets(getFtplets());
+
+		return serverFactory;
+	}
+
+	protected Map<String, Ftplet> getFtplets() {
+		Map<String, Ftplet> map = new HashMap<String, Ftplet>();
+		map.put(REQUEST_LOG, new RequestLogFtplet());
+		return map;
+	}
+
+	protected final int getListenerPort() {
+		return server.getListener("default").getPort();
+	}
+
+	/*
+	 * Asserts that the given file exists and contains the given string.
+	 */
+	protected void assertFileContains(File file, String string)
+			throws IOException {
+
+		assertTrue("file does not exist: " + file, file.exists());
+		assertTrue("cannot read file: " + file, file.canRead());
+
+		Scanner scanner = null;
+		try {
+			scanner = new Scanner(file);
+			String result = scanner.findInLine(string);
+			assertNotNull("string '" + string + "' not found in file: " + file,
+					result);
+		} finally {
+			if (scanner != null)
+				scanner.close();
+		}
+	}
+
+	/**
+	 * Copy test data to given file.
+	 */
+	protected void createTestFile(File file) throws IOException {
+		file.getParentFile().mkdirs();
+		InputStream fis = new FileInputStream(RESOURCES + "/test-data.xml");
+		OutputStream fos = new FileOutputStream(file);
+		FileUtil.copyInputStream(fis, fos);
+		fis.close();
+		fos.close();
+	}
+
+	/**
+	 * Get the list of requests received by the FTP server.
+	 */
+	protected List<String> getRequestLog() {
+		RequestLogFtplet ftplet = (RequestLogFtplet) server.getFtplets().get(
+				REQUEST_LOG);
+		return ftplet.getRequests();
+	}
+
+	/**
+	 * Test assertion that the FTP server executed the given requests (in
+	 * order). Any requests before or after the given sequence are ignored.
+	 */
+	protected void assertRequestLogContains(String[] expected) {
+		List<String> requestLog = getRequestLog();
+		String[] requestArray = new String[requestLog.size()];
+		requestArray = requestLog.toArray(requestArray);
+
+		String[] actual = null;
+
+		for (int i = 0; i < requestArray.length; i++) {
+			if (requestArray[i].equals(expected[0])) {
+				actual = (String[]) Arrays.copyOfRange(requestArray, i, i
+						+ expected.length);
+			}
+		}
+
+		assertTrue("expected " + Arrays.toString(expected) + " actual "
+				+ Arrays.toString(actual), Arrays.equals(expected, actual));
+	}
+
+	/**
+	 * Ftplet to capture the list of requests received by the FTP server.
+	 */
+	protected static class RequestLogFtplet extends DefaultFtplet {
+
+		List<String> requests = new ArrayList<String>();
+
+		@Override
+		public FtpletResult beforeCommand(FtpSession session, FtpRequest request)
+				throws FtpException, IOException {
+			requests.add(request.getRequestLine());
+			return super.beforeCommand(session, request);
+		}
+
+		public List<String> getRequests() {
+			return requests;
+		}
+
+	}
+
+}

Modified: servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java?rev=783962&r1=783961&r2=783962&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
(original)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/DynamicEndpointTest.java
Fri Jun 12 00:20:45 2009
@@ -1,66 +1,89 @@
-/*
- * 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.servicemix.ftp;
 
+import java.io.File;
+
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.InOnly;
-import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
 import javax.jbi.servicedesc.ServiceEndpoint;
 
-import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.client.ServiceMixClient;
 import org.apache.servicemix.components.util.DefaultFileMarshaler;
-import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
-import org.apache.servicemix.tck.SpringTestSupport;
-import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-
-public class DynamicEndpointTest extends SpringTestSupport {
-
-    public void testSendingToDynamicEndpoint() throws Exception {
-        ServiceMixClient client = new DefaultServiceMixClient(jbi);
-
-        ServiceEndpoint se = client.resolveEndpointReference("ftp://servicemix:rocks@localhost/smx/test");
-        assertNotNull("We should find a service endpoint!", se);
-
-        InOnly exchange = client.createInOnlyExchange();
-        exchange.setEndpoint(se);
-        exchange.getInMessage().setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test.xml");
-        exchange.getInMessage().setContent(new StringSource("<hello>world</hello>"));
-        client.sendSync(exchange);
-
-        assertExchangeWorked(exchange);
-    }
-
-    protected void assertExchangeWorked(MessageExchange me) throws Exception {
-        if (me.getStatus() == ExchangeStatus.ERROR) {
-            if (me.getError() != null) {
-                throw me.getError();
-            } else {
-                fail("Received ERROR status");
-            }
-        } else if (me.getFault() != null) {
-            fail("Received fault: " + new SourceTransformer().toString(me.getFault().getContent()));
-        }
-    }
-
-    protected AbstractXmlApplicationContext createBeanFactory() {
-        return new ClassPathXmlApplicationContext("spring-no-endpoints.xml");
-    }
+
+/**
+ * Test cases for dynamically creating {@link FtpSenderEndpoint}s.
+ */
+public class DynamicEndpointTest extends AbstractFtpTestSupport {
+
+	private static final String FILE_CONTENT = "<hello>world</hello>";
+	private static final String FILE_NAME = "test.xml";
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+		container.activateComponent(new FtpComponent(), "servicemix-ftp");
+	}
+
+	// test simple send to a dynamic endpoint
+	public void testSendingToDynamicEndpoint() throws Exception {
+		String uri = "ftp://testuser1:password@localhost:" + getListenerPort()
+				+ "/dynamic";
+
+		InOnly exchange = createExchange(uri);
+		client.sendSync(exchange);
+
+		assertEquals("exchange status", ExchangeStatus.DONE, exchange
+				.getStatus());
+		assertFileContains(new File(TEST_DIR, "dynamic/" + FILE_NAME),
+				FILE_CONTENT);
+	}
+
+	// test send to a dynamic endpoint with additional URI parameters
+	public void testSendingToDynamicEndpointWithParameters() throws Exception {
+
+		// create file to be replaced
+		File file = new File(TEST_DIR, "dynamic/" + FILE_NAME);
+		createTestFile(file);
+
+		String uri = "ftp://testuser1:password@localhost:" + getListenerPort()
+				+ "/dynamic?overwrite=true";
+
+		InOnly exchange = createExchange(uri);
+		String newContent = "<new>overwritten</new>";
+		exchange.getInMessage().setContent(new StringSource(newContent));
+
+		client.sendSync(exchange);
+
+		assertEquals("exchange status", ExchangeStatus.DONE, exchange
+				.getStatus());
+		assertFileContains(new File(TEST_DIR, "dynamic/" + FILE_NAME),
+				newContent);
+	}
+
+	// test send fails with invalid login
+	public void testLoginFailure() throws Exception {
+		String uri = "ftp://testuser1:wrong_password@localhost:"
+				+ getListenerPort() + "/dynamic";
+
+		InOnly exchange = createExchange(uri);
+		exchange.getInMessage().setContent(new StringSource(FILE_CONTENT));
+		client.sendSync(exchange);
+
+		assertEquals("exchange status", ExchangeStatus.ERROR, exchange
+				.getStatus());
+	}
+
+	private InOnly createExchange(String uri) throws MessagingException {
+		ServiceEndpoint endpoint = client.resolveEndpointReference(uri);
+		assertNotNull("expected endpoint for uri: " + uri, endpoint);
+
+		InOnly exchange = client.createInOnlyExchange();
+		exchange.setEndpoint(endpoint);
+		exchange.getInMessage().setProperty(
+				DefaultFileMarshaler.FILE_NAME_PROPERTY, FILE_NAME);
+		exchange.getInMessage().setContent(new StringSource(FILE_CONTENT));
+
+		return exchange;
+	}
 
 }

Added: servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpClientPoolTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpClientPoolTest.java?rev=783962&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpClientPoolTest.java
(added)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpClientPoolTest.java
Fri Jun 12 00:20:45 2009
@@ -0,0 +1,108 @@
+package org.apache.servicemix.ftp;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.jbi.component.Component;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.tck.MessageList;
+import org.apache.servicemix.tck.ReceiverComponent;
+
+/**
+ * Test cases for {@link FTPClientPool}.
+ */
+public class FtpClientPoolTest extends AbstractFtpTestSupport {
+
+	private ReceiverComponent receiver;
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		ReceiverComponent rec = new ReceiverComponent();
+		rec.setService(new QName("receiver"));
+		rec.setEndpoint("endpoint");
+		container.activateComponent(rec, "receiver");
+		receiver = rec;
+
+		File file = new File(TEST_DIR, "test.xml");
+		createTestFile(file);
+	}
+
+	// test using a client pool to set passive mode
+	public void testPassive() throws Exception {
+		FTPClientPool pool = createClientPool();
+		pool.setPassiveMode(true);
+		pool.afterPropertiesSet();
+		FtpPollerEndpoint endpoint = createEndpoint(pool);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(1);
+
+		assertRequestLogContains(new String[] { "PASV" });
+	}
+
+	// test using a client pool to set binary mode
+	public void testBinary() throws Exception {
+		FTPClientPool pool = createClientPool();
+		pool.setBinaryMode(true);
+		pool.afterPropertiesSet();
+		FtpPollerEndpoint endpoint = createEndpoint(pool);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		assertRequestLogContains(new String[] { "TYPE I" });
+	}
+
+	// test using a client pool to disable binary mode
+	public void testNotBinary() throws Exception {
+		FTPClientPool pool = createClientPool();
+		pool.setBinaryMode(false);
+		pool.afterPropertiesSet();
+		FtpPollerEndpoint endpoint = createEndpoint(pool);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		assertFalse("request not expected: TYPE I", getRequestLog().contains(
+				"TYPE I"));
+	}
+
+	private Component createComponent(FtpPollerEndpoint endpoint) {
+		FtpComponent component = new FtpComponent();
+		component.setEndpoints(new FtpPollerEndpoint[] { endpoint });
+		return component;
+	}
+
+	private FtpPollerEndpoint createEndpoint(FTPClientPool clientPool)
+			throws Exception {
+		FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+		endpoint.setPeriod(1000);
+		endpoint.setService(new QName("ftp"));
+		endpoint.setEndpoint("endpoint");
+		endpoint.setTargetService(receiver.getService());
+		endpoint.setClientPool(clientPool);
+
+		// TODO Need this until SMXCOMP-556 is fixed
+		endpoint.setUri(new URI("ftp://testuser1:password@localhost:"
+				+ getListenerPort() + "/"));
+
+		endpoint.validate();
+		return endpoint;
+	}
+
+	private FTPClientPool createClientPool() {
+		FTPClientPool pool = new FTPClientPool();
+		// TODO Causes NPE, seeSMXCOMP-556
+		// pool.setHost("localhost");
+		// pool.setPort(getListenerPort());
+		pool.setUsername("testuser2");
+		pool.setPassword("password");
+		return pool;
+	}
+
+}

Modified: servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java?rev=783962&r1=783961&r2=783962&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
(original)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpPollerEndpointTest.java
Fri Jun 12 00:20:45 2009
@@ -16,30 +16,377 @@
  */
 package org.apache.servicemix.ftp;
 
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
 
 import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
 import javax.xml.namespace.QName;
 
-import junit.framework.TestCase;
+import org.apache.servicemix.components.util.DefaultFileMarshaler;
+import org.apache.servicemix.ftp.FtpPollerEndpoint.FtpData;
+import org.apache.servicemix.tck.MessageList;
+import org.apache.servicemix.tck.ReceiverComponent;
 
 /**
- * Test cases for {@link FtpPollerEndpoint} 
+ * Tests for {@link FtpPollerEndpoint}
  */
-public class FtpPollerEndpointTest extends TestCase {
+public class FtpPollerEndpointTest extends AbstractFtpTestSupport {
 
-    public void testValidateNoCwdWhenRecursive() throws URISyntaxException {
-        FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
-        endpoint.setUri(new URI("ftp://anonymous@just.a.server/test"));
-        endpoint.setTargetService(new QName("test", "service"));
-        endpoint.setChangeWorkingDirectory(true);
-        try {
-            endpoint.validate();
-            fail("validate() should throw exception when changeWorkingDirectory='true' and
recursive='true'");
-        } catch (DeploymentException e) {
-            //this is what we expect
-        }
-    }
-}
+	private ReceiverComponent receiver;
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		ReceiverComponent rec = new MyReceiverComponent();
+		rec.setService(new QName("receiver"));
+		rec.setEndpoint("endpoint");
+		container.activateComponent(rec, "receiver");
+		receiver = rec;
+	}
+
+	// test basic polling
+	public void testSimplePoll() throws Exception {
+		Map<String, File> files = createTestFiles(3);
+		container.activateComponent(createComponent(), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted", file
+						.exists());
+			}
+		});
+	}
+
+	// test recursive polling
+	public void testRecursive() throws Exception {
+		Map<String, File> files = createTestFiles(1);
+		files.putAll(createTestFiles(1, "dir1"));
+		files.putAll(createTestFiles(1, "dir1/dir2"));
+
+		container.activateComponent(createComponent(), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted", file
+						.exists());
+			}
+		});
+	}
+
+	// test non-recursive polling
+	public void testNotRecursive() throws Exception {
+		Map<String, File> files = createTestFiles(3);
+		createTestFiles(2, "dir1/dir2");
+
+		FtpPollerEndpoint endpoint = createEndpoint();
+		endpoint.setRecursive(false);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted", file
+						.exists());
+			}
+		});
+	}
+
+	// test polling without deleting
+	public void testNoDelete() throws Exception {
+		Map<String, File> files = createTestFiles(1);
+
+		FtpPollerEndpoint endpoint = createEndpoint();
+		endpoint.setDeleteFile(false);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertTrue("expected <" + file + "> to exist", file.exists());
+			}
+		});
+	}
+
+	// test polling with archiving
+	public void testArchive() throws Exception {
+		Map<String, File> files = createTestFiles(3);
+
+		FtpPollerEndpoint endpoint = createEndpoint();
+		endpoint.setArchive(new URI("archived"));
+		endpoint.setDeleteFile(true);
+		endpoint.setRecursive(false);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+
+		final File archiveDir = new File(TEST_DIR, "/archived");
+		assertTrue("expected <" + archiveDir + "> to exist", archiveDir
+				.exists());
+
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted" + file,
+						file.exists());
+
+				final String expectedName = file.getName();
+				FilenameFilter filter = new FilenameFilter() {
+					public boolean accept(File parent, String name) {
+						return name.endsWith(expectedName);
+					}
+				};
+				assertEquals("unexpected number of archives for file: " + file
+						+ "", 1, archiveDir.listFiles(filter).length);
+			}
+		});
+	}
+
+	// test polling with a filter
+	public void testFilter() throws Exception {
+		Map<String, File> files = createTestFiles(1);
+		createTestFile("ignore-test-1.xml");
+		createTestFile("ignore-test-2.xml");
+
+		FileFilter filter = new FileFilter() {
+			public boolean accept(File file) {
+				return (!file.getName().startsWith("ignore"));
+			}
+		};
+
+		FtpPollerEndpoint endpoint = createEndpoint();
+		endpoint.setFilter(filter);
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		MessageList messageList = receiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted", file
+						.exists());
+			}
+		});
+
+	}
+
+	// test polling with stateless = false
+	public void testNotStateless() throws Exception {
+		Map<String, File> files = createTestFiles(3);
+
+		// Replace the receiver component to check the exchange properties:
+		// when 'stateless' is false the FtpData object should not be passed
+		// with the exchange because it is cached by the endpoint.
+		container.deleteComponent("receiver");
+		ReceiverComponent newReceiver = new MyReceiverComponent() {
+			@Override
+			public void onMessageExchange(MessageExchange exchange)
+					throws MessagingException {
+				// !stateless: FtpData should not be passed with the exchange
+				if (exchange.getProperty(FtpData.class.getName()) != null) {
+					fail(exchange, new Exception("Unexpected property: "
+							+ FtpData.class.getName()));
+				} else {
+					super.onMessageExchange(exchange);
+				}
+			}
+		};
+		newReceiver.setService(new QName("receiver"));
+		newReceiver.setEndpoint("endpoint");
+		container.activateComponent(newReceiver, "receiver");
 
+		FtpPollerEndpoint endpoint = createEndpoint();
+		endpoint.setStateless(false);
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+		MessageList messageList = newReceiver.getMessageList();
+		messageList.assertMessagesReceived(files.size());
+		assertFilesProcessed(messageList, files, new FileAssertions() {
+			public void assertProcessed(File file, NormalizedMessage message) {
+				assertFalse("expected <" + file + "> to be deleted", file
+						.exists());
+			}
+		});
+
+	}
+
+	public void testValidateNoCwdWhenRecursive() throws URISyntaxException {
+		FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+		endpoint.setUri(new URI("ftp://anonymous@just.a.server/test"));
+		endpoint.setTargetService(new QName("test", "service"));
+		endpoint.setChangeWorkingDirectory(true);
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when changeWorkingDirectory='true' and recursive='true'");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+	}
+
+	public void testValidateUriOrHost() throws URISyntaxException,
+			DeploymentException {
+		FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+		endpoint.setTargetService(new QName("test", "service"));
+
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when neither URI nor clientPool.host is set");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+
+		endpoint.setUri(new URI("ftp://anonymous@just.a.server/test"));
+		endpoint.validate(); // should not throw
+
+		FTPClientPool clientPool = new FTPClientPool();
+		clientPool.setHost("just.a.server");
+		endpoint.setClientPool(clientPool);
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when both URI and clientPool.host are set");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+
+		endpoint.setUri(null);
+		endpoint.validate(); // should not throw
+	}
+
+	public void testValidateDeleteWhenArchive() throws URISyntaxException {
+		FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+		endpoint.setUri(new URI("ftp://anonymous@just.a.server/test/data"));
+		endpoint.setArchive(new URI("ftp://anonymous@just.a.server"));
+		endpoint.setDeleteFile(false);
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when both archive is set but delete is false");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+	}
+
+	private FtpComponent createComponent() throws Exception {
+		return createComponent(createEndpoint());
+	}
+
+	private FtpComponent createComponent(FtpPollerEndpoint endpoint)
+			throws Exception {
+		FtpComponent component = new FtpComponent();
+		component.setEndpoints(new FtpPollerEndpoint[] { endpoint });
+		return component;
+	}
+
+	private FtpPollerEndpoint createEndpoint() throws Exception {
+		FtpPollerEndpoint endpoint = new FtpPollerEndpoint();
+		endpoint.setPeriod(1000);
+		endpoint.setService(new QName("ftp"));
+		endpoint.setEndpoint("endpoint");
+		endpoint.setTargetService(receiver.getService());
+		endpoint.setUri(new URI("ftp://testuser1:password@localhost:"
+				+ getListenerPort() + "/"));
+
+		endpoint.validate();
+		return endpoint;
+	}
+
+	/**
+	 * Generate some number of unique test files in the FTP root directory.
+	 */
+	protected Map<String, File> createTestFiles(int count) throws IOException {
+		return createTestFiles(count, null);
+	}
+
+	/**
+	 * Generate some number of unique test files in the given dir relative to
+	 * the FTP root directory.
+	 */
+	protected Map<String, File> createTestFiles(int count, String path)
+			throws IOException {
+		Map<String, File> files = new HashMap<String, File>(count);
+
+		File targetDir = path == null ? TEST_DIR : new File(TEST_DIR, path);
+		targetDir.mkdirs();
+
+		for (int i = 0; i < count; i++) {
+			File file = File.createTempFile("test-", ".xml", targetDir);
+			createTestFile(file);
+			files.put(file.getName(), file);
+		}
+		return files;
+	}
+
+	/**
+	 * Generate a test file with given path relative to the FTP root directory.
+	 */
+	protected File createTestFile(String path) throws IOException {
+		File file = new File(TEST_DIR, path);
+		createTestFile(file);
+		return file;
+	}
+
+	/**
+	 * Check that the given message list contains a message for each file in the
+	 * given file map, and that the files have been processed as expected.
+	 */
+	protected void assertFilesProcessed(MessageList messageList,
+			Map<String, File> files, FileAssertions additionalAssertions)
+			throws Exception {
+
+		assertEquals(messageList.getMessageCount(), files.size());
+		for (Iterator<NormalizedMessage> iter = messageList.getMessages()
+				.iterator(); iter.hasNext();) {
+			NormalizedMessage message = iter.next();
+
+			String fileName = (String) message
+					.getProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY);
+			File file = files.get(fileName);
+			assertNotNull("invalid file name: " + fileName, file);
+
+			File path = new File(TEST_DIR, ((String) message
+					.getProperty(DefaultFileMarshaler.FILE_PATH_PROPERTY)));
+			assertEquals("invalid file path", file, path);
+
+			additionalAssertions.assertProcessed(file, message);
+		}
+	}
+
+	/**
+	 * Variant of ReceiverComponent that sets done on the message exchange
+	 * before updating the message list. This allows the FTP Poller endpoint to
+	 * finish processing (i.e. delete or archive the file) before the test
+	 * results are examined.
+	 */
+	private static class MyReceiverComponent extends ReceiverComponent {
+		public void onMessageExchange(MessageExchange exchange)
+				throws MessagingException {
+			NormalizedMessage inMessage = getInMessage(exchange);
+			NormalizedMessage copyMessage = exchange.createMessage();
+			getMessageTransformer().transform(exchange, inMessage, copyMessage);
+			done(exchange);
+			getMessageList().addMessage(copyMessage);
+		}
+	}
+
+	private static interface FileAssertions {
+		void assertProcessed(File file, NormalizedMessage message);
+	}
+
+}

Modified: servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpSenderEndpointTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpSenderEndpointTest.java?rev=783962&r1=783961&r2=783962&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpSenderEndpointTest.java
(original)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/java/org/apache/servicemix/ftp/FtpSenderEndpointTest.java
Fri Jun 12 00:20:45 2009
@@ -16,29 +16,191 @@
  */
 package org.apache.servicemix.ftp;
 
-import junit.framework.TestCase;
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.jbi.management.DeploymentException;
+import javax.jbi.messaging.ExchangeStatus;
+import javax.jbi.messaging.InOnly;
+import javax.jbi.messaging.MessageExchange;
+import javax.jbi.messaging.MessagingException;
+import javax.jbi.messaging.NormalizedMessage;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.components.util.DefaultFileMarshaler;
+import org.apache.servicemix.jbi.jaxp.StringSource;
 
 /**
- * Test cases for {@link FtpSenderEndpoint} 
+ * Test cases for {@link FtpSenderEndpoint}
  */
-public class FtpSenderEndpointTest extends TestCase {
+public class FtpSenderEndpointTest extends AbstractFtpTestSupport {
+
+	private static final String DEFAULT_CONTENT = "<hello>world</hello>";
+	private static final String DEFAULT_FILENAME = "test.xml";
+
+	public void testAutoCreateDir() throws Exception {
+
+		// test auto-create: false
+		FtpSenderEndpoint endpoint = createEndpoint();
+		endpoint.setAutoCreateDirectory(false);
+		endpoint.setUri(new URI("ftp://testuser1:password@localhost:"
+				+ getListenerPort() + "/user1"));
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		File dir = new File(TEST_DIR, "user1");
+		assertFalse("dir should not have been created: " + dir, dir.exists());
+
+		container.deactivateComponent("servicemix-ftp");
+
+		// test auto-create: true
+		endpoint = createEndpoint();
+		endpoint.setAutoCreateDirectory(true);
+		endpoint.setUri(new URI("ftp://testuser2:password@localhost:"
+				+ getListenerPort() + "/user2"));
+
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		dir = new File(TEST_DIR, "user2");
+		assertTrue("expected dir to be created: " + dir, dir.exists());
+
+		// test default
+		endpoint = new FtpSenderEndpoint();
+		assertEquals("unexpected default for 'autoCreateDirectory", true,
+				endpoint.isAutoCreateDirectory());
+	}
+	
+	// test simple upload
+	public void testSimpleUpload() throws Exception {
+		container.activateComponent(createComponent(), "servicemix-ftp");
+
+		MessageExchange exchange = createExchange(DEFAULT_FILENAME,
+				DEFAULT_CONTENT);
+		client.sendSync(exchange);
+
+		assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+		File file = new File(TEST_DIR, DEFAULT_FILENAME);
+		assertFileContains(file, DEFAULT_CONTENT);
+	}
+
+	// test upload fails to overwrite existing file
+	public void testUploadNoOverwrite() throws Exception {
+		container.activateComponent(createComponent(), "servicemix-ftp");
+
+		MessageExchange exchange = createExchange(DEFAULT_FILENAME,
+				DEFAULT_CONTENT);
+		client.sendSync(exchange);
+
+		assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+		File file = new File(TEST_DIR, DEFAULT_FILENAME);
+		assertFileContains(file, DEFAULT_CONTENT);
+
+		exchange = createExchange(DEFAULT_FILENAME, "<new>overwritten</new>");
+		client.sendSync(exchange);
+
+		// should fail and file should remain as before
+		assertEquals(ExchangeStatus.ERROR, exchange.getStatus());
+		assertFileContains(file, DEFAULT_CONTENT);
+	}
+
+	// test upload that overwrites an existing file
+	public void testUploadAndOverwrite() throws Exception {
+		FtpSenderEndpoint endpoint = createEndpoint();
+		endpoint.setOverwrite(true);
+		container
+				.activateComponent(createComponent(endpoint), "servicemix-ftp");
+
+		MessageExchange exchange = createExchange(DEFAULT_FILENAME,
+				DEFAULT_CONTENT);
+		client.sendSync(exchange);
+
+		assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+		File file = new File(TEST_DIR, DEFAULT_FILENAME);
+		assertFileContains(file, DEFAULT_CONTENT);
+
+		exchange = createExchange(DEFAULT_FILENAME, "<new>overwritten</new>");
+		client.sendSync(exchange);
+
+		assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+		assertFileContains(file, "<new>overwritten</new>");
+	}
+
+	// test upload with a specific temporary file name
+	public void testUploadWithTempName() throws Exception {
+		container.activateComponent(createComponent(), "servicemix-ftp");
+
+		MessageExchange exchange = createExchange(DEFAULT_FILENAME,
+				DEFAULT_CONTENT);
+		exchange.setProperty(DefaultFileMarshaler.TEMP_FILE_NAME_PROPERTY,
+				"upload.tmp");
+		client.sendSync(exchange);
+
+		assertEquals(ExchangeStatus.DONE, exchange.getStatus());
+		File file = new File(TEST_DIR, DEFAULT_FILENAME);
+		assertFileContains(file, DEFAULT_CONTENT);
+
+		assertRequestLogContains(new String[] { "STOR upload.tmp",
+				"RNFR upload.tmp", "RNTO test.xml" });
+	}
+
+	public void testValidateUriOrHost() throws URISyntaxException,
+			DeploymentException {
+		FtpSenderEndpoint endpoint = new FtpSenderEndpoint();
+
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when neither URI nor clientPool.host is set");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+
+		endpoint.setUri(new URI("ftp://anonymous@just.a.server/test"));
+		endpoint.validate(); // should not throw
+
+		FTPClientPool clientPool = new FTPClientPool();
+		clientPool.setHost("just.a.server");
+		endpoint.setClientPool(clientPool);
+		try {
+			endpoint.validate();
+			fail("validate() should throw exception when both URI and clientPool.host are set");
+		} catch (DeploymentException e) {
+			// this is what we expect
+		}
+
+		endpoint.setUri(null);
+		endpoint.validate(); // should not throw
+	}
+
+	private FtpSenderEndpoint createEndpoint() throws Exception {
+		FtpSenderEndpoint endpoint = new FtpSenderEndpoint();
+		endpoint.setService(new QName("ftp"));
+		endpoint.setEndpoint("endpoint");
+		endpoint.setUri(new URI("ftp://testuser1:password@localhost:"
+				+ getListenerPort() + "/"));
+		return endpoint;
+	}
+
+	private FtpComponent createComponent() throws Exception {
+		return createComponent(createEndpoint());
+	}
+
+	private FtpComponent createComponent(FtpSenderEndpoint endpoint)
+			throws Exception {
+		FtpComponent component = new FtpComponent();
+		component.setEndpoints(new FtpSenderEndpoint[] { endpoint });
+		return component;
+	}
+
+	private MessageExchange createExchange(String filename, String content)
+			throws MessagingException {
+		InOnly me = client.createInOnlyExchange();
+		NormalizedMessage inMessage = me.getInMessage();
+		inMessage.setContent(new StringSource(content));
+		me.setService(new QName("ftp"));
+		me.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, filename);
+		return me;
+	}
 
-    public void testGetUploadNameWithPrefix() {
-        FtpSenderEndpoint endpoint = new FtpSenderEndpoint();
-        endpoint.setUploadPrefix("work/");
-        assertEquals("work/myfile.xml", endpoint.getUploadName("myfile.xml"));
-    }
-    
-    public void testGetUploadNameWithSuffix() {
-        FtpSenderEndpoint endpoint = new FtpSenderEndpoint();
-        endpoint.setUploadSuffix(".tmp");
-        assertEquals("myfile.xml.tmp", endpoint.getUploadName("myfile.xml"));
-    }
-    
-    public void testGetUploadNameWithPrefixAndSuffix() {
-        FtpSenderEndpoint endpoint = new FtpSenderEndpoint();
-        endpoint.setUploadPrefix("work/");
-        endpoint.setUploadSuffix(".tmp");
-        assertEquals("work/myfile.xml.tmp", endpoint.getUploadName("myfile.xml"));
-    } 
 }

Added: servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/test-data.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/test-data.xml?rev=783962&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/test-data.xml (added)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/test-data.xml Fri
Jun 12 00:20:45 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0"?>
+<!--
+
+    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.
+
+-->
+<just>
+  <a>
+    <message>for testing purposes</message>
+  </a>
+</just>

Added: servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/users.properties
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/users.properties?rev=783962&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/users.properties
(added)
+++ servicemix/components/bindings/servicemix-ftp/trunk/src/test/resources/users.properties
Fri Jun 12 00:20:45 2009
@@ -0,0 +1,9 @@
+ftpserver.user.testuser1.homedirectory=./target/test
+ftpserver.user.testuser1.maxloginnumber=3
+ftpserver.user.testuser1.writepermission=true
+ftpserver.user.testuser1.userpassword=password
+
+ftpserver.user.testuser2.homedirectory=./target/test
+ftpserver.user.testuser2.maxloginnumber=3
+ftpserver.user.testuser2.writepermission=true
+ftpserver.user.testuser2.userpassword=password



Mime
View raw message