1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.http.functional;
12
13 import org.mule.tck.DynamicPortTestCase;
14
15 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
16 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
17
18 public abstract class AbstractMockHttpServerTestCase extends DynamicPortTestCase
19 {
20 private static final long MOCK_HTTP_SERVER_STARTUP_TIMEOUT = 30000;
21 private CountDownLatch serverStartLatch = new CountDownLatch(1);
22
23 @Override
24 protected void doSetUp() throws Exception
25 {
26 super.doSetUp();
27
28 MockHttpServer httpServer = getHttpServer(serverStartLatch);
29 new Thread(httpServer).start();
30
31
32 assertTrue("MockHttpServer start failed",
33 serverStartLatch.await(MOCK_HTTP_SERVER_STARTUP_TIMEOUT, TimeUnit.MILLISECONDS));
34 }
35
36
37
38
39 protected abstract MockHttpServer getHttpServer(CountDownLatch latch);
40 }