示例#1
0
 public static boolean isUriInetAddress(String paramString) {
   try {
     forUriString(paramString);
     return true;
   } catch (IllegalArgumentException localIllegalArgumentException) {
   }
   return false;
 }
示例#2
0
  public void testForUriStringBad() {
    try {
      InetAddresses.forUriString("");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("192.168.999.888");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("www.google.com");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("[1:2e]");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("[192.168.1.1]");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("192.168.1.1]");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("[192.168.1.1");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1]");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("3ffe:0:0:0:0:0:0:1");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }

    try {
      InetAddresses.forUriString("::ffff:192.0.2.1");
      fail("expected IllegalArgumentException"); // COV_NF_LINE
    } catch (IllegalArgumentException e) {
      // expected
    }
  }
示例#3
0
 public void testForUriStringIPv6() {
   Inet6Address expected = (Inet6Address) InetAddresses.forString("3ffe:0:0:0:0:0:0:1");
   assertEquals(expected, InetAddresses.forUriString("[3ffe:0:0:0:0:0:0:1]"));
 }
示例#4
0
 public void testForUriStringIPv4Mapped() {
   Inet4Address expected = (Inet4Address) InetAddresses.forString("192.0.2.1");
   assertEquals(expected, InetAddresses.forUriString("[::ffff:192.0.2.1]"));
 }
示例#5
0
 public void testForUriStringIPv4() {
   Inet4Address expected = (Inet4Address) InetAddresses.forString("192.168.1.1");
   assertEquals(expected, InetAddresses.forUriString("192.168.1.1"));
 }