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.*;
21 import java.util.ArrayList;
22 import java.util.List;
24 import org.apache.commons.httpclient.Header;
25 import org.junit.Test;
26 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.VnfmException;
27 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.HttpRequests;
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");
40 public void addHeadersTest(){
41 Header header = new Header();
42 builder.addHeaders(header, header);
43 assertNotNull(builder);
46 public void addHeadersListTest(){
47 List<Header> list = new ArrayList<>();
48 Header header = new Header();
50 builder.addHeaders(list);
51 assertNotNull(builder);
54 @Test(expected = VnfmException.class)
55 public void setUrlTestException() throws VnfmException{
58 builder.setUrl(url, path);
60 @Test(expected = VnfmException.class)
61 public void setUrlTestException2() throws VnfmException{
64 builder.setUrl(url, path);
67 @Test(expected = VnfmException.class)
68 public void setUrlTestNormal() throws VnfmException{
69 String url="/test/123";
70 String path="http://localhost:8080";
71 builder.setUrl(url, path);
74 @Test(expected = VnfmException.class)
75 public void setUrl2TestException() throws VnfmException{
78 builder.setUrl(url, path,101);
80 @Test(expected = VnfmException.class)
81 public void setUrl2TestException2() throws VnfmException{
84 builder.setUrl(url, path,101);
87 @Test(expected = VnfmException.class)
88 public void setUrl2TestNormal() throws VnfmException{
89 String url="/test/123";
90 String path="http://localhost:8080";
91 builder.setUrl(url, path,101);
93 @Test(expected = Exception.class)
94 public void requestTestException(){
95 String res = builder.request();