1   /*
2    * $Id: FtpFunctionalTestCase.java 10612 2008-01-29 17:05:37Z holger $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.providers.ftp;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.providers.file.FileConnector;
15  import org.mule.providers.ftp.server.NamedPayload;
16  import org.mule.umo.UMOMessage;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class FtpFunctionalTestCase extends AbstractFtpServerTestCase
22  {
23  
24      private static int PORT = 60198;
25  
26      public FtpFunctionalTestCase()
27      {
28          super(PORT);
29      }
30  
31      protected String getConfigResources()
32      {
33          return "ftp-functional-test.xml";
34      }
35  
36      public void testSendAndReceive() throws Exception
37      {
38          Map properties = new HashMap();
39          MuleClient client = new MuleClient();
40          client.dispatch("ftp://anonymous:email@localhost:" + PORT, TEST_MESSAGE, properties);
41          NamedPayload payload = awaitUpload();
42          assertNotNull(payload);
43          assertEquals(TEST_MESSAGE, new String(payload.getPayload()));
44          logger.info("received message OK!");
45          UMOMessage retrieved = client.receive("ftp://anonymous:email@localhost:" + PORT, getTimeout());
46          assertNotNull(retrieved);
47          assertNotNull(retrieved.getProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME));
48          assertNotNull(retrieved.getProperty(FileConnector.PROPERTY_FILE_SIZE));
49          assertEquals(retrieved.getPayloadAsString(), TEST_MESSAGE);
50      }
51  
52  }