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