1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.ftp;
12
13 import org.mule.tck.FunctionalTestCase;
14 import org.mule.transport.ftp.server.NamedPayload;
15 import org.mule.transport.ftp.server.Server;
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 }
32
33 public AbstractFtpServerTestCase(int port)
34 {
35 this(port, DEFAULT_TIMEOUT);
36 }
37
38 protected void startServer() throws Exception
39 {
40 server = new Server(port);
41 server.awaitStart(timeout);
42
43
44 synchronized(this)
45 {
46 wait(500);
47 }
48 }
49
50 protected void stopServer() throws Exception
51 {
52
53 if (null != server)
54 {
55 server.stop();
56 }
57 }
58
59
60 protected void doSetUp() throws Exception
61 {
62 startServer();
63 }
64
65
66 protected void doTearDown() throws Exception
67 {
68 stopServer();
69 }
70
71 protected int getTimeout()
72 {
73 return timeout;
74 }
75
76 protected NamedPayload awaitUpload() throws InterruptedException
77 {
78 return server.awaitUpload(timeout);
79 }
80
81 }