******************************************************************************/
package org.onap.aaf.cadi.test;
-import static org.mockito.Matchers.*;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-import org.junit.*;
-import org.mockito.*;
-import static org.mockito.Mockito.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.file.Paths;
import java.util.Properties;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
import org.onap.aaf.cadi.CmdLine;
-import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.Symm;
public class JU_CmdLine {
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
- System.setOut(new PrintStream(outContent));
+ System.setOut(new PrintStream(outContent));
Properties p = new Properties();
p.setProperty("force_exit", "false");
- CmdLine.access = new PropAccess(p);
-
+ CmdLine.setSystemExit(false);
+ keyfile = "src/test/resources/keyfile";
password = "password";
- keyfile = "test/keyfile";
- FileInputStream fis = new FileInputStream(keyfile);
+ File keyF = new File("src/test/resources", "keyfile");
+ FileInputStream fis = new FileInputStream(keyF);
try {
symm = Symm.obtain(fis);
} finally {
@After
public void restoreStreams() throws IOException {
- System.setOut(System.out);
- System.setIn(System.in);
+ System.setOut(System.out);
+ System.setIn(System.in);
}
@Test
assertThat(decrypted, is(password));
}
- @Test
- public void regurgitateTest() {
- // TODO: We may still want to remove the regurgitate functionality
- // from the CmdLine - Ian
- fail("Tests not yet implemented");
- }
-
@Test
public void encode64Test() throws Exception {
CmdLine.main(new String[]{"encode64", password});
assertThat(outContent.toString().length(), is(2074));
String filePath = "test/output_key";
+ File testDir = new File("test");
+ if(!testDir.exists()) {
+ testDir.mkdirs();
+ }
CmdLine.main(new String[]{"keygen", filePath});
File keyfile = new File(filePath);
assertTrue(Files.isReadable(Paths.get(filePath)));