Home | History | Annotate | Download | only in integration
      1 package fi.iki.elonen.integration;
      2 
      3 import fi.iki.elonen.NanoHTTPD;
      4 import org.apache.http.client.HttpClient;
      5 import org.apache.http.impl.client.DefaultHttpClient;
      6 import org.junit.After;
      7 import org.junit.Before;
      8 
      9 import java.io.IOException;
     10 
     11 /**
     12  * @author Paul S. Hawke (paul.hawke (at) gmail.com)
     13  *         On: 9/2/13 at 10:02 PM
     14  */
     15 public abstract class IntegrationTestBase<T extends NanoHTTPD> {
     16     protected DefaultHttpClient httpclient;
     17     protected T testServer;
     18 
     19     @Before
     20     public void setUp() {
     21         testServer = createTestServer();
     22         httpclient = new DefaultHttpClient();
     23         try {
     24             testServer.start();
     25         } catch (IOException e) {
     26             e.printStackTrace();
     27         }
     28     }
     29 
     30     @After
     31     public void tearDown() {
     32         httpclient.getConnectionManager().shutdown();
     33         testServer.stop();
     34     }
     35 
     36     public abstract T createTestServer();
     37 }
     38