X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-certman%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fcm%2Fcert%2FJU_BCFactory.java;h=7e0a084541d2fe66e07448c57a4c172057491c73;hb=6dd9704640eb8cc8d6b4ccd266e40a3f6f589e75;hp=337bc9ed404a0d2370bb97f60bef3e9e8967cf57;hpb=c060284812fbbc18fcf22eb628c47c251505fe50;p=aaf%2Fauthz.git diff --git a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_BCFactory.java b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_BCFactory.java index 337bc9ed..7e0a0845 100644 --- a/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_BCFactory.java +++ b/auth/auth-certman/src/test/java/org/onap/aaf/auth/cm/cert/JU_BCFactory.java @@ -7,9 +7,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. @@ -19,6 +19,7 @@ * * * * ******************************************************************************/ + package org.onap.aaf.auth.cm.cert; import static org.junit.Assert.assertNotNull; @@ -47,82 +48,81 @@ import org.onap.aaf.misc.env.Trans; @RunWith(MockitoJUnitRunner.class) public class JU_BCFactory { - - private static BCFactory bcFactory = new BCFactory(); - - private static BCFactory bcFact; - - private static PrivateKey pk; - - - private static Trans trans; - - - private static PKCS10CertificationRequest req; - - @BeforeClass - public static void setUp() throws IOException { - pk = new XYZKey(); - trans = mock(Trans.class); - req = mock(PKCS10CertificationRequest.class); - when(req.getEncoded()).thenReturn(new byte[1]); - when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken(null, 0) { - - @Override - public void output(StringBuilder sb) { - // TODO Auto-generated method stub - - } - }); - bcFact = mock(BCFactory.class); - } - - @Test - public void toStrin() throws OperatorCreationException, IOException, CertException { - assertNotNull(bcFactory.toString(req)); - } - - @Test - public void toStrinMoc() throws OperatorCreationException, IOException, CertException { - assertNotNull(bcFact.toString(req)); - } - - @Rule + + private static BCFactory bcFactory = new BCFactory(); + + private static BCFactory bcFact; + + private static PrivateKey pk; + + + private static Trans trans; + + + private static PKCS10CertificationRequest req; + + @BeforeClass + public static void setUp() throws IOException { + pk = new XYZKey(); + trans = mock(Trans.class); + req = mock(PKCS10CertificationRequest.class); + when(req.getEncoded()).thenReturn(new byte[1]); + when(trans.start(Mockito.anyString(), Mockito.anyInt())).thenReturn(new TimeTaken(null, 0) { + + @Override + public void output(StringBuilder sb) { + // TODO Auto-generated method stub + + } + }); + bcFact = mock(BCFactory.class); + } + + @Test + public void toStrin() throws OperatorCreationException, IOException, CertException { + assertNotNull(bcFactory.toString(req)); + } + + @Test + public void toStrinMoc() throws OperatorCreationException, IOException, CertException { + assertNotNull(bcFact.toString(req)); + } + + @Rule public ExpectedException thrown= ExpectedException.none(); - - @Test - public void toCSR() { - try { - assertNotNull(bcFactory.toCSR(trans, new File("/random/path"))); - thrown.expect(FileNotFoundException.class); - } catch (IOException e) { - - e.printStackTrace(); - } - } - + + @Test + public void toCSR() { + try { + assertNotNull(bcFactory.toCSR(trans, new File("/random/path"))); + thrown.expect(FileNotFoundException.class); + } catch (IOException e) { + e.printStackTrace(); + } + } + } class XYZKey implements Key, PublicKey, PrivateKey { - - int rotValue; - public XYZKey() { - rotValue = 1200213; - } - public String getAlgorithm() { - return "XYZ"; - } - - public String getFormat() { - return "XYZ Special Format"; - } - - public byte[] getEncoded() { - byte b[] = new byte[4]; - b[3] = (byte) ((rotValue << 24) & 0xff); - b[2] = (byte) ((rotValue << 16) & 0xff); - b[1] = (byte) ((rotValue << 8) & 0xff); - b[0] = (byte) ((rotValue << 0) & 0xff); - return b; - } + + int rotValue; + public XYZKey() { + rotValue = 1200213; + } + public String getAlgorithm() { + return "XYZ"; + } + + public String getFormat() { + return "XYZ Special Format"; + } + + public byte[] getEncoded() { + byte b[] = new byte[4]; + b[3] = (byte) ((rotValue << 24) & 0xff); + b[2] = (byte) ((rotValue << 16) & 0xff); + b[1] = (byte) ((rotValue << 8) & 0xff); + b[0] = (byte) ((rotValue << 0) & 0xff); + return b; + } }