aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/java/fi/iki/elonen/integration/IntegrationTestBase.java
blob: eb3403342971a9ca68182f86ad22f7794ee44abd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package fi.iki.elonen.integration;

import fi.iki.elonen.NanoHTTPD;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.After;
import org.junit.Before;

import java.io.IOException;

/**
 * @author Paul S. Hawke (paul.hawke@gmail.com)
 *         On: 9/2/13 at 10:02 PM
 */
public abstract class IntegrationTestBase<T extends NanoHTTPD> {
    protected DefaultHttpClient httpclient;
    protected T testServer;

    @Before
    public void setUp() {
        testServer = createTestServer();
        httpclient = new DefaultHttpClient();
        try {
            testServer.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @After
    public void tearDown() {
        httpclient.getConnectionManager().shutdown();
        testServer.stop();
    }

    public abstract T createTestServer();
}