summaryrefslogtreecommitdiffstats
path: root/dblib/provider/src
diff options
context:
space:
mode:
authorDriptaroop Das <driptaroop.das@in.ibm.com>2019-02-01 12:42:36 +0530
committerDriptaroop Das <driptaroop.das@in.ibm.com>2019-02-01 13:44:52 +0530
commit58982ce3d08ed1510daada7d0ecb0792990248d6 (patch)
tree55112268aea377b03f4d89be1a43b5538794f4c5 /dblib/provider/src
parent1efd16dce0ecedb81039b26b81d1490cadeb3395 (diff)
Junit for EncShellCommand.java
Junit for EncShellCommand.java Issue-ID: CCSDK-1016 Change-Id: I7cbdb49b6e04ce6a69a48f9a507c7db959698140 Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
Diffstat (limited to 'dblib/provider/src')
-rw-r--r--dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java
new file mode 100644
index 000000000..740e69dba
--- /dev/null
+++ b/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java
@@ -0,0 +1,41 @@
+package org.onap.ccsdk.sli.core.dblib;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.Arrays;
+
+import static org.junit.Assert.*;
+
+public class EncShellCommandTest {
+
+ private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
+ private final PrintStream originalOut = System.out;
+ private final PrintStream originalErr = System.err;
+
+ @Before
+ public void setUp() {
+ System.setOut(new PrintStream(outContent));
+ System.setErr(new PrintStream(errContent));
+ }
+
+ @After
+ public void tearDown() {
+ System.setOut(originalOut);
+ System.setErr(originalErr);
+ }
+
+ @Test
+ public void testDoExecute() throws Exception {
+ String expected = "Original value: test" + System.getProperty("line.separator") +
+ "Encrypted value: test";
+ EncShellCommand encShellCommand = new EncShellCommand();
+ encShellCommand.arg = "test";
+ encShellCommand.doExecute();
+ assertEquals(expected.trim(), outContent.toString().trim());
+ }
+} \ No newline at end of file