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 import org.mule.tck.FunctionalTestCase;
15
16 import edu.emory.mathcs.backport.java.util.concurrent.CountDownLatch;
17 import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
18
19 public abstract class AbstractMockHttpServerTestCase extends DynamicPortTestCase
20 {
21 private static final long MOCK_HTTP_SERVER_STARTUP_TIMEOUT = 30000;
22 private CountDownLatch serverStartLatch = new CountDownLatch(1);
23
24 @Override
25 protected void doSetUp() throws Exception
26 {
27 super.doSetUp();
28
29 MockHttpServer httpServer = getHttpServer(serverStartLatch);
30 new Thread(httpServer).start();
31
32
33 assertTrue("MockHttpServer start failed",
34 serverStartLatch.await(MOCK_HTTP_SERVER_STARTUP_TIMEOUT, TimeUnit.MILLISECONDS));
35 }
36
37
38
39
40 protected abstract MockHttpServer getHttpServer(CountDownLatch latch);
41 }