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.openo.nfvo.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.openo.nfvo.vnfmadapter.common.VnfmException;
28 public class HttpRequestsTest {
30 String authenticateMode = "test";
31 HttpRequests.Builder builder = new HttpRequests.Builder(authenticateMode);
34 public void addHeaderTest(){
35 builder.addHeader("id", "1234");
39 public void addHeadersTest(){
40 Header header = new Header();
41 builder.addHeaders(header, header);
42 assertNotNull(builder);
45 public void addHeadersListTest(){
46 List<Header> list = new ArrayList<>();
47 Header header = new Header();
49 builder.addHeaders(list);
50 assertNotNull(builder);
53 @Test(expected = VnfmException.class)
54 public void setUrlTestException() throws VnfmException{
57 builder.setUrl(url, path);
59 @Test(expected = VnfmException.class)
60 public void setUrlTestException2() throws VnfmException{
63 builder.setUrl(url, path);
66 @Test(expected = VnfmException.class)
67 public void setUrlTestNormal() throws VnfmException{
68 String url="/test/123";
69 String path="http://localhost:8080";
70 builder.setUrl(url, path);
73 @Test(expected = VnfmException.class)
74 public void setUrl2TestException() throws VnfmException{
77 builder.setUrl(url, path,101);
79 @Test(expected = VnfmException.class)
80 public void setUrl2TestException2() throws VnfmException{
83 builder.setUrl(url, path,101);
86 @Test(expected = VnfmException.class)
87 public void setUrl2TestNormal() throws VnfmException{
88 String url="/test/123";
89 String path="http://localhost:8080";
90 builder.setUrl(url, path,101);
92 @Test(expected = Exception.class)
93 public void requestTestException(){
94 String res = builder.request();