X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fclient%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Flocator%2Ftest%2FJU_DNSLocator.java;h=69632e57a44d0af47c330b27cbd887acaf4653ca;hb=861b557b294032f9443ee1fca6b42d7252e92481;hp=e2c8f82831f2a09cec41b41f41772f0cc64bbd43;hpb=1296352d8eafee57f982a4342ad79ada4aa56d28;p=aaf%2Fauthz.git diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java index e2c8f828..69632e57 100644 --- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java +++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java @@ -22,12 +22,15 @@ package org.onap.aaf.cadi.locator.test; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.anyOf; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.io.ByteArrayOutputStream; import java.io.PrintStream; +import java.net.InetAddress; import java.net.URI; +import java.net.UnknownHostException; import org.junit.Before; import org.junit.Test; @@ -56,9 +59,9 @@ public class JU_DNSLocator { item = dl.best(); uri = dl.get(item); - assertThat(uri.toString(), is("https://localhost:8100")); + assertThat(uri.toString(), anyOf(is("https://localhost:8100"), is("https://127.0.0.1:8100"))); item = dl.best(); - assertThat(uri.toString(), is("https://localhost:8100")); + assertThat(uri.toString(), anyOf(is("https://localhost:8100"), is("https://127.0.0.1:8100"))); assertThat(dl.hasItems(), is(true)); for (item = dl.first(); item != null; item = dl.next(item)) { @@ -94,8 +97,17 @@ public class JU_DNSLocator { @Test public void refreshTest() throws LocatorException { - DNSLocator dl = new DNSLocator(access, "https", "bogushost", "8100-8101"); - assertThat(dl.refresh(), is(false)); + DNSLocator dl = new DNSLocator(access, "https", "bogushost", "8100-8101", + // Note: Lambda would be nice but need JDK 1.7 still + // PowerMock couldn't do InetAddress + new DNSLocator.DNSLookup() { + @Override + public InetAddress[] getAllByName(String host) throws UnknownHostException { + return new InetAddress[0]; + } + } + ); + assertThat(dl.refresh(), is(true)); } @Test(expected = LocatorException.class)