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.common;
19 import static org.junit.Assert.assertNotNull;
20 import static org.junit.Assert.assertTrue;
22 import org.junit.Test;
23 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.constant.Constant;
24 import org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.service.csm.connect.ConnectMgrVnfm;
28 import net.sf.json.JSONObject;
30 public class ResultRequestUtilTest {
33 public void callTestInternalError() {
34 // new MockUp<ConnectMgrVnfm>() {
37 // public int connect(JSONObject vnfmObj) {
43 JSONObject vnfmObject = new JSONObject();
44 String path = "http://localhost:8080";
45 String methodName = "get";
46 String paramsJson = "";
47 vnfmObject.put("url", path);
48 vnfmObject.put(Constant.USERNAME, Constant.USERNAME);
49 vnfmObject.put(Constant.PASSWORD, Constant.PASSWORD);
50 JSONObject resp = ResultRequestUtil.call(vnfmObject, path, methodName, paramsJson);
51 assertTrue(resp.get("data").equals("connect fail."));
55 public void callTestConnectionErrot() {
56 // new MockUp<ConnectMgrVnfm>() {
59 // public int connect(JSONObject vnfmObj) {
63 JSONObject vnfmObject = new JSONObject();
64 vnfmObject.put("url", "/test/123");
65 String path = "http://localhost:8080";
66 String methodName = "get";
67 String paramsJson = "";
68 JSONObject resp = ResultRequestUtil.call(vnfmObject, path, methodName, paramsJson);
69 assertTrue(resp.get("data").equals("get connection error"));
73 public void callTest() {
74 // new MockUp<ConnectMgrVnfm>() {
77 // public int connect(JSONObject vnfmObj) {
82 // public String getRoaRand() {
87 // public String getAccessSession() {
93 JSONObject vnfmObject = new JSONObject();
94 vnfmObject.put("url", "/test/123");
95 String path = "https://localhost:8080/%s";
96 String methodName = "get";
97 String paramsJson = "";
98 JSONObject resp = ResultRequestUtil.call(vnfmObject, path, methodName, paramsJson);
99 assertTrue(resp.get("data").equals("get connection error"));
106 JSONObject vnfmObject = new JSONObject();
107 vnfmObject.put("url","https://localhost:8080/%s" );
108 vnfmObject.put(Constant.USERNAME, Constant.USERNAME);
109 vnfmObject.put(Constant.PASSWORD, Constant.PASSWORD);
110 String path = "https://localhost:8080/%s";
111 String methodName = "get";
112 String paramsJson = "";
113 assertNotNull(ResultRequestUtil.call( vnfmObject, path, methodName, paramsJson,
119 public void callSouth() {
120 JSONObject vnfmObject = new JSONObject();
121 vnfmObject.put("url", "https://localhost:8080/%s");
122 vnfmObject.put(Constant.USERNAME, Constant.USERNAME);
123 vnfmObject.put(Constant.PASSWORD, Constant.PASSWORD);
124 String path = "https://localhost:8080/%s";
125 String methodName = "get";
126 String paramsJson = "";
127 assertNotNull(ResultRequestUtil.callSouth(vnfmObject, path, methodName, paramsJson, "authModel"));