diff options
author | amshegokar <AS00500801@techmahindra.com> | 2018-03-13 18:55:12 +0530 |
---|---|---|
committer | Takamune Cho <tc012c@att.com> | 2018-03-13 18:23:26 +0000 |
commit | 11e583e4e37bd274390643d494d2a8670e118c36 (patch) | |
tree | 2eb42c70cb4428cdea89f8cb73e215c219ac0669 /appc-adapters/appc-ssh-adapter/appc-ssh-adapter-tests/src/test | |
parent | f6f366b5532c51d9166ed68073f611097aec1db4 (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/appc-ssh-adapter-tests/src/test')
2 files changed, 148 insertions, 0 deletions
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()); + } +} |