1 package org.onap.ccsdk.features.sdnr.wt.apigateway.test;
3 import static org.junit.Assert.fail;
5 import java.io.IOException;
6 import java.util.HashMap;
9 import org.junit.After;
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.onap.ccsdk.features.sdnr.wt.apigateway.database.http.BaseHTTPClient;
13 import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
15 public class TestHttpClient {
17 private static final int PORT =40010;
18 private static final String BASEURI = "/test";
20 private class TestBaseHTTPClient extends BaseHTTPClient {
21 public TestBaseHTTPClient() {
22 super(String.format("http://localhost:%s%s",PORT,BASEURI));
24 public void doTest() {
25 String[] methods=new String[] {"GET","POST","PUT","DELETE"};
26 Map<String, String> headers=new HashMap<String,String>();
27 headers.put("Content-Type","application/json");
28 headers.put("Authorization",BaseHTTPClient.getAuthorizationHeaderValue("admin","admin"));
29 for(String method:methods) {
31 this.sendRequest(String.format("%s%s", BASEURI,"/abc"), method, "abddef", headers);
32 } catch (IOException e) {
34 fail(String.format("problem with method %s: %s",method,e.getMessage()));
41 TestBaseHTTPClient client = new TestBaseHTTPClient();
47 public void init() throws IOException{
48 HelpServletBase.initEsTestWebserver(PORT);
51 public void deinit() {
52 HelpServletBase.stopTestWebserver();