1 /*******************************************************************************
 
   2  * ============LICENSE_START========================================================================
 
   3  * ONAP : ccsdk feature sdnr wt
 
   4  * =================================================================================================
 
   5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
 
   6  * =================================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 
   8  * in compliance with the License. You may obtain a copy of the License at
 
  10  * http://www.apache.org/licenses/LICENSE-2.0
 
  12  * Unless required by applicable law or agreed to in writing, software distributed under the License
 
  13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 
  14  * or implied. See the License for the specific language governing permissions and limitations under
 
  16  * ============LICENSE_END==========================================================================
 
  17  ******************************************************************************/
 
  18 package org.onap.ccsdk.features.sdnr.wt.apigateway.test;
 
  20 import static org.junit.Assert.fail;
 
  22 import java.io.IOException;
 
  23 import java.util.HashMap;
 
  26 import org.junit.After;
 
  27 import org.junit.Before;
 
  28 import org.junit.Test;
 
  29 import org.onap.ccsdk.features.sdnr.wt.apigateway.database.http.BaseHTTPClient;
 
  30 import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
 
  32 public class TestHttpClient {
 
  34         private static final int PORT =40010;
 
  35         private static final String BASEURI = "/test";
 
  37         private class TestBaseHTTPClient extends BaseHTTPClient {
 
  38                 public TestBaseHTTPClient() {
 
  39                         super(String.format("http://localhost:%s%s",PORT,BASEURI));
 
  41                 public void doTest() {
 
  42                         String[] methods=new String[] {"GET","POST","PUT","DELETE"};
 
  43                         Map<String, String> headers=new HashMap<String,String>();
 
  44                         headers.put("Content-Type","application/json");
 
  45                         headers.put("Authorization",BaseHTTPClient.getAuthorizationHeaderValue("admin","admin"));
 
  46                         for(String method:methods) {
 
  48                                         this.sendRequest(String.format("%s%s", BASEURI,"/abc"), method, "abddef", headers);
 
  49                                 } catch (IOException e) {
 
  51                                         fail(String.format("problem with method %s: %s",method,e.getMessage()));
 
  58                 TestBaseHTTPClient client = new TestBaseHTTPClient();
 
  64         public void init() throws IOException{  
 
  65                 HelpServletBase.initEsTestWebserver(PORT);
 
  68         public void deinit() {
 
  69                 HelpServletBase.stopTestWebserver();