2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.plugins.grtoolkit.connection;
24 import com.github.tomakehurst.wiremock.junit.WireMockRule;
26 import org.junit.Rule;
27 import org.junit.Test;
29 import static org.junit.Assert.*;
31 import static com.github.tomakehurst.wiremock.client.WireMock.*;
33 public class ConnectionManagerTest {
35 public WireMockRule wireMockRule = new WireMockRule(9999);
38 public void getConnectionResponseWithInput() throws Exception {
39 stubFor(post(urlEqualTo("/post"))
40 .willReturn(aResponse().withStatus(200)));
41 ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/post", ConnectionManager.HttpMethod.POST, "", "creds:creds");
42 assertNotNull(response);
43 assertEquals(200, response.statusCode);
47 public void getConnectionResponseWithCredentials() throws Exception {
48 stubFor(post(urlEqualTo("/post"))
49 .willReturn(aResponse().withStatus(200)));
50 ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/post", ConnectionManager.HttpMethod.POST, "", "creds:creds");
51 assertNotNull(response);
52 assertEquals(200, response.statusCode);
56 public void getConnectionResponse() throws Exception {
57 stubFor(get(urlEqualTo("/get"))
58 .willReturn(aResponse().withStatus(200)
59 .withBody("Multi\nLine\nResponse")));
60 ConnectionResponse response = ConnectionManager.getConnectionResponse("http://localhost:9999/get", ConnectionManager.HttpMethod.GET, null, null);
61 assertNotNull(response);
62 assertEquals(200, response.statusCode);
63 assertEquals("MultiLineResponse", response.content);