PageRenderTime 31ms CodeModel.GetById 17ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/plugin-module-codegen-engine/src/main/resources/templates/common/servlet/filter/ServletFilterFuncTest.java.vtl

https://bitbucket.org/mmeinhold/amps
Unknown | 42 lines | 32 code | 10 blank | 0 comment | 0 complexity | 6eba65e5c1eba9c81f469a73bfca0ccf MD5 | raw file
 1package ${PACKAGE};
 2
 3import org.apache.http.client.HttpClient;
 4import org.apache.http.client.ResponseHandler;
 5import org.apache.http.client.methods.HttpGet;
 6import org.apache.http.impl.client.BasicResponseHandler;
 7import org.apache.http.impl.client.DefaultHttpClient;
 8import org.junit.Test;
 9import org.junit.After;
10import org.junit.Before;
11
12import java.io.IOException;
13
14import static org.junit.Assert.*;
15
16
17public class ${CLASSNAME} {
18
19    HttpClient httpClient;
20    String baseUrl;
21
22    @Before
23    public void setup() {
24        httpClient = new DefaultHttpClient();
25        baseUrl = System.getProperty("baseurl");
26    }
27
28    @After
29    public void tearDown() {
30        httpClient.getConnectionManager().shutdown();
31    }
32
33    @Test
34    public void testSomething() throws IOException {
35        HttpGet httpget = new HttpGet(baseUrl);
36
37        // Create a response handler
38        ResponseHandler<String> responseHandler = new BasicResponseHandler();
39        String responseBody = httpClient.execute(httpget, responseHandler);
40        assertTrue(null != responseBody && !"".equals(responseBody));
41    }
42}