2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.instar.node;
28 import java.nio.charset.Charset;
29 import java.util.HashMap;
31 import javax.net.ssl.HostnameVerifier;
32 import javax.net.ssl.SSLContext;
33 import javax.ws.rs.HttpMethod;
35 import org.apache.commons.io.IOUtils;
36 import org.json.JSONObject;
37 import org.junit.Assert;
38 import org.junit.Test;
39 import org.onap.appc.instar.dme2client.SecureRestClientTrustManager;
40 import org.onap.appc.instar.utils.InstarClientConstant;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
43 import com.sun.jersey.api.client.Client;
44 import com.sun.jersey.api.client.ClientResponse;
45 import com.sun.jersey.api.client.WebResource;
46 import com.sun.jersey.api.client.config.DefaultClientConfig;
47 import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
50 public class TestInstarClientNode {
54 @Test(expected=Exception.class)
55 public void testInstarClientNode() throws Exception {
57 SvcLogicContext ctx = new SvcLogicContext();
58 String key_conetent = IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("templates/sampleKeyContents"), Charset.defaultCharset());
59 Map<String, String> inParams = new HashMap<String, String>();
60 inParams.put(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
61 inParams.put(InstarClientConstant.INSTAR_KEYS, "LOCAL_ACCESS_IP_ADDR");
62 inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
63 ctx.setAttribute("INSTAR.LOCAL_ACCESS_IP_ADDR", key_conetent);
64 ctx.setAttribute(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX, "TEST");
65 ctx.setAttribute(InstarClientConstant.VNF_NAME, "basx0003v");
66 InstarClientNode icn = new InstarClientNode();
67 icn.getInstarInfo(inParams, ctx);
68 String address = (new JSONObject(ctx.getAttribute("TEST." + InstarClientConstant.INSTAR_KEY_VALUES))).getString("LOCAL_ACCESS_IP_ADDR");
70 @Test(expected=Exception.class)
71 public void testInstarData() throws Exception {
73 InstarClientNode inNode = new InstarClientNode();
74 SvcLogicContext ctx = new SvcLogicContext ();
75 Map<String, String> inParams = new HashMap<String, String>();
77 inParams.put(InstarClientConstant.VNF_NAME, "basx0003v");
78 inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
79 inNode.getInstarData(inParams, ctx);