View Javadoc

1   /*
2    * $Id: FtpMessageDispatcherTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.DefaultMuleMessage;
14  import org.mule.module.client.MuleClient;
15  
16  import java.io.File;
17  
18  import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
19  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
20  
21  public class FtpMessageDispatcherTestCase extends AbstractFtpServerTestCase
22  {
23      private static final int PORT = 61099;
24      
25      private CountDownLatch latch;
26      
27      public FtpMessageDispatcherTestCase()
28      {
29          super(PORT);        
30          latch = new CountDownLatch(1);
31      }
32  
33      @Override
34      protected String getConfigResources()
35      {
36          return "ftp-message-requester-test.xml";
37      }
38  
39      public void testDispatch() throws Exception
40      {
41          MuleClient client = new MuleClient(muleContext);
42          client.dispatch(getMuleFtpEndpoint(), new DefaultMuleMessage(TEST_MESSAGE, muleContext));
43          
44          // check that the message arrived on the FTP server
45          assertTrue(latch.await(getTimeout(), TimeUnit.MILLISECONDS));
46  
47          String[] filesOnServer = new File(FTP_SERVER_BASE_DIR).list();
48          assertTrue(filesOnServer.length > 0);
49      }
50      
51      @Override
52      public void fileUploadCompleted()
53      {
54          latch.countDown();
55      }
56  }
57  
58