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