summaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java')
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java197
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java88
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java60
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java93
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java91
-rw-r--r--appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java87
7 files changed, 709 insertions, 0 deletions
diff --git a/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
new file mode 100644
index 000000000..d6d5ae278
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/OperationalStateValidatorTest.java
@@ -0,0 +1,197 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
+ */
+
+import org.openecomp.appc.exceptions.APPCException;
+import org.junit.Test;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidator;
+import org.openecomp.appc.adapter.netconf.OperationalStateValidatorFactory;
+import org.openecomp.appc.adapter.netconf.VnfType;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+
+public class OperationalStateValidatorTest {
+
+ @Test
+ public void testVNFValidResponse() {
+ String validResponse = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertValidResponse(validResponse, operationalStateValidator);
+ }
+
+ void assertInvalidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ fail("invalid resposne passed without exception!!!");
+ } catch (APPCException e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testVNFInvalidResponses() {
+
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.VNF);
+ assertInvalidResponse(null, operationalStateValidator);
+
+ assertInvalidResponse("", operationalStateValidator);
+
+ String response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+
+ response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"101\">\n" +
+ " <data>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <id>1</id>\n" +
+ " <ProcessorManagement>\n" +
+ " <id>1</id>\n" +
+ " <MatedPair>\n" +
+ " <id>1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_5</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " <PayloadProcessor>\n" +
+ " <id>processor_0_7</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <id>SC-1</id>\n" +
+ " <operationalState>ENABLED</operationalState>\n" +
+ " </SystemController>\n" +
+ " <SystemController>\n" +
+ " <id>SC-2</id>\n" +
+ " <operationalState></operationalState>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </data>\n" +
+ "</rpc-reply>";
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ void assertValidResponse(String response, OperationalStateValidator operationalStateValidator) {
+ try {
+ operationalStateValidator.validateResponse(response);
+ } catch (APPCException e) {
+ fail("Got unexpected exception. Validation failed. " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void testMockValidResponse() {
+ String response = "valid";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator("mock");
+ assertValidResponse(response, operationalStateValidator);
+
+ response = "";
+ assertValidResponse(response, operationalStateValidator);
+
+ response = null;
+ assertValidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testMockInValidResponse() {
+ String response = "anything InValid anything.. ";
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(VnfType.MOCK);
+ assertInvalidResponse(response, operationalStateValidator);
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForInValidVnfType() {
+ try{
+ OperationalStateValidatorFactory.getOperationalStateValidator("wrongVnfType");
+ fail("invalid vnfType without exception!!!");
+ } catch (Exception e) {
+ assertNotNull(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testGetOperationalStateValidatorForValidVnfType() {
+ String vnfType = VnfType.VNF.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.VNF.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toLowerCase();
+ assertGettingValidatorForValidVnf(vnfType);
+
+ vnfType = VnfType.MOCK.name().toUpperCase();
+ assertGettingValidatorForValidVnf(vnfType);
+ }
+
+ void assertGettingValidatorForValidVnf(String vnfType) {
+ try{
+ OperationalStateValidator operationalStateValidator = OperationalStateValidatorFactory.getOperationalStateValidator(vnfType);
+ assertNotNull(operationalStateValidator);
+ } catch (Exception e) {
+ fail("valid vnfType throw exception!!!");
+ }
+ }
+}
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
new file mode 100644
index 000000000..5e63d5010
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/internal/TestNetconfAdapter.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.internal;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.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
new file mode 100644
index 000000000..a26c6e9e9
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestGetRunningConfig.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.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<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+
+ 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
new file mode 100644
index 000000000..e4baecc89
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfig.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.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<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ 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
new file mode 100644
index 000000000..1fe2e1093
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigMock.java
@@ -0,0 +1,93 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.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<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String CONFIG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" message-id=\"1\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <running />\n" +
+ " </target>\n" +
+ " <default-operation>merge</default-operation>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <ManagedElement xmlns=\"urn:org.openecomp.appc:Test\">\n" +
+ " <managedElementId>1</managedElementId>\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:VnfFunction\">\n" +
+ " <id>1</id>\n" +
+ " <Interfaces>\n" +
+ " <id>1</id>\n" +
+ " <DiaRealmRf>\n" +
+ " <realm>example.com</realm>\n" +
+ " <reconnectTimer>60</reconnectTimer>\n" +
+ " </DiaRealmRf>\n" +
+ " </Interfaces>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>";
+
+ 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
new file mode 100644
index 000000000..256e8e8f5
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestModifyConfigRouterMock.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.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<String> CAPABILITIES = Collections.emptyList();
+ private static final String CONFIG =
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <edit-config>\n" +
+ " <target>\n" +
+ " <candidate/>\n" +
+ " </target>\n" +
+ " <config xmlns:xc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <router xmlns=\"urn:sdnhub:odl:tutorial:router\">\n" +
+ " <ospf>\n" +
+ " <process-id>1</process-id>\n" +
+ " <networks>\n" +
+ " <subnet-ip>100.100.100.0/24</subnet-ip>\n" +
+ " <area-id>10</area-id>\n" +
+ " </networks>\n" +
+ " </ospf>\n" +
+ " <bgp>\n" +
+ " <as-number>1000</as-number>\n" +
+ " <router-id>10.10.1.1</router-id>\n" +
+ " <neighbors>\n" +
+ " <as-number>2000</as-number>\n" +
+ " <peer-ip>10.10.1.2</peer-ip>\n" +
+ " </neighbors>\n" +
+ " </bgp>\n" +
+ " </router>\n" +
+ " </config>\n" +
+ " </edit-config>\n" +
+ "</rpc>\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
new file mode 100644
index 000000000..39c1a871c
--- /dev/null
+++ b/appc-adapters/appc-netconf-adapter/appc-netconf-adapter-bundle/src/test/java/org/openecomp/appc/adapter/netconf/jsch/TestOperationalStates.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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 org.openecomp.appc.adapter.netconf.jsch;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.openecomp.appc.adapter.netconf.NetconfConnectionDetails;
+import org.openecomp.appc.adapter.netconf.jsch.NetconfClientJsch;
+import org.openecomp.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<String> CAPABILITIES = Collections.singletonList("<capability>urn:org:openecomp:appc:capability:1.1.0</capability>");
+ private static final String GET_OPERATIONAL_STATES =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<rpc message-id=\"101\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\">\n" +
+ " <get>\n" +
+ " <filter>\n" +
+ " <ManagedElement xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <VnfFunction xmlns=\"urn:org:openecomp:appc:Test\">\n" +
+ " <ProcessorManagement>\n" +
+ " <MatedPair>\n" +
+ " <operationalState/>\n" +
+ " <PayloadProcessor>\n" +
+ " <operationalState/>\n" +
+ " </PayloadProcessor>\n" +
+ " </MatedPair>\n" +
+ " <SystemController>\n" +
+ " <operationalState/>\n" +
+ " </SystemController>\n" +
+ " </ProcessorManagement>\n" +
+ " </VnfFunction>\n" +
+ " </ManagedElement>\n" +
+ " </filter>\n" +
+ " </get>\n" +
+ "</rpc>";
+
+ 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();
+ }
+ }
+}