diff options
Diffstat (limited to 'sshapi-call-node/provider/src/test')
9 files changed, 0 insertions, 1225 deletions
diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java deleted file mode 100644 index 78f20e327..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestJsonParser.java +++ /dev/null @@ -1,85 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.codehaus.jettison.json.JSONException; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.sshapicall.model.JsonParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestJsonParser { - - private static final Logger log = LoggerFactory.getLogger(TestJsonParser.class); - - @Test - public void test() throws SvcLogicException, IOException { - BufferedReader in = new BufferedReader( - new InputStreamReader(ClassLoader.getSystemResourceAsStream("test.json")) - ); - StringBuilder b = new StringBuilder(); - String line; - while ((line = in.readLine()) != null) - b.append(line).append('\n'); - Map<String, String> mm = null; - try { - mm = JsonParser.convertToProperties(b.toString()); - } catch (JSONException e){ - throw new SvcLogicException(e.getMessage()); - } - - logProperties(mm); - - in.close(); - } - - @Test(expected = NullPointerException.class) - public void testNullString() throws SvcLogicException { - Map<String, String> mm = null; - try { - mm = JsonParser.convertToProperties(null); - } catch (JSONException e){ - throw new SvcLogicException(e.getMessage()); - } - } - - private void logProperties(Map<String, String> mm) { - List<String> ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); - log.info("Properties:"); - for (String name : ll) - log.info("--- {}: {}", name, mm.get(name)); - } -} diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java deleted file mode 100644 index c0bcdb82a..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestSshApiCallNode.java +++ /dev/null @@ -1,330 +0,0 @@ -package jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.sshapicall.SshApiCallNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - -public class TestSshApiCallNode { - - private static final Logger log = LoggerFactory.getLogger(TestSshApiCallNode.class); - - private SshApiCallNode adapter; - private String TestId; - private boolean testMode = true; - private Map<String, String> params; - private SvcLogicContext svcContext; - - - @Before - public void setup() throws IllegalArgumentException { - testMode = true; - svcContext = new SvcLogicContext(); - adapter = new SshApiCallNode(); - - params = new HashMap<>(); - params.put("AgentUrl", "https://192.168.1.1"); - params.put("User", "test"); - params.put("Password", "test"); - } - - @After - public void tearDown() { - testMode = false; - adapter = null; - params = null; - svcContext = null; - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noUrlFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("HostName", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noPortFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Test", "fail"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommand_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execCommand(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandPty_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execCommandWithPty(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noCmdFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHBasicFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "basic"); - params.put("Cmd", "test"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHKeyFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "key"); - params.put("Cmd", "test"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHNoneFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("AuthType", "none"); - params.put("Cmd", "test"); - params.put("ResponseType", "xml"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_noSSHFailed() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "json"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = IllegalArgumentException.class) - public void testExecCommandResponse_noSSHInvalidParam() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "txt"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = IllegalArgumentException.class) - public void testExecCommandResponse_noSSHInvalidAuthParam() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "spring"); - params.put("ResponseType", "json"); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test - public void testExecCommandResponse_validJSON() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "json"); - params.put("TestOut", "{\"equipment-data\":\"boo\"}"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("boo", svcContext.getAttribute("equipment-data")); - } - - @Test - public void testExecCommandResponse_validXML() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "<modelVersion>4.0.0</modelVersion>"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("modelVersion")); - } - - @Test - public void testExecCommandResponse_validJSONPrefix() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "json"); - params.put("TestOut", "{\"equipment-data\":\"boo\"}"); - params.put("ResponsePrefix", "test"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("boo", svcContext.getAttribute("test.equipment-data")); - } - - @Test - public void testExecCommandResponse_validXMLPrefix() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "<modelVersion>4.0.0</modelVersion>"); - params.put("ResponsePrefix", "test"); - params.put("TestFail", "false"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_validXMLFail() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - - params.put("Url", "test"); - params.put("Port", "10"); - params.put("User", "test"); - params.put("Password", "test"); - params.put("Cmd", "test"); - params.put("AuthType", "basic"); - params.put("ResponseType", "xml"); - params.put("TestOut", "<modelVersion>4.0.0</modelVersion>"); - params.put("TestFail", "true"); - params.put("ResponsePrefix", "test"); - adapter = new SshApiCallNode(true); - adapter.execWithStatusCheck(params, svcContext); - } - - @Test(expected = SvcLogicException.class) - public void testExecCommandResponse_validXMLPrefixKey() throws SvcLogicException, - IllegalStateException, IllegalArgumentException { - params = new HashMap<>(); - params.put("Url", "test"); - params.put("Port", "10"); - params.put("SshKey", "test"); - params.put("Cmd", "test"); - params.put("ResponseType", "xml"); - params.put("TestOut", "<modelVersion>4.0.0</modelVersion>"); - params.put("ResponsePrefix", "test"); - adapter.execWithStatusCheck(params, svcContext); - assertEquals("4.0.0", svcContext.getAttribute("test.modelVersion")); - } -} diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java deleted file mode 100644 index 33e0f24dd..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlJsonUtil.java +++ /dev/null @@ -1,264 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlJsonUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class TestXmlJsonUtil { - - private static final Logger log = LoggerFactory.getLogger(TestXmlJsonUtil.class); - - @Test - public void test() { - Map<String, String> mm = new HashMap<>(); - mm.put("service-data.vnf-config-parameters-list.vnf-config-parameters[0].vnf-type", "N-SBG"); - mm.put("service-data.service-information.service-instance-id", "someinstance001"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].dns-server-ip-address", "10.11.12.13"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].escf-domain-name", "hclab.atttest.com"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3_length", "2"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[0].snmp-target-v3-id", "1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[0].snmp-target-ip-address", "127.0.0.1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[0].snmp-security-level", "NO_AUTH_NO_PRIV"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[1].snmp-target-v3-id", "2"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[1].snmp-target-ip-address", "192.168.1.8"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].snmp-target-v3[1].snmp-security-level", "NO_AUTH_NO_PRIV"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].dns-ip-address-1", "2001:1890:1001:2224::1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].dns-ip-address-2", "2001:1890:1001:2424::1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].diameter-rf-realm-name", "uvp.els-an.att.net"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].diameter-rf-peer-ip-address", "192.168.1.66"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].bgf-controller-ip-address", "192.168.1.186"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].bgf-control-link-name", "mg3/69@192.168.1.226"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].rf-interface-nexthop-ip-address", "10.111.108.150"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].rf-mated-pair-ip-address", "10.111.108.146"); - - mm.put("service-data.vnf-config-parameters-list.vnf-config-parameters[0].access-net-pcscf_length", "4"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[0].network-name", "UvpbUgnAccess1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[0].sip-pa-termination-ip-address", "10.111.108.146"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[1].network-name", "MIS"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[1].proactive-transcoding-profile", - "trinity-transcodingProfile"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[1].next-hop-ip-address", "10.111.108.158"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[1].subnet-mask-length", "10.111.108.154"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[2].network-name", "AVPN1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[2].proactive-transcoding-profile", - "trinity-transcodingProfile"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[2].next-hop-ip-address", "10.111.108.166"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[2].subnet-mask-length", "10.111.108.162"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[3].network-name", "AVPN1"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[3].proactive-transcoding-profile", - "trinity-transcodingProfile"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[3].next-hop-ip-address", "10.129.108.166"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].access-net-pcscf[3].subnet-mask-length", "10.129.108.162"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].core-net-pcscf_length", "1"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].core-net-pcscf[0].network-name", "Core"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].core-net-pcscf[0].next-hop-ip-address", "10.111.108.142"); - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].core-net-pcscf[0].sip-pa-termination-ip-address", "10.111.108.138"); - - mm.put("service-data.vnf-config-parameters-list." + - "vnf-config-parameters[0].mated-pair-fully-qualified-domain-name", - "mt1nj01sbg01pyl-mt1nj01sbg02pyl.ar1ga.uvp.els-an.att.net"); - - mm.put("service-data.appc-request-header.svc-request-id", "SOMESERVICEREQUEST123451000"); - mm.put("service-data.vnf-config-information.vnf-host-ip-address", "192.168.13.151"); - mm.put("service-data.vnf-config-information.vendor", "Netconf"); - - mm.put("service-data.vnf-config-information.escape-test", - "blah blah \"xxx&nnn<>\\'\"there>blah<&''\"\"123\\\\\\'''blah blah &"); - - String ss = XmlJsonUtil.getXml(mm, "service-data.vnf-config-parameters-list"); - log.info(ss); - - ss = XmlJsonUtil.getXml(mm, "service-data.vnf-config-information"); - log.info(ss); - - ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-parameters-list.vnf-config-parameters"); - log.info(ss); - - ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-information"); - log.info(ss); - - ss = XmlJsonUtil.getJson(mm, "service-data.vnf-config-information.vnf-host-ip-address"); - log.info(ss); - - ss = XmlJsonUtil.getJson(mm, "\"service-data.vnf-config-information.vnf-host-ip-address"); - log.info(ss); - } - - @Test - public void testRemoveEmptyStructXml() { - String xmlin = "" + - "<T1>\n" + - " <T2>\n" + - " <T3>\n" + - " <T4></T4>\n" + - " <T5> </T5>\n" + - " <T6>\n" + - " </T6>\n" + - " </T3>\n" + - " <T7>blah</T7>\n" + - " </T2>\n" + - " <T8>\n" + - " <T9>\n" + - " <T10></T10>\n" + - " <T11> </T11>\n" + - " <T12>\n" + - " </T12>\n" + - " </T9>\n" + - " <T13>\n" + - " <T14></T14>\n" + - " <T15> </T15>\n" + - " <T16>\n" + - " <T17></T17>\n" + - " </T16>\n" + - " </T13>\n" + - " <T17>\n" + - " </T17>\n" + - " </T8>\n" + - " <T18>blah blah</T18>\n" + - "</T1>\n"; - - String xmloutexpected = "" + - "<T1>\n" + - " <T2>\n" + - " <T7>blah</T7>\n" + - " </T2>\n" + - " <T18>blah blah</T18>\n" + - "</T1>\n"; - - String xmlout = XmlJsonUtil.removeEmptyStructXml(xmlin); - log.info(xmlout); - - Assert.assertEquals(xmloutexpected, xmlout); - } - - @Test - public void testRemoveEmptyStructJson() { - String xmlin = "{\r\n" + - " \"T1\":{\r\n" + - " \"T2\":{\r\n" + - " \"T3\":[\r\n" + - " \r\n" + - " ],\r\n" + - " \"T4\":{\r\n" + - " \"T12\":[\r\n" + - " \r\n" + - " ],\r\n" + - " \"T13\":[ ],\r\n" + - " \"T14\":{\r\n" + - " \"T15\":{\r\n" + - " \r\n" + - " },\r\n" + - " \"T16\":{\r\n" + - " \r\n" + - " }\r\n" + - " }\r\n" + - " },\r\n" + - " \"T5\":{\r\n" + - " \"T6\":[\r\n" + - " \r\n" + - " ],\r\n" + - " \"T7\":[\r\n" + - " \"T8\":{\r\n" + - " \r\n" + - " },\r\n" + - " \"T9\":{ },\r\n" + - " \"T10\":\"blah\",\r\n" + - " \"T11\":[\r\n" + - " \r\n" + - " ]\r\n" + - " ]\r\n" + - " }\r\n" + - " }\r\n" + - " }\r\n" + - "}\r\n" + - ""; - - String xmloutexpected = "{\r\n" + - " \"T1\":{\r\n" + - " \"T2\":{\r\n" + - " \"T5\":{\r\n" + - " \"T7\":[\r\n" + - " \"T10\":\"blah\",\r\n" + - " ]\r\n" + - " }\r\n" + - " }\r\n" + - " }\r\n" + - "}\r\n" + - ""; - - String xmlout = XmlJsonUtil.removeEmptyStructJson(xmlin); - log.info(xmlout); - - Assert.assertEquals(xmloutexpected, xmlout); - } -} diff --git a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java b/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java deleted file mode 100644 index ba0ae41de..000000000 --- a/sshapi-call-node/provider/src/test/java/jtest/org/onap/ccsdk/sli/plugins/restapicall/TestXmlParser.java +++ /dev/null @@ -1,123 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package jtest.org.onap.ccsdk.sli.plugins.restapicall; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.core.Is.is; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.plugins.sshapicall.model.XmlParser; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestXmlParser { - - private static final Logger log = LoggerFactory.getLogger(TestXmlParser.class); - - @Test - public void test() throws Exception { - BufferedReader in = new BufferedReader( - new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml")) - ); - StringBuilder b = new StringBuilder(); - String line; - while ((line = in.readLine()) != null) - b.append(line).append('\n'); - - Set<String> listNameList = new HashSet<String>(); - listNameList.add("project.dependencies.dependency"); - listNameList.add("project.build.plugins.plugin"); - listNameList.add("project.build.plugins.plugin.executions.execution"); - listNameList.add("project.build.pluginManagement.plugins.plugin"); - listNameList.add("project.build.pluginManagement." + - "plugins.plugin.configuration.lifecycleMappingMetadata.pluginExecutions.pluginExecution"); - - Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - @Test - public void testValidLength() throws Exception { - BufferedReader in = new BufferedReader( - new InputStreamReader(ClassLoader.getSystemResourceAsStream("test3.xml")) - ); - StringBuilder b = new StringBuilder(); - String line; - while ((line = in.readLine()) != null) - b.append(line).append('\n'); - - Set<String> listNameList = new HashSet<String>(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList); - - assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport[5]"), is("SET_RESET_LP")); - assertThat(mm.get("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport[0]"), is("SET_BVOIP_IN")); - - logProperties(mm); - in.close(); - } - - @Test(expected = SvcLogicException.class) - public void testInvalidLength() throws Exception { - BufferedReader in = new BufferedReader( - new InputStreamReader(ClassLoader.getSystemResourceAsStream("invalidlength.xml")) - ); - StringBuilder b = new StringBuilder(); - String line; - while ((line = in.readLine()) != null) - b.append(line).append('\n'); - - Set<String> listNameList = new HashSet<String>(); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfImport"); - listNameList.add("ApplyGroupResponse.ApplyGroupResponseData.VrfDetails.VrfExport"); - - Map<String, String> mm = XmlParser.convertToProperties(b.toString(), listNameList); - logProperties(mm); - in.close(); - } - - private void logProperties(Map<String, String> mm) { - List<String> ll = new ArrayList<>(); - for (Object o : mm.keySet()) - ll.add((String) o); - Collections.sort(ll); - - log.info("Properties:"); - for (String name : ll) - log.info("--- " + name + ": " + mm.get(name)); - } -} diff --git a/sshapi-call-node/provider/src/test/resources/invalidlength.xml b/sshapi-call-node/provider/src/test/resources/invalidlength.xml deleted file mode 100644 index b71f6391f..000000000 --- a/sshapi-call-node/provider/src/test/resources/invalidlength.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - Copyright (C) 2018 Samsung Electronics. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1" - xmlns:ns2="http://onap.org/prov/vpn/schema/v2"> - <ApplyGroupResponseData> - <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId> - <VrfDetails> - <End2EndVpnKey>VPNL811182</End2EndVpnKey> - <VpnId>811182</VpnId> - <VrfName>21302:811182</VrfName> - <VrfImport>SET_BVOIP_IN</VrfImport> - <VrfImport>SET6_BVOIP_IN</VrfImport> - <VrfExport_length>a</VrfExport_length> - <VrfExport>SET6_DSU</VrfExport> - <VrfExport>SET_DSU</VrfExport> - <VrfExport>SET6_MANAGED</VrfExport> - <VrfExport>SET_MANAGED</VrfExport> - <VrfExport>SET_LOVRF_COMMUNITY</VrfExport> - <VrfExport>SET_RESET_LP</VrfExport> - <ApplyGroup> - <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup> - </ApplyGroup> - </VrfDetails> - </ApplyGroupResponseData> - <response-code>200</response-code> - <response-message>Success</response-message> - <ack-final-indicator>Y</ack-final-indicator> -</ApplyGroupResponse> - diff --git a/sshapi-call-node/provider/src/test/resources/test-template.json b/sshapi-call-node/provider/src/test/resources/test-template.json deleted file mode 100644 index cd5e74699..000000000 --- a/sshapi-call-node/provider/src/test/resources/test-template.json +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -{ - "sdn-circuit-request": [ - ${repeat:tmp.sdn-circuit-req-row_length: - { - "request-id": ${tmp.sdn-circuit-req-row[${1}].request-id}, - "source-uid": ${tmp.sdn-circuit-req-row[${1}].source-uid}, - "action": ${tmp.sdn-circuit-req-row[${1}].action}, - "request-timestamp": ${tmp.sdn-circuit-req-row[${1}].request-timestamp}, - "update-timestamp": ${tmp.sdn-circuit-req-row[${1}].update-timestamp}, - "request-status": ${tmp.sdn-circuit-req-row[${1}].request-status}, - "processing-status": ${tmp.sdn-circuit-req-row[${1}].processing-status}, - "reason-code": ${tmp.sdn-circuit-req-row[${1}].reason-code}, - "reason-message": ${tmp.sdn-circuit-req-row[${1}].reason-message}, - "customer-code": ${tmp.sdn-circuit-req-row[${1}].customer-code}, - "bundle-id": ${tmp.sdn-circuit-req-row[${1}].bundle-id}, - "router-name-1": ${tmp.sdn-circuit-req-row[${1}].router-name-1}, - "tail-clfi-1": ${tmp.sdn-circuit-req-row[${1}].tail-clfi-1}, - "srg-1": ${tmp.sdn-circuit-req-row[${1}].srg-1}, - "router-name-2": ${tmp.sdn-circuit-req-row[${1}].router-name-2}, - "tail-clfi-2": ${tmp.sdn-circuit-req-row[${1}].tail-clfi-2}, - "srg-2": ${tmp.sdn-circuit-req-row[${1}].srg-2}, - "facility-speed": ${tmp.sdn-circuit-req-row[${1}].facility-speed}, - "facility-speed-units": ${tmp.sdn-circuit-req-row[${1}].facility-speed-units}, - "facility-type": ${tmp.sdn-circuit-req-row[${1}].facility-type}, - "service-clfi": ${tmp.sdn-circuit-req-row[${1}].service-clfi}, - "clci": ${tmp.sdn-circuit-req-row[${1}].clci}, - "wavelength-purpose": ${tmp.sdn-circuit-req-row[${1}].wavelength-purpose}, - "activate-setting": ${tmp.sdn-circuit-req-row[${1}].activate-setting}, - "apply-date": ${tmp.sdn-circuit-req-row[${1}].apply-date}, - "run-id": ${tmp.sdn-circuit-req-row[${1}].run-id}, - "hostname": ${tmp.sdn-circuit-req-row[${1}].hostname}, - "algo-request-reason": ${tmp.sdn-circuit-req-row[${1}].algo-request-reason} - }, - } - ] -} diff --git a/sshapi-call-node/provider/src/test/resources/test.json b/sshapi-call-node/provider/src/test/resources/test.json deleted file mode 100644 index e272d457a..000000000 --- a/sshapi-call-node/provider/src/test/resources/test.json +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -{ - "equipment-data": [ - { - "server-count": "4", - "max-server-speed": "1600000", - "number-primary-servers": "2", - "equipment-id": "Server1", - "server-model": "Unknown", - "server-id": "Server1", - "test-node" : { - "test-inner-node" : "Test-Value" - } - } - ], - "resource-state": { - "threshold-value": "1600000", - "last-added": "1605000", - "used": "1605000", - "limit-value": "1920000" - }, - "resource-rule": { - "endpoint-position": "VCE-Cust", - "soft-limit-expression": "0.6 * max-server-speed * number-primary-servers", - "resource-name": "Bandwidth", - "service-model": "DUMMY", - "hard-limit-expression": "max-server-speed * number-primary-servers", - "equipment-level": "Server" - }, - "message": "The provisioned access bandwidth is at or exceeds 50% of the total server capacity." -} diff --git a/sshapi-call-node/provider/src/test/resources/test.xml b/sshapi-call-node/provider/src/test/resources/test.xml deleted file mode 100644 index 7645f1992..000000000 --- a/sshapi-call-node/provider/src/test/resources/test.xml +++ /dev/null @@ -1,184 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. - * ================================================================================ - * Copyright (C) 2018 Samsung Electronics. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.ccsdk.sli.plugins</groupId> - <artifactId>sshapi-call-node</artifactId> - <version>6.0.0-SNAPSHOT</version> - </parent> - <artifactId>sshapi-call-node-provider</artifactId> - <packaging>bundle</packaging> - <name>SSHAPI Call Node - Provider</name> - <url>http://maven.apache.org</url> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - </properties> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <version>3.1.4.RELEASE</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.sli</groupId> - <artifactId>sli-common</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.onap.ccsdk.sli</groupId> - <artifactId>sli-provider</artifactId> - <scope>compile</scope> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - <version>${slf4j.version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-beans</artifactId> - <version>3.1.4.RELEASE</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>3.1.4.RELEASE</version> - </dependency> - <dependency> - <groupId>xerces</groupId> - <artifactId>xerces</artifactId> - <version>2.4.0</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-client</artifactId> - <version>1.17</version> - </dependency> - <dependency> - <groupId>com.sun.jersey.contribs.jersey-oauth</groupId> - <artifactId>oauth-signature</artifactId> - <version>1.17</version> - </dependency> - <dependency> - <groupId>com.sun.jersey.contribs.jersey-oauth</groupId> - <artifactId>oauth-client</artifactId> - <version>1.17</version> - </dependency> - <dependency> - <groupId>commons-codec</groupId> - <artifactId>commons-codec</artifactId> - </dependency> - </dependencies> - - <build> - <plugins> - <plugin> - <groupId>com.brocade.developer</groupId> - <artifactId>providermodule-plugin</artifactId> - <configuration> - <packageId>org.onap.ccsdk.sli.plugins</packageId> - <appName>sshapi-call-node</appName> - </configuration> - <executions> - <execution> - <phase>process-sources</phase> - <goals> - <goal>process</goal> - </goals> - </execution> - </executions> - </plugin> - - - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Bundle-SymbolicName>org.onap.ccsdk.sli.plugins.sshapicall</Bundle-SymbolicName> - <Export-Package>org.onap.ccsdk.sli.plugins.sshapicall</Export-Package> - <Import-Package>*</Import-Package> - </instructions> - - <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation> - - </configuration> - - </plugin> - - - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings - only. It has no influence on the Maven build itself. --> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - com.brocade.developer - </groupId> - <artifactId> - providermodule-plugin - </artifactId> - <versionRange> - [1.2.0.100-SNAPSHOT,) - </versionRange> - <goals> - <goal>process</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> -</project> diff --git a/sshapi-call-node/provider/src/test/resources/test3.xml b/sshapi-call-node/provider/src/test/resources/test3.xml deleted file mode 100644 index 52a7a7d98..000000000 --- a/sshapi-call-node/provider/src/test/resources/test3.xml +++ /dev/null @@ -1,82 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - Copyright (C) 2018 Samsung Electronics. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<ApplyGroupResponse xmlns="http://onap.org/vpn/schema/v1" - xmlns:ns2="http://onap.org/prov/vpn/schema/v2"> - <ApplyGroupResponseData> - <ServiceInstanceId>ICOREPVC-81114561</ServiceInstanceId> - <VrfDetails> - <End2EndVpnKey>VPNL811182</End2EndVpnKey> - <VpnId>811182</VpnId> - <VrfName>21302:811182</VrfName> - <VrfImport>SET_BVOIP_IN</VrfImport> - <VrfImport>SET6_BVOIP_IN</VrfImport> - <VrfExport>SET6_DSU</VrfExport> - <VrfExport>SET_DSU</VrfExport> - <VrfExport>SET6_MANAGED</VrfExport> - <VrfExport>SET_MANAGED</VrfExport> - <VrfExport>SET_LOVRF_COMMUNITY</VrfExport> - <VrfExport>SET_RESET_LP</VrfExport> - <ApplyGroup> - <ns2:ApplyGroup>AG_MAX_MCASTROUTES</ns2:ApplyGroup> - </ApplyGroup> - </VrfDetails> - <RoutingApplyGroups> - <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol> - <Family>v4</Family> - <PeerGroupName>gp_21302:811182</PeerGroupName> - <ApplyGroupPeer> - <ns2:ApplyGroup>AG_L3VPN_EBGP</ns2:ApplyGroup> - </ApplyGroupPeer> - <ApplyGroupPeer> - <ns2:ApplyGroup>AG_MAX_PREFIX</ns2:ApplyGroup> - </ApplyGroupPeer> - <ApplyGroupNeighbour> - <ns2:ApplyGroup>AG_BGP_UNMANAGED</ns2:ApplyGroup> - </ApplyGroupNeighbour> - <ApplyGroupNeighbour> - <ns2:ApplyGroup>AG_BFD_BGP_3000</ns2:ApplyGroup> - </ApplyGroupNeighbour> - </RoutingApplyGroups> - <RoutingApplyGroups> - <RoutingProtocol>BGP4_PROTOCOL</RoutingProtocol> - <Family>v6</Family> - <PeerGroupName>gp6_21302:811182</PeerGroupName> - <ApplyGroupPeer> - <ns2:ApplyGroup>AG6_L3VPN_EBGP</ns2:ApplyGroup> - </ApplyGroupPeer> - <ApplyGroupPeer> - <ns2:ApplyGroup>AG6_MAX_PREFIX</ns2:ApplyGroup> - </ApplyGroupPeer> - <ApplyGroupNeighbour> - <ns2:ApplyGroup>AG6_BGP_UNMANAGED</ns2:ApplyGroup> - </ApplyGroupNeighbour> - <ApplyGroupNeighbour> - <ns2:ApplyGroup>AG6_BFD_BGP_3000</ns2:ApplyGroup> - </ApplyGroupNeighbour> - </RoutingApplyGroups> - </ApplyGroupResponseData> - <response-code>200</response-code> - <response-message>Success</response-message> - <ack-final-indicator>Y</ack-final-indicator> -</ApplyGroupResponse> - |