aboutsummaryrefslogtreecommitdiffstats
path: root/appc-adapters/appc-ssh-adapter
diff options
context:
space:
mode:
authoramshegokar <AS00500801@techmahindra.com>2018-03-13 18:55:12 +0530
committerTakamune Cho <tc012c@att.com>2018-03-13 18:23:26 +0000
commit11e583e4e37bd274390643d494d2a8670e118c36 (patch)
tree2eb42c70cb4428cdea89f8cb73e215c219ac0669 /appc-adapters/appc-ssh-adapter
parentf6f366b5532c51d9166ed68073f611097aec1db4 (diff)
Coverage for org.onap.appc.adapter.ssh classes
Coverage for org.onap.appc.adapter.ssh classes Sonar-Link: https://sonar.onap.org/code?id=org.onap.appc%3Aappc&selected=org.onap.appc%3Aappc-ssh-adapter-tests%3Asrc%2Fmain%2Fjava%2Forg%2Fonap%2Fappc%2Fadapter%2Fssh Change-Id: Icd1dde27c8588f217b6cca83f1cde3a8b24a41c3 Issue-ID: APPC-725 Signed-off-by: amshegokar<AS00500801@techmahindra.com>
Diffstat (limited to 'appc-adapters/appc-ssh-adapter')
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml34
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshAdapterMock.java65
-rw-r--r--appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshConnectionMock.java83
3 files changed, 168 insertions, 14 deletions
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml
index bf91cd2cd..3bc3a5a5a 100644
--- a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/pom.xml
@@ -21,19 +21,25 @@
ECOMP is a trademark and service mark of AT&T Intellectual Property.
-->
<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.appc</groupId>
- <artifactId>appc-ssh-adapter</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
- <artifactId>appc-ssh-adapter-tests</artifactId>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.appc</groupId>
+ <artifactId>appc-ssh-adapter</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>appc-ssh-adapter-tests</artifactId>
- <dependencies>
- <dependency>
- <groupId>org.onap.appc</groupId>
- <artifactId>appc-ssh-adapter-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.appc</groupId>
+ <artifactId>appc-ssh-adapter-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project> \ No newline at end of file
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshAdapterMock.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshAdapterMock.java
new file mode 100644
index 000000000..f3badd775
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshAdapterMock.java
@@ -0,0 +1,65 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* 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.onap.appc.adapter.ssh;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestSshAdapterMock {
+ private SshAdapterMock sshAdapterMock;
+
+ @Before
+ public void setUp() {
+ sshAdapterMock = new SshAdapterMock();
+ }
+
+ @Test
+ public void testGetReturnStatus() {
+ sshAdapterMock.setReturnStatus(200);
+ assertNotNull(sshAdapterMock.getReturnStatus());
+ assertEquals(sshAdapterMock.getReturnStatus(), 200);
+ }
+
+ @Test
+ public void testGetReturnStdout() {
+ sshAdapterMock.setReturnStdout("success");
+ assertNotNull(sshAdapterMock.getReturnStdout());
+ assertEquals(sshAdapterMock.getReturnStdout(), "success");
+ }
+
+ @Test
+ public void testGetReturnStderr() {
+ sshAdapterMock.setReturnStderr("error");
+ assertNotNull(sshAdapterMock.getReturnStderr());
+ assertEquals(sshAdapterMock.getReturnStderr(), "error");
+ }
+
+ @Test
+ public void testGetConnectionMocks() {
+ sshAdapterMock.setReturnStatus(200);
+ sshAdapterMock.setReturnStdout("success");
+ sshAdapterMock.setReturnStderr("error");
+ sshAdapterMock.getConnection("localhost", 8080, "myUser", "myPassword");
+ assertEquals(false, sshAdapterMock.getConnectionMocks().isEmpty());
+ assertNotNull(sshAdapterMock.getConnectionMocks());
+ }
+}
diff --git a/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshConnectionMock.java b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshConnectionMock.java
new file mode 100644
index 000000000..182e0d7c7
--- /dev/null
+++ b/appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test/java/org/onap/appc/adapter/ssh/TestSshConnectionMock.java
@@ -0,0 +1,83 @@
+/*
+* ============LICENSE_START=======================================================
+* ONAP : APPC
+* ================================================================================
+* Copyright 2018 TechMahindra
+*=================================================================================
+* 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.onap.appc.adapter.ssh;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestSshConnectionMock {
+
+ private SshConnectionMock sshConnectionMock;
+ @Before
+ public void setUp() {
+ sshConnectionMock=new SshConnectionMock("localhost", 8080, "myUser", "myPassword");
+ }
+
+ @Test
+ public void testGetHost() {
+ assertNotNull(sshConnectionMock.getHost());
+ assertEquals(sshConnectionMock.getHost(), "localhost");
+ }
+
+ @Test
+ public void testGetPort() {
+ assertNotNull(sshConnectionMock.getPort());
+ assertEquals(sshConnectionMock.getPort(), 8080);
+ }
+
+ @Test
+ public void testGetUsername() {
+ assertNotNull(sshConnectionMock.getUsername());
+ assertEquals(sshConnectionMock.getUsername(), "myUser");
+ }
+
+ @Test
+ public void testGetPassword() {
+ assertNotNull(sshConnectionMock.getPassword());
+ assertEquals(sshConnectionMock.getPassword(), "myPassword");
+ }
+ @Test
+ public void testGetReturnStderr() {
+ sshConnectionMock.setReturnStderr("returnStderr");
+ assertNotNull(sshConnectionMock.getReturnStderr());
+ assertEquals(sshConnectionMock.getReturnStderr(), "returnStderr");
+ }
+ @Test
+ public void testGetReturnStdout() {
+ sshConnectionMock.setReturnStdout("returnStdout");
+ assertNotNull(sshConnectionMock.getReturnStdout());
+ assertEquals(sshConnectionMock.getReturnStdout(), "returnStdout");
+ }
+ @Test
+ public void testGetReturnStatus() {
+ sshConnectionMock.setReturnStatus(200);
+ assertNotNull(sshConnectionMock.getReturnStatus());
+ assertEquals(sshConnectionMock.getReturnStatus(), 200);
+ }
+ @Test
+ public void testGetExecutedCommands() {
+ sshConnectionMock.getExecutedCommands().add("cls");
+ sshConnectionMock.getExecutedCommands().add("pwd");
+ assertNotNull(sshConnectionMock.getExecutedCommands());
+ assertEquals(false, sshConnectionMock.getExecutedCommands().isEmpty());
+ }
+}