aboutsummaryrefslogtreecommitdiffstats
path: root/dblib/provider/src/test/java/org/onap/ccsdk/sli/core/dblib/EncShellCommandTest.java
blob: 740e69dba92f9797b632ce42fd93aadb7cd362ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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());
    }
}