-
- @Mock private HClient clientMock;
- @Mock private Future<Endpoints> futureMock;
- @Mock private Endpoints endpointsMock;
-
- private PropAccess access;
-
- private ByteArrayOutputStream errStream;
-
- private static final String uriString = "https://example.com";
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- doReturn(futureMock).when(clientMock).futureRead((RosettaDF<?>)any(), eq(TYPE.JSON));
- when(clientMock.timeout()).thenReturn(1);
- when(clientMock.getURI()).thenReturn(new URI(uriString));
- when(futureMock.get(1)).thenReturn(true);
-
- futureMock.value = endpointsMock;
- List<Endpoint> endpoints = new ArrayList<>();
- endpoints.add(new Endpoint());
- when(endpointsMock.getEndpoint()).thenReturn(endpoints);
-
- access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
-
- errStream = new ByteArrayOutputStream();
-
- System.setErr(new PrintStream(errStream));
- }
-
- @After
- public void tearDown() {
- System.setErr(System.err);
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- Field field = SecurityInfoC.class.getDeclaredField("sicMap");
- field.setAccessible(true);
- field.set(null, new HashMap<>());
- }
-
- @Test
- public void test() throws CadiException, URISyntaxException, LocatorException {
- access.setProperty(Config.CADI_LATITUDE, "38.62"); // St Louis approx lat
- access.setProperty(Config.CADI_LONGITUDE, "90.19"); // St Louis approx lon
- SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
- URI locatorURI = new URI("https://somemachine.moc:10/com.att.aaf.service:2.0");
- AbsAAFLocator<BasicTrans> al = new AAFLocator(si, locatorURI) {
- @Override
- protected HClient createClient(SecuritySetter<HttpURLConnection> ss, URI uri, int connectTimeout) throws LocatorException {
- return clientMock;
- }
- };
- // Start over: This was originally calling a developer machine.
-// assertThat(al.refresh(), is(true));
-// when(futureMock.get(1)).thenReturn(false);
-// assertThat(al.refresh(), is(false));
-// String errorMessage = errStream.toString().split(": ", 2)[1];
-// assertThat(errorMessage, is("Error reading location information from " + uriString + ": 0 null\n \n"));
- }
+
+ @Mock private HClient clientMock;
+ @Mock private Future<Endpoints> futureMock;
+ @Mock private Endpoints endpointsMock;
+
+ private PropAccess access;
+
+ private ByteArrayOutputStream errStream;
+
+ private static final String uriString = "https://example.com";
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ doReturn(futureMock).when(clientMock).futureRead((RosettaDF<?>)any(), eq(TYPE.JSON));
+ when(clientMock.timeout()).thenReturn(1);
+ when(clientMock.getURI()).thenReturn(new URI(uriString));
+ when(futureMock.get(1)).thenReturn(true);
+
+ futureMock.value = endpointsMock;
+ List<Endpoint> endpoints = new ArrayList<>();
+ endpoints.add(new Endpoint());
+ when(endpointsMock.getEndpoint()).thenReturn(endpoints);
+
+ access = new PropAccess(new PrintStream(new ByteArrayOutputStream()), new String[0]);
+
+ errStream = new ByteArrayOutputStream();
+
+ System.setErr(new PrintStream(errStream));
+ }
+
+ @After
+ public void tearDown() {
+ System.setErr(System.err);
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ Field field = SecurityInfoC.class.getDeclaredField("sicMap");
+ field.setAccessible(true);
+ field.set(null, new HashMap<>());
+ }
+
+ @Test
+ public void test() throws CadiException, URISyntaxException, LocatorException {
+ access.setProperty(Config.CADI_LATITUDE, "38.62"); // St Louis approx lat
+ access.setProperty(Config.CADI_LONGITUDE, "90.19"); // St Louis approx lon
+ SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
+ URI locatorURI = new URI("https://somemachine.moc:10/com.att.aaf.service:2.0");
+// AbsAAFLocator<BasicTrans> al = new AAFLocator(si, locatorURI) {
+// @Override
+// protected HClient createClient(SecuritySetter<HttpURLConnection> ss, URI uri, int connectTimeout) throws LocatorException {
+// return clientMock;
+// }
+// };
+ // Start over: This was originally calling a developer machine.
+// assertThat(al.refresh(), is(true));
+// when(futureMock.get(1)).thenReturn(false);
+// assertThat(al.refresh(), is(false));
+// String errorMessage = errStream.toString().split(": ", 2)[1];
+// assertThat(errorMessage, is("Error reading location information from " + uriString + ": 0 null\n \n"));
+ }