1   /*
2    * $Id: FtpFunctionalTestCase.java 12377 2008-07-17 15:59:53Z tcarlson $
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.transport.ftp;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.transport.file.FileConnector;
16  import org.mule.transport.ftp.server.NamedPayload;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  public class FtpFunctionalTestCase extends AbstractFtpServerTestCase
22  {
23      private static int PORT = 60198;
24  
25      public FtpFunctionalTestCase()
26      {
27          super(PORT);
28      }
29  
30      protected String getConfigResources()
31      {
32          return "ftp-functional-test.xml";
33      }
34  
35      protected int getPort()
36      {
37          return PORT;
38      }
39      
40      public void testSendAndRequest() throws Exception
41      {
42          Map properties = new HashMap();
43          MuleClient client = new MuleClient();
44          client.dispatch("ftp://anonymous:email@localhost:" + getPort(), TEST_MESSAGE, properties);
45          NamedPayload payload = awaitUpload();
46          assertNotNull(payload);
47          assertEquals(TEST_MESSAGE, new String(payload.getPayload()));
48          logger.info("received message OK!");
49          MuleMessage retrieved = client.request("ftp://anonymous:email@localhost:" + getPort(), getTimeout());
50          assertNotNull(retrieved);
51          assertNotNull(retrieved.getProperty(FileConnector.PROPERTY_ORIGINAL_FILENAME));
52          assertNotNull(retrieved.getProperty(FileConnector.PROPERTY_FILE_SIZE));
53          assertEquals(retrieved.getPayloadAsString(), TEST_MESSAGE);
54      }
55  
56  }