Exemple #1
0
 public static boolean isUriInetAddress(String paramString) {
   try {
     forUriString(paramString);
     return true;
   } catch (IllegalArgumentException localIllegalArgumentException) {
   }
   return false;
 }
  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
    }
  }
 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]"));
 }
 public void testForUriStringIPv4Mapped() {
   Inet4Address expected = (Inet4Address) InetAddresses.forString("192.0.2.1");
   assertEquals(expected, InetAddresses.forUriString("[::ffff:192.0.2.1]"));
 }
 public void testForUriStringIPv4() {
   Inet4Address expected = (Inet4Address) InetAddresses.forString("192.168.1.1");
   assertEquals(expected, InetAddresses.forUriString("192.168.1.1"));
 }