X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=cadi%2Faaf%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Foauth%2Ftest%2FJU_TzHClient.java;h=11dce82500902873aba794de83eb15866acb8d23;hb=4b5a7d721d994a49057e9bfb403c7bff1b376660;hp=bd2393e4e490a8e22ba1ec24cb2f142a5373d52f;hpb=824dc7b5fc0e1ccdf7f460479aff344727f0f01e;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/oauth/test/JU_TzHClient.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/oauth/test/JU_TzHClient.java index bd2393e4..11dce825 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/oauth/test/JU_TzHClient.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/oauth/test/JU_TzHClient.java @@ -53,66 +53,66 @@ import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.config.SecurityInfoC; public class JU_TzHClient { - - @Mock private Retryable retryableMock; - @Mock private TimedToken tokenMock; - @Mock private SecurityInfoC siMock; - @Mock private Locator locMock; - @Mock private Item itemMock; - @Mock private Rcli clientMock; - - private PropAccess access; - - private ByteArrayOutputStream errStream; - - private final static String client_id = "id"; - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]); - access.setProperty(Config.CADI_LATITUDE, "38.62"); // St Louis approx lat - access.setProperty(Config.CADI_LONGITUDE, "90.19"); // St Louis approx lon } - - errStream = new ByteArrayOutputStream(); - System.setErr(new PrintStream(errStream)); - } - - @After - public void tearDown() { - System.setErr(System.err); - } + + @Mock private Retryable retryableMock; + @Mock private TimedToken tokenMock; + @Mock private SecurityInfoC siMock; + @Mock private Locator locMock; + @Mock private Item itemMock; + @Mock private Rcli clientMock; + + private PropAccess access; + + private ByteArrayOutputStream errStream; + + private final static String client_id = "id"; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]); + access.setProperty(Config.CADI_LATITUDE, "38.62"); // St Louis approx lat + access.setProperty(Config.CADI_LONGITUDE, "90.19"); // St Louis approx lon } + + errStream = new ByteArrayOutputStream(); + System.setErr(new PrintStream(errStream)); + } + + @After + public void tearDown() { + System.setErr(System.err); + } - @Test - public void test() throws CadiException, LocatorException, APIException, IOException { - TzHClient client; - try { - client = new TzHClient(access, "tag"); - } catch (Exception e) { - throw e; - } - try { - client.best(retryableMock); - fail("Should've thrown an exception"); - } catch (CadiException e) { - assertThat(e.getMessage(), is("OAuth2 Token has not been set")); - } - client.setToken(client_id, tokenMock); - when(tokenMock.expired()).thenReturn(true); - try { - client.best(retryableMock); - fail("Should've thrown an exception"); - } catch (CadiException e) { - assertThat(e.getMessage(), is("Expired Token")); - } + @Test + public void test() throws CadiException, LocatorException, APIException, IOException { + TzHClient client; + try { + client = new TzHClient(access, "tag"); + } catch (Exception e) { + throw e; + } + try { + client.best(retryableMock); + fail("Should've thrown an exception"); + } catch (CadiException e) { + assertThat(e.getMessage(), is("OAuth2 Token has not been set")); + } + client.setToken(client_id, tokenMock); + when(tokenMock.expired()).thenReturn(true); + try { + client.best(retryableMock); + fail("Should've thrown an exception"); + } catch (CadiException e) { + assertThat(e.getMessage(), is("Expired Token")); + } - client = new TzHClient(access, siMock, locMock); - when(tokenMock.expired()).thenReturn(false); - doReturn(clientMock).when(retryableMock).lastClient(); + client = new TzHClient(access, siMock, locMock); + when(tokenMock.expired()).thenReturn(false); + doReturn(clientMock).when(retryableMock).lastClient(); - when(retryableMock.item()).thenReturn(itemMock); - client.setToken(client_id, tokenMock); - assertThat(client.best(retryableMock), is(nullValue())); - } + when(retryableMock.item()).thenReturn(itemMock); + client.setToken(client_id, tokenMock); + assertThat(client.best(retryableMock), is(nullValue())); + } }