2 * Copyright 2016 Huawei Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.apache.commons.httpclient.Header;
26 import org.junit.Test;
27 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException;
29 public class HttpRequestsTest {
31 String authenticateMode = "test";
32 HttpRequests.Builder builder = new HttpRequests.Builder(authenticateMode);
35 public void addHeaderTest() {
36 builder.addHeader("id", "1234");
41 public void addHeadersTest() {
42 Header header = new Header();
43 builder.addHeaders(header, header);
44 assertNotNull(builder);
48 public void addHeadersListTest() {
49 List<Header> list = new ArrayList<>();
50 Header header = new Header();
52 builder.addHeaders(list);
53 assertNotNull(builder);
56 @Test(expected = VnfmException.class)
57 public void setUrlTestException() throws VnfmException {
60 builder.setUrl(url, path);
63 @Test(expected = VnfmException.class)
64 public void setUrlTestException2() throws VnfmException {
67 builder.setUrl(url, path);
70 @Test(expected = VnfmException.class)
71 public void setUrlTestNormal() throws VnfmException {
72 String url = "/test/123";
73 String path = "http://localhost:8080";
74 builder.setUrl(url, path);
77 @Test(expected = VnfmException.class)
78 public void setUrl2TestException() throws VnfmException {
81 builder.setUrl(url, path, 101);
84 @Test(expected = VnfmException.class)
85 public void setUrl2TestException2() throws VnfmException {
88 builder.setUrl(url, path, 101);
91 @Test(expected = VnfmException.class)
92 public void setUrl2TestNormal() throws VnfmException {
93 String url = "/test/123";
94 String path = "http://localhost:8080";
95 builder.setUrl(url, path, 101);
98 @Test(expected = Exception.class)
99 public void requestTestException() {
100 String res = builder.request();
105 public void postTest() throws VnfmException {
106 assertNotNull(builder.post());
110 public void putTest() throws VnfmException {
111 assertNotNull(builder.put());
115 public void getTest() throws VnfmException {
116 assertNotNull(builder.get());
120 public void deleteTest() throws VnfmException {
121 assertNotNull(builder.delete());
125 public void setParamsTest() throws VnfmException {
126 String json = "test";
127 assertNotNull(builder.setParams(json));
131 public void setEncodingTest() throws VnfmException {
132 String json = "test";
133 assertNotNull(builder.setEncoding(json));