6901d24b883ed6ebf34737fe39c2594e9e2f7a5a
[appc.git] / appc-outbound / appc-network-inventory-client / provider / src / test / java / org / openecomp / appc / instar / node / TestInstarClientNode.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.instar.node;
26
27 import java.net.URI;
28 import java.nio.charset.Charset;
29 import java.util.HashMap;
30 import java.util.Map;
31 import javax.net.ssl.HostnameVerifier;
32 import javax.net.ssl.SSLContext;
33 import javax.ws.rs.HttpMethod;
34
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.openecomp.appc.instar.dme2client.SecureRestClientTrustManager;
40 import org.openecomp.appc.instar.utils.InstarClientConstant;
41 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
42
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;
48
49
50 public class TestInstarClientNode {
51     
52     //ONAP Migration
53
54     @Test(expected=Exception.class)
55     public void testInstarClientNode() throws Exception {
56     
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");
69     }
70     @Test(expected=Exception.class)
71     public void testInstarData() throws Exception {
72         
73         InstarClientNode inNode = new InstarClientNode();
74          SvcLogicContext ctx  = new SvcLogicContext ();
75          Map<String, String> inParams = new HashMap<String, String>();
76
77          inParams.put(InstarClientConstant.VNF_NAME, "basx0003v");
78          inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);         
79          inNode.getInstarData(inParams, ctx);
80          
81
82     }
83 }