aboutsummaryrefslogtreecommitdiffstats
path: root/aai-core
diff options
context:
space:
mode:
authorJames Forsyth <jf2512@att.com>2018-10-13 00:34:43 +0000
committerGerrit Code Review <gerrit@onap.org>2018-10-13 00:34:43 +0000
commit27e7d8a0111e3a0df6c43da3c0cb6a5b888bf17d (patch)
tree6578d0e56f57057b8a42b1365d367103a347bdf8 /aai-core
parent4843d76e54fc50882ca1bc7c3cc8ff11544ad122 (diff)
parentb9c335bab6814a48499d8c6c043a66bd99a01e71 (diff)
Merge "some test cases added"
Diffstat (limited to 'aai-core')
-rw-r--r--aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java89
1 files changed, 57 insertions, 32 deletions
diff --git a/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java b/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
index 97349ecc..071b630b 100644
--- a/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
+++ b/aai-core/src/test/java/org/onap/aai/util/JettyObfuscationConversionCommandLineUtilTest.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2018 IBM.
+ * ================================================================================
* 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
@@ -30,42 +32,65 @@ import org.junit.Test;
public class JettyObfuscationConversionCommandLineUtilTest {
- private final ByteArrayOutputStream testOut = new ByteArrayOutputStream();
+ private final ByteArrayOutputStream testOut = new ByteArrayOutputStream();
+
+ /**
+ * Test.
+ */
+ @Test
+ public void test() {
+ //setup, this will catch main's print statements for evaluation
+ PrintStream oldOutputStream = System.out;
+ System.setOut(new PrintStream(testOut));
+
+ /* ------ TEST OBFUSCATION ----*/
+ JettyObfuscationConversionCommandLineUtil.main(new String[]{"-e", "hello world"});
+ /*
+ * testOut was also catching any logging statements which interfered with result checking.
+ * This regex business was the workaround - it tries to find the expected value in
+ * the results and asserts against that.
+ */
+ String obfResult = testOut.toString();
+ String obfExpected = "OBF:1thf1ugo1x151wfw1ylz11tr1ymf1wg21x1h1uh21th7";
+ Pattern obfExpectPat = Pattern.compile(obfExpected);
+ Matcher obfMatch = obfExpectPat.matcher(obfResult);
+ assertTrue(obfMatch.find());
+
+ testOut.reset(); //clear out previous result
+
+ /* ------ TEST DEOBFUSCATION ----- */
+ JettyObfuscationConversionCommandLineUtil.main(new String[]{"-d", obfExpected});
+ String deobfResult = testOut.toString();
+ String deobfExpected = "hello world";
+ Pattern deobfExpectPat = Pattern.compile(deobfExpected);
+ Matcher deobfMatch = deobfExpectPat.matcher(deobfResult);
+ assertTrue(deobfMatch.find());
- /**
- * Test.
- */
- @Test
- public void test() {
- //setup, this will catch main's print statements for evaluation
- PrintStream oldOutputStream = System.out;
- System.setOut(new PrintStream(testOut));
+ //clean up, resets to stdout
+ System.setOut(oldOutputStream);
+ }
- /* ------ TEST OBFUSCATION ----*/
- JettyObfuscationConversionCommandLineUtil.main(new String[]{"-e", "hello world"});
- /*
- * testOut was also catching any logging statements which interfered with result checking.
- * This regex business was the workaround - it tries to find the expected value in
- * the results and asserts against that.
- */
- String obfResult = testOut.toString();
- String obfExpected = "OBF:1thf1ugo1x151wfw1ylz11tr1ymf1wg21x1h1uh21th7";
- Pattern obfExpectPat = Pattern.compile(obfExpected);
- Matcher obfMatch = obfExpectPat.matcher(obfResult);
- assertTrue(obfMatch.find());
+
+ /**
+ * Test.
+ */
+ @Test
+ public void testUsage() {
+ System.setOut(new PrintStream(testOut));
- testOut.reset(); //clear out previous result
+ /* ------ TEST OBFUSCATION ----*/
+ JettyObfuscationConversionCommandLineUtil.main(new String[]{"-f", "hello world"});
+ /*
+ * testOut was also catching any logging statements which interfered with result checking.
+ * This regex business was the workaround - it tries to find the expected value in
+ * the results and asserts against that.
+ */
+ String obfResult = testOut.toString();
+ assertTrue(obfResult.startsWith("failed to parse input"));
+
+ testOut.reset(); //clear out previous result
- /* ------ TEST DEOBFUSCATION ----- */
- JettyObfuscationConversionCommandLineUtil.main(new String[]{"-d", obfExpected});
- String deobfResult = testOut.toString();
- String deobfExpected = "hello world";
- Pattern deobfExpectPat = Pattern.compile(deobfExpected);
- Matcher deobfMatch = deobfExpectPat.matcher(deobfResult);
- assertTrue(deobfMatch.find());
- //clean up, resets to stdout
- System.setOut(oldOutputStream);
- }
+ }
}