Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / cadi / aaf / src / test / java / org / onap / aaf / cadi / cm / test / JU_PlaceArtifactInKeystore.java
index d61ac49..1a653ab 100644 (file)
@@ -54,100 +54,100 @@ import certman.v1_0.CertInfo;
 
 public class JU_PlaceArtifactInKeystore {
 
-       @Mock private Trans transMock;
-       @Mock private CertInfo certInfoMock;
-       @Mock private Artifact artiMock;
-
-       private static final String caName = "onap";
-       private static final String dirName = "src/test/resources/artifacts";
-       private static final String nsName = "org.onap.test";
-       private static final String mechID = "m12345";
-       private static final String luggagePassword = "12345";  // That's the stupidest combination I've ever heard in my life
-
-       private static String privateKeyString;
-       private static String x509Chain;
-       private static String x509String;
-
-       private List<String> certs;
-
-       @Before
-       public void setup() throws FileNotFoundException, IOException, CertificateException {
-               MockitoAnnotations.initMocks(this);
-
-               x509Chain = fromFile(new File("src/test/resources/cert.pem"));
-               x509String = fromFile(new File("src/test/resources/exampleCertificate.cer"));
-               privateKeyString = fromFile(new File("src/test/resources/key.pem"));
-
-               certs = new ArrayList<>();
-
-               when(certInfoMock.getChallenge()).thenReturn(luggagePassword);
-               when(certInfoMock.getCerts()).thenReturn(certs);
-
-               when(artiMock.getCa()).thenReturn(caName);
-               when(artiMock.getDir()).thenReturn(dirName);
-               when(artiMock.getNs()).thenReturn(nsName);
-               when(artiMock.getMechid()).thenReturn(mechID);
-
-               when(certInfoMock.getPrivatekey()).thenReturn(privateKeyString);
-
-               when(transMock.start("Reconstitute Private Key", Env.SUB)).thenReturn(mock(TimeTaken.class));
-       }
-
-       @AfterClass
-       public static void tearDownOnce() {
-               cleanup();
-               PlaceArtifactInKeystore.clear();
-       }
-
-       @Test
-       public void test() throws CadiException {
-               // Note: PKCS12 can't be tested in JDK 7 and earlier.  Can't handle Trusting Certificates.
-               PlaceArtifactInKeystore placer = new PlaceArtifactInKeystore(Agent.JKS);
-
-               certs.add(x509String);
-               certs.add(x509Chain);
-               assertThat(placer.place(transMock, certInfoMock, artiMock, "machine"), is(true));
-               for (String ext : new String[] {"chal", "keyfile", Agent.JKS, "trust.jks", "cred.props"}) {
-                       File f = new File(dirName + '/' + nsName + '.' + ext);
-                       assertThat(f.exists(), is(true));
-               }
-
-               // coverage
-               assertThat(placer.place(transMock, certInfoMock, artiMock, "machine"), is(true));
-               
-               when(certInfoMock.getCerts()).thenReturn(null);
-               try {
-                       placer._place(transMock, certInfoMock, artiMock);
-                       fail("Should've thrown an exception");
-               } catch (Exception e) {
-               }
-
-       }
-
-       private static void cleanup() {
-               File dir = new File(dirName);
-               if (dir.exists()) {
-                       for (File f : dir.listFiles()) {
-                               f.delete();
-                       }
-                       dir.delete();
-               }
-       }
-
-       public String fromFile(File file) throws IOException {
-               BufferedReader br = new BufferedReader(new FileReader(file));
-               ByteArrayOutputStream baos = new ByteArrayOutputStream();
-               String line;
-               baos.write(br.readLine().getBytes());
-               // Here comes the hacky part
-               baos.write("\n".getBytes());
-               while((line=br.readLine())!=null) {
-                       if(line.length()>0) {
-                               baos.write(line.getBytes());
-                               baos.write("\n".getBytes());
-                       }
-               }
-               br.close();
-               return baos.toString();
-       }
+    @Mock private Trans transMock;
+    @Mock private CertInfo certInfoMock;
+    @Mock private Artifact artiMock;
+
+    private static final String caName = "onap";
+    private static final String dirName = "src/test/resources/artifacts";
+    private static final String nsName = "org.onap.test";
+    private static final String mechID = "m12345";
+    private static final String luggagePassword = "12345";  // That's the stupidest combination I've ever heard in my life
+
+    private static String privateKeyString;
+    private static String x509Chain;
+    private static String x509String;
+
+    private List<String> certs;
+
+    @Before
+    public void setup() throws FileNotFoundException, IOException, CertificateException {
+        MockitoAnnotations.initMocks(this);
+
+        x509Chain = fromFile(new File("src/test/resources/cert.pem"));
+        x509String = fromFile(new File("src/test/resources/exampleCertificate.cer"));
+        privateKeyString = fromFile(new File("src/test/resources/key.pem"));
+
+        certs = new ArrayList<>();
+
+        when(certInfoMock.getChallenge()).thenReturn(luggagePassword);
+        when(certInfoMock.getCerts()).thenReturn(certs);
+
+        when(artiMock.getCa()).thenReturn(caName);
+        when(artiMock.getDir()).thenReturn(dirName);
+        when(artiMock.getNs()).thenReturn(nsName);
+        when(artiMock.getMechid()).thenReturn(mechID);
+
+        when(certInfoMock.getPrivatekey()).thenReturn(privateKeyString);
+
+        when(transMock.start("Reconstitute Private Key", Env.SUB)).thenReturn(mock(TimeTaken.class));
+    }
+
+    @AfterClass
+    public static void tearDownOnce() {
+        cleanup();
+        PlaceArtifactInKeystore.clear();
+    }
+
+    @Test
+    public void test() throws CadiException {
+        // Note: PKCS12 can't be tested in JDK 7 and earlier.  Can't handle Trusting Certificates.
+        PlaceArtifactInKeystore placer = new PlaceArtifactInKeystore(Agent.JKS);
+
+        certs.add(x509String);
+        certs.add(x509Chain);
+        assertThat(placer.place(transMock, certInfoMock, artiMock, "machine"), is(true));
+        for (String ext : new String[] {"chal", "keyfile", Agent.JKS, "trust.jks", "cred.props"}) {
+            File f = new File(dirName + '/' + nsName + '.' + ext);
+            assertThat(f.exists(), is(true));
+        }
+
+        // coverage
+        assertThat(placer.place(transMock, certInfoMock, artiMock, "machine"), is(true));
+        
+        when(certInfoMock.getCerts()).thenReturn(null);
+        try {
+            placer._place(transMock, certInfoMock, artiMock);
+            fail("Should've thrown an exception");
+        } catch (Exception e) {
+        }
+
+    }
+
+    private static void cleanup() {
+        File dir = new File(dirName);
+        if (dir.exists()) {
+            for (File f : dir.listFiles()) {
+                f.delete();
+            }
+            dir.delete();
+        }
+    }
+
+    public String fromFile(File file) throws IOException {
+        BufferedReader br = new BufferedReader(new FileReader(file));
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        String line;
+        baos.write(br.readLine().getBytes());
+        // Here comes the hacky part
+        baos.write("\n".getBytes());
+        while((line=br.readLine())!=null) {
+            if(line.length()>0) {
+                baos.write(line.getBytes());
+                baos.write("\n".getBytes());
+            }
+        }
+        br.close();
+        return baos.toString();
+    }
 }