1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.ftp;
12
13 import org.mule.providers.ftp.server.NamedPayload;
14 import org.mule.providers.ftp.server.Server;
15 import org.mule.tck.FunctionalTestCase;
16
17
18 public abstract class AbstractFtpServerTestCase extends FunctionalTestCase
19 {
20
21 public static final String TEST_MESSAGE = "Test FTP message";
22 private static int DEFAULT_TIMEOUT = 10000;
23 private int timeout;
24 private int port;
25 private Server server;
26
27 public AbstractFtpServerTestCase(int port, int timeout)
28 {
29 this.port = port;
30 this.timeout = timeout;
31 setDisposeManagerPerSuite(true);
32 }
33
34 public AbstractFtpServerTestCase(int port)
35 {
36 this(port, DEFAULT_TIMEOUT);
37 }
38
39 protected void startServer() throws Exception
40 {
41 server = new Server(port);
42 server.awaitStart(timeout);
43
44
45 synchronized(this)
46 {
47 wait(500);
48 }
49 }
50
51 protected void stopServer() throws Exception
52 {
53
54 if (null != server)
55 {
56 server.stop();
57 }
58 }
59
60 protected void doPostFunctionalSetUp() throws Exception
61 {
62 startServer();
63 }
64
65 protected void doFunctionalTearDown() throws Exception
66 {
67 stopServer();
68 }
69
70 protected int getTimeout()
71 {
72 return timeout;
73 }
74
75 protected NamedPayload awaitUpload() throws InterruptedException
76 {
77 return server.awaitUpload(timeout);
78 }
79
80 }