From 161df8a94bb3b0c34ed16fd4fdba078bd1eeef9a Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:14:21 -0800 Subject: Second part of onap rename This is the second commit of the rename. The folder structure is renamed for appc-adapters and appc-config in this commit. Change-Id: Iaa2b8c937ff1ca1b5d1178128961fb115ee65d9b Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../netconf/internal/TestNetconfAdapter.java | 91 ++++++++++++++++++++ .../adapter/netconf/jsch/TestGetRunningConfig.java | 63 ++++++++++++++ .../adapter/netconf/jsch/TestModifyConfig.java | 96 ++++++++++++++++++++++ .../adapter/netconf/jsch/TestModifyConfigMock.java | 96 ++++++++++++++++++++++ .../netconf/jsch/TestModifyConfigRouterMock.java | 94 +++++++++++++++++++++ .../netconf/jsch/TestOperationalStates.java | 90 ++++++++++++++++++++ .../netconf/internal/TestNetconfAdapter.java | 91 -------------------- .../adapter/netconf/jsch/TestGetRunningConfig.java | 63 -------------- .../adapter/netconf/jsch/TestModifyConfig.java | 96 ---------------------- .../adapter/netconf/jsch/TestModifyConfigMock.java | 96 ---------------------- .../netconf/jsch/TestModifyConfigRouterMock.java | 94 --------------------- .../netconf/jsch/TestOperationalStates.java | 90 -------------------- 12 files changed, 530 insertions(+), 530 deletions(-) create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfAdapter.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestGetRunningConfig.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfig.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigMock.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java create mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestOperationalStates.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java delete mode 100644 appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java') diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfAdapter.java new file mode 100644 index 000000000..cb20cbdb5 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/internal/TestNetconfAdapter.java @@ -0,0 +1,91 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.internal; + +import org.junit.Assert; +import org.junit.Test; +import org.onap.appc.adapter.netconf.internal.NetconfAdapter; + +import java.io.IOException; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; + +public class TestNetconfAdapter { + + private static final String EOM = "]]>]]>"; + + @Test + public void testReceiveMessage() throws IOException { + PipedOutputStream pos = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(pos); + + PipedInputStream pis = new PipedInputStream(); + PipedOutputStream os = new PipedOutputStream(pis); + + NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); + + String request = "Hello, netconf!"; + pos.write(request.getBytes()); + pos.write(EOM.getBytes()); + String response = netconfAdapter.receiveMessage(); + Assert.assertNotNull(response); + Assert.assertEquals(request, response.trim()); + } + + @Test + public void testSendMessage() throws IOException { + PipedOutputStream pos = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(pos); + + PipedInputStream pis = new PipedInputStream(); + PipedOutputStream os = new PipedOutputStream(pis); + + NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); + + String request = "Hello, netconf!"; + netconfAdapter.sendMessage(request); + byte[] bytes = new byte[request.length()+EOM.length()+2]; + int count = pis.read(bytes); + String response = new String(bytes, 0, count); + Assert.assertNotNull(response); + Assert.assertTrue(response.endsWith(EOM)); + response = response.substring(0, response.length() - EOM.length()).trim(); + Assert.assertEquals(request, response); + } + + @Test + public void testSendReceive() throws IOException { + PipedOutputStream os = new PipedOutputStream(); + PipedInputStream is = new PipedInputStream(os); + + NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); + + String request = "Hello, netconf!"; + netconfAdapter.sendMessage(request); + String response = netconfAdapter.receiveMessage(); + Assert.assertNotNull(response); + Assert.assertEquals(request, response.trim()); + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestGetRunningConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestGetRunningConfig.java new file mode 100644 index 000000000..b559bc749 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestGetRunningConfig.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import java.util.Collections; +import java.util.List; + +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.exceptions.APPCException; + +public class TestGetRunningConfig { + + private static final String HOST = "192.168.1.2"; + private static final String USER = "test"; + private static final String PSWD = "test123"; + private static final int PORT = 830; + private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); + + public static void main(String[] args) throws APPCException { + try { + NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); + connectionDetails.setHost(HOST); + connectionDetails.setPort(PORT); + connectionDetails.setUsername(USER); + connectionDetails.setPassword(PSWD); + connectionDetails.setCapabilities(CAPABILITIES); + NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); + netconfClientJsch.connect(connectionDetails); + try { + System.out.println("=> Running get configuration..."); + String configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + } finally { + netconfClientJsch.disconnect(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfig.java new file mode 100644 index 000000000..809625333 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfig.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import java.util.Collections; +import java.util.List; + +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.exceptions.APPCException; + +public class TestModifyConfig { + + private static final String HOST = "192.168.1.2"; + private static final String USER = "test"; + private static final String PSWD = "test123"; + private static final int PORT = 830; + private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); + private static final String CONFIG = + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " merge\n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " 1\n" + + " \n" + + " 1\n" + + " \n" + + " example.com\n" + + " 60\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + public static void main(String[] args) throws APPCException { + try { + NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); + connectionDetails.setHost(HOST); + connectionDetails.setPort(PORT); + connectionDetails.setUsername(USER); + connectionDetails.setPassword(PSWD); + connectionDetails.setCapabilities(CAPABILITIES); + NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); + netconfClientJsch.connect(connectionDetails); + try { + System.out.println("=> Running get configuration..."); + String configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + + System.out.println("=> Reconfiguring device..."); + String outMessage = netconfClientJsch.exchangeMessage(CONFIG); + System.out.println("=> Reconfiguration response:\n" + outMessage); + + System.out.println("=> Running get configuration..."); + configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + } finally { + netconfClientJsch.disconnect(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigMock.java new file mode 100644 index 000000000..915721d51 --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigMock.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import java.util.Collections; +import java.util.List; + +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.exceptions.APPCException; + +public class TestModifyConfigMock { + + private static final String HOST = "192.168.1.2"; + private static final String USER = "test"; + private static final String PSWD = "test123"; + private static final int PORT = 830; + private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); + private static final String CONFIG = + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " merge\n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " 1\n" + + " \n" + + " 1\n" + + " \n" + + " example.com\n" + + " 60\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + public static void main(String[] args) throws APPCException { + try { + NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); + connectionDetails.setHost(HOST); + connectionDetails.setPort(PORT); + connectionDetails.setUsername(USER); + connectionDetails.setPassword(PSWD); + connectionDetails.setCapabilities(CAPABILITIES); + NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); + netconfClientJsch.connect(connectionDetails); + try { + System.out.println("=> Running get configuration..."); + String configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + + System.out.println("=> Reconfiguring device..."); + String outMessage = netconfClientJsch.exchangeMessage(CONFIG); + System.out.println("=> Reconfiguration response:\n" + outMessage); + + System.out.println("=> Running get configuration..."); + configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + } finally { + netconfClientJsch.disconnect(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java new file mode 100644 index 000000000..83e62bc9f --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import java.util.Collections; +import java.util.List; + +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.exceptions.APPCException; + +public class TestModifyConfigRouterMock { + + private static final String HOST = "10.147.27.50"; // yuma netconf simulator + private static final int PORT = 830; + private static final String USER = "admin"; + private static final String PSWD = "admin"; + private static final List CAPABILITIES = Collections.emptyList(); + private static final String CONFIG = + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " \n" + + " 100.100.100.0/24\n" + + " 10\n" + + " \n" + + " \n" + + " \n" + + " 1000\n" + + " 10.10.1.1\n" + + " \n" + + " 2000\n" + + " 10.10.1.2\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n"; + + public static void main(String[] args) throws APPCException { + try { + NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); + connectionDetails.setHost(HOST); + connectionDetails.setPort(PORT); + connectionDetails.setUsername(USER); + connectionDetails.setPassword(PSWD); + connectionDetails.setCapabilities(CAPABILITIES); + NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); + netconfClientJsch.connect(connectionDetails); + try { + System.out.println("=> Running get configuration..."); + String configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + + System.out.println("=> Reconfiguring device..."); + String outMessage = netconfClientJsch.exchangeMessage(CONFIG); + System.out.println("=> Reconfiguration response:\n" + outMessage); + } finally { + netconfClientJsch.disconnect(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestOperationalStates.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestOperationalStates.java new file mode 100644 index 000000000..263dd5a8f --- /dev/null +++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/onap/appc/adapter/netconf/jsch/TestOperationalStates.java @@ -0,0 +1,90 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.appc.adapter.netconf.jsch; + +import java.util.Collections; +import java.util.List; + +import org.onap.appc.adapter.netconf.NetconfConnectionDetails; +import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; +import org.onap.appc.exceptions.APPCException; + +public class TestOperationalStates { + + private static final String HOST = "192.168.1.2"; + private static final String USER = "test"; + private static final String PSWD = "test123"; + private static final int PORT = 830; + private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); + private static final String GET_OPERATIONAL_STATES = + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + + public static void main(String[] args) throws APPCException { + try { + NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); + connectionDetails.setHost(HOST); + connectionDetails.setPort(PORT); + connectionDetails.setUsername(USER); + connectionDetails.setPassword(PSWD); + connectionDetails.setCapabilities(CAPABILITIES); + NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); + netconfClientJsch.connect(connectionDetails); + try { + System.out.println("=> Running get configuration..."); + String configuration = netconfClientJsch.getConfiguration(); + System.out.println("=> Configuration:\n" + configuration); + + System.out.println("=> Running get operational states..."); + String outMessage = netconfClientJsch.exchangeMessage(GET_OPERATIONAL_STATES); + System.out.println("=> Operational states:\n" + outMessage); + } finally { + netconfClientJsch.disconnect(); + } + } catch(Exception e) { + e.printStackTrace(); + } + } +} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java deleted file mode 100644 index cb20cbdb5..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java +++ /dev/null @@ -1,91 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.internal; - -import org.junit.Assert; -import org.junit.Test; -import org.onap.appc.adapter.netconf.internal.NetconfAdapter; - -import java.io.IOException; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; - -public class TestNetconfAdapter { - - private static final String EOM = "]]>]]>"; - - @Test - public void testReceiveMessage() throws IOException { - PipedOutputStream pos = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(pos); - - PipedInputStream pis = new PipedInputStream(); - PipedOutputStream os = new PipedOutputStream(pis); - - NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); - - String request = "Hello, netconf!"; - pos.write(request.getBytes()); - pos.write(EOM.getBytes()); - String response = netconfAdapter.receiveMessage(); - Assert.assertNotNull(response); - Assert.assertEquals(request, response.trim()); - } - - @Test - public void testSendMessage() throws IOException { - PipedOutputStream pos = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(pos); - - PipedInputStream pis = new PipedInputStream(); - PipedOutputStream os = new PipedOutputStream(pis); - - NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); - - String request = "Hello, netconf!"; - netconfAdapter.sendMessage(request); - byte[] bytes = new byte[request.length()+EOM.length()+2]; - int count = pis.read(bytes); - String response = new String(bytes, 0, count); - Assert.assertNotNull(response); - Assert.assertTrue(response.endsWith(EOM)); - response = response.substring(0, response.length() - EOM.length()).trim(); - Assert.assertEquals(request, response); - } - - @Test - public void testSendReceive() throws IOException { - PipedOutputStream os = new PipedOutputStream(); - PipedInputStream is = new PipedInputStream(os); - - NetconfAdapter netconfAdapter = new NetconfAdapter(is, os); - - String request = "Hello, netconf!"; - netconfAdapter.sendMessage(request); - String response = netconfAdapter.receiveMessage(); - Assert.assertNotNull(response); - Assert.assertEquals(request, response.trim()); - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java deleted file mode 100644 index b559bc749..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import java.util.Collections; -import java.util.List; - -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.exceptions.APPCException; - -public class TestGetRunningConfig { - - private static final String HOST = "192.168.1.2"; - private static final String USER = "test"; - private static final String PSWD = "test123"; - private static final int PORT = 830; - private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); - - public static void main(String[] args) throws APPCException { - try { - NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); - connectionDetails.setHost(HOST); - connectionDetails.setPort(PORT); - connectionDetails.setUsername(USER); - connectionDetails.setPassword(PSWD); - connectionDetails.setCapabilities(CAPABILITIES); - NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); - netconfClientJsch.connect(connectionDetails); - try { - System.out.println("=> Running get configuration..."); - String configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - } finally { - netconfClientJsch.disconnect(); - } - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java deleted file mode 100644 index 809625333..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import java.util.Collections; -import java.util.List; - -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.exceptions.APPCException; - -public class TestModifyConfig { - - private static final String HOST = "192.168.1.2"; - private static final String USER = "test"; - private static final String PSWD = "test123"; - private static final int PORT = 830; - private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); - private static final String CONFIG = - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " merge\n" + - " \n" + - " \n" + - " 1\n" + - " \n" + - " 1\n" + - " \n" + - " 1\n" + - " \n" + - " example.com\n" + - " 60\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - public static void main(String[] args) throws APPCException { - try { - NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); - connectionDetails.setHost(HOST); - connectionDetails.setPort(PORT); - connectionDetails.setUsername(USER); - connectionDetails.setPassword(PSWD); - connectionDetails.setCapabilities(CAPABILITIES); - NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); - netconfClientJsch.connect(connectionDetails); - try { - System.out.println("=> Running get configuration..."); - String configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - - System.out.println("=> Reconfiguring device..."); - String outMessage = netconfClientJsch.exchangeMessage(CONFIG); - System.out.println("=> Reconfiguration response:\n" + outMessage); - - System.out.println("=> Running get configuration..."); - configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - } finally { - netconfClientJsch.disconnect(); - } - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java deleted file mode 100644 index 915721d51..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import java.util.Collections; -import java.util.List; - -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.exceptions.APPCException; - -public class TestModifyConfigMock { - - private static final String HOST = "192.168.1.2"; - private static final String USER = "test"; - private static final String PSWD = "test123"; - private static final int PORT = 830; - private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); - private static final String CONFIG = - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " merge\n" + - " \n" + - " \n" + - " 1\n" + - " \n" + - " 1\n" + - " \n" + - " 1\n" + - " \n" + - " example.com\n" + - " 60\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - public static void main(String[] args) throws APPCException { - try { - NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); - connectionDetails.setHost(HOST); - connectionDetails.setPort(PORT); - connectionDetails.setUsername(USER); - connectionDetails.setPassword(PSWD); - connectionDetails.setCapabilities(CAPABILITIES); - NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); - netconfClientJsch.connect(connectionDetails); - try { - System.out.println("=> Running get configuration..."); - String configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - - System.out.println("=> Reconfiguring device..."); - String outMessage = netconfClientJsch.exchangeMessage(CONFIG); - System.out.println("=> Reconfiguration response:\n" + outMessage); - - System.out.println("=> Running get configuration..."); - configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - } finally { - netconfClientJsch.disconnect(); - } - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java deleted file mode 100644 index 83e62bc9f..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import java.util.Collections; -import java.util.List; - -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.exceptions.APPCException; - -public class TestModifyConfigRouterMock { - - private static final String HOST = "10.147.27.50"; // yuma netconf simulator - private static final int PORT = 830; - private static final String USER = "admin"; - private static final String PSWD = "admin"; - private static final List CAPABILITIES = Collections.emptyList(); - private static final String CONFIG = - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " 1\n" + - " \n" + - " 100.100.100.0/24\n" + - " 10\n" + - " \n" + - " \n" + - " \n" + - " 1000\n" + - " 10.10.1.1\n" + - " \n" + - " 2000\n" + - " 10.10.1.2\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n"; - - public static void main(String[] args) throws APPCException { - try { - NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); - connectionDetails.setHost(HOST); - connectionDetails.setPort(PORT); - connectionDetails.setUsername(USER); - connectionDetails.setPassword(PSWD); - connectionDetails.setCapabilities(CAPABILITIES); - NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); - netconfClientJsch.connect(connectionDetails); - try { - System.out.println("=> Running get configuration..."); - String configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - - System.out.println("=> Reconfiguring device..."); - String outMessage = netconfClientJsch.exchangeMessage(CONFIG); - System.out.println("=> Reconfiguration response:\n" + outMessage); - } finally { - netconfClientJsch.disconnect(); - } - } catch(Exception e) { - e.printStackTrace(); - } - } -} diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java deleted file mode 100644 index 263dd5a8f..000000000 --- a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java +++ /dev/null @@ -1,90 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.onap.appc.adapter.netconf.jsch; - -import java.util.Collections; -import java.util.List; - -import org.onap.appc.adapter.netconf.NetconfConnectionDetails; -import org.onap.appc.adapter.netconf.jsch.NetconfClientJsch; -import org.onap.appc.exceptions.APPCException; - -public class TestOperationalStates { - - private static final String HOST = "192.168.1.2"; - private static final String USER = "test"; - private static final String PSWD = "test123"; - private static final int PORT = 830; - private static final List CAPABILITIES = Collections.singletonList("urn:org:onap:appc:capability:1.1.0"); - private static final String GET_OPERATIONAL_STATES = - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - ""; - - public static void main(String[] args) throws APPCException { - try { - NetconfConnectionDetails connectionDetails = new NetconfConnectionDetails(); - connectionDetails.setHost(HOST); - connectionDetails.setPort(PORT); - connectionDetails.setUsername(USER); - connectionDetails.setPassword(PSWD); - connectionDetails.setCapabilities(CAPABILITIES); - NetconfClientJsch netconfClientJsch = new NetconfClientJsch(); - netconfClientJsch.connect(connectionDetails); - try { - System.out.println("=> Running get configuration..."); - String configuration = netconfClientJsch.getConfiguration(); - System.out.println("=> Configuration:\n" + configuration); - - System.out.println("=> Running get operational states..."); - String outMessage = netconfClientJsch.exchangeMessage(GET_OPERATIONAL_STATES); - System.out.println("=> Operational states:\n" + outMessage); - } finally { - netconfClientJsch.disconnect(); - } - } catch(Exception e) { - e.printStackTrace(); - } - } -} -- cgit 1.2.3-korg