Sonar Fixes, Formatting
[aaf/authz.git] / cadi / core / src / test / java / org / onap / aaf / cadi / util / test / JU_SubStandardConsole.java
index 712b989..8c1597c 100644 (file)
@@ -6,9 +6,9 @@
  * * 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.
@@ -18,6 +18,7 @@
  * *
  * *
  ******************************************************************************/
+
 package org.onap.aaf.cadi.util.test;
 
 import static org.junit.Assert.*;
@@ -36,90 +37,90 @@ import org.onap.aaf.cadi.util.SubStandardConsole;
 
 public class JU_SubStandardConsole {
 
-       private String inputString = "An input string";
-       private ByteArrayOutputStream outStream;
-       private ByteArrayOutputStream errStream;
-       private String lineSeparator = System.lineSeparator();
-
-       @Before
-       public void setup() {
-               outStream = new ByteArrayOutputStream();
-               errStream = new ByteArrayOutputStream();
-               System.setOut(new PrintStream(outStream));
-               System.setErr(new PrintStream(errStream));
-       }
-
-       @After
-       public void tearDown() {
-               System.setOut(System.out);
-               System.setErr(System.err);
-       }
-
-       @Test
-       public void readLineTest() {
-               byte[] input = inputString.getBytes();
-               System.setIn(new ByteArrayInputStream(input));
-               SubStandardConsole ssc = new SubStandardConsole();
-               String output = ssc.readLine("%s" + lineSeparator, ">>> ");
-               assertThat(output, is(inputString));
-               assertThat(outStream.toString(), is(">>> " + lineSeparator));
-       }
-
-       @Test
-       public void readLineTest2() {
-               byte[] input = inputString.getBytes();
-               System.setIn(new ByteArrayInputStream(input));
-               SubStandardConsole ssc = new SubStandardConsole();
-               String output = ssc.readLine("%s %s"  + lineSeparator, ">>> ", "Another argument for coverage");
-               assertThat(output, is(inputString));
-       }
-
-       @Test
-       public void readLineTest3() {
-               byte[] input = "\n".getBytes();
-               System.setIn(new ByteArrayInputStream(input));
-               SubStandardConsole ssc = new SubStandardConsole();
-               String output = ssc.readLine("%s" + lineSeparator, ">>> ");
-               assertThat(output, is(">>> "));
-               assertThat(outStream.toString(), is(">>> " + lineSeparator));
-       }
-
-       @Test
-       public void readPasswordTest() {
-               byte[] input = inputString.getBytes();
-               System.setIn(new ByteArrayInputStream(input));
-               SubStandardConsole ssc = new SubStandardConsole();
-               char[] output = ssc.readPassword("%s" + lineSeparator, ">>> ");
-               System.out.println(output);
-               assertThat(output, is(inputString.toCharArray()));
-               assertThat(outStream.toString(), is(">>> " + lineSeparator + "An input string"  + lineSeparator));
-       }
-
-       @Test
-       public void printfTest() {
-               byte[] input = inputString.getBytes();
-               System.setIn(new ByteArrayInputStream(input));
-               SubStandardConsole ssc = new SubStandardConsole();
-               ssc.printf("%s", "A format specifier");
-               assertThat(outStream.toString(), is("A format specifier"));
-       }
-
-       @Test
-       public void throwsTest() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
-               BufferedReader brMock = mock(BufferedReader.class);
-               when(brMock.readLine()).thenThrow(new IOException());
-
-               SubStandardConsole ssc = new SubStandardConsole();
-
-               Field brField = SubStandardConsole.class.getDeclaredField("br");
-               brField.setAccessible(true);
-               brField.set(ssc, brMock);
-
-               assertThat(ssc.readLine(""), is(""));
-               assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
+    private String inputString = "An input string";
+    private ByteArrayOutputStream outStream;
+    private ByteArrayOutputStream errStream;
+    private String lineSeparator = System.lineSeparator();
+
+    @Before
+    public void setup() {
+        outStream = new ByteArrayOutputStream();
+        errStream = new ByteArrayOutputStream();
+        System.setOut(new PrintStream(outStream));
+        System.setErr(new PrintStream(errStream));
+    }
+
+    @After
+    public void tearDown() {
+        System.setOut(System.out);
+        System.setErr(System.err);
+    }
+
+    @Test
+    public void readLineTest() {
+        byte[] input = inputString.getBytes();
+        System.setIn(new ByteArrayInputStream(input));
+        SubStandardConsole ssc = new SubStandardConsole();
+        String output = ssc.readLine("%s" + lineSeparator, ">>> ");
+        assertThat(output, is(inputString));
+        assertThat(outStream.toString(), is(">>> " + lineSeparator));
+    }
+
+    @Test
+    public void readLineTest2() {
+        byte[] input = inputString.getBytes();
+        System.setIn(new ByteArrayInputStream(input));
+        SubStandardConsole ssc = new SubStandardConsole();
+        String output = ssc.readLine("%s %s"  + lineSeparator, ">>> ", "Another argument for coverage");
+        assertThat(output, is(inputString));
+    }
+
+    @Test
+    public void readLineTest3() {
+        byte[] input = "\n".getBytes();
+        System.setIn(new ByteArrayInputStream(input));
+        SubStandardConsole ssc = new SubStandardConsole();
+        String output = ssc.readLine("%s" + lineSeparator, ">>> ");
+        assertThat(output, is(">>> "));
+        assertThat(outStream.toString(), is(">>> " + lineSeparator));
+    }
+
+    @Test
+    public void readPasswordTest() {
+        byte[] input = inputString.getBytes();
+        System.setIn(new ByteArrayInputStream(input));
+        SubStandardConsole ssc = new SubStandardConsole();
+        char[] output = ssc.readPassword("%s" + lineSeparator, ">>> ");
+        System.out.println(output);
+        assertThat(output, is(inputString.toCharArray()));
+        assertThat(outStream.toString(), is(">>> " + lineSeparator + "An input string"  + lineSeparator));
+    }
+
+    @Test
+    public void printfTest() {
+        byte[] input = inputString.getBytes();
+        System.setIn(new ByteArrayInputStream(input));
+        SubStandardConsole ssc = new SubStandardConsole();
+        ssc.printf("%s", "A format specifier");
+        assertThat(outStream.toString(), is("A format specifier"));
+    }
+
+    @Test
+    public void throwsTest() throws IOException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
+        BufferedReader brMock = mock(BufferedReader.class);
+        when(brMock.readLine()).thenThrow(new IOException());
+
+        SubStandardConsole ssc = new SubStandardConsole();
+
+        Field brField = SubStandardConsole.class.getDeclaredField("br");
+        brField.setAccessible(true);
+        brField.set(ssc, brMock);
+
+        assertThat(ssc.readLine(""), is(""));
+        assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
         errStream.reset();
-               assertThat(ssc.readPassword("").length, is(0));
-               assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
-       }
+        assertThat(ssc.readPassword("").length, is(0));
+        assertThat(errStream.toString(), is("uh oh..." + lineSeparator));
+    }
 
 }