Package java.net

Examples of java.net.Inet6Address


    Inet4Address expected = (Inet4Address) InetAddresses.forString("192.168.1.1");
    assertEquals(expected, InetAddresses.forUriString("192.168.1.1"));
  }

  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]"));
  }
View Full Code Here


      }
    }
  }

  public void testGetEmbeddedIPv4ClientAddress() {
    Inet6Address testIp;

    // Test regular global unicast address.
    testIp = (Inet6Address) InetAddresses.forString("2001:db8::1");
    assertFalse(InetAddresses.hasEmbeddedIPv4ClientAddress(testIp));
View Full Code Here

      return LOOPBACK4;  // ::1
    } else if (leadingBytesOfZero && (bytes[15] == 0)) {
      return ANY4;  // ::0
    }

    Inet6Address ip6 = (Inet6Address) ip;
    long addressAsLong = 0;
    if (hasEmbeddedIPv4ClientAddress(ip6)) {
      addressAsLong = getEmbeddedIPv4ClientAddress(ip6).hashCode();
    } else {

      // Just extract the high 64 bits (assuming the rest is user-modifiable).
      addressAsLong = ByteBuffer.wrap(ip6.getAddress(), 0, 8).getLong();
    }

    // Many strategies for hashing are possible.  This might suffice for now.
    int coercedHash = hash64To32(addressAsLong);
View Full Code Here

      // HORNETQ-907 - strip off IPv6 scope-id (if necessary)
      remoteDestination = new InetSocketAddress(host, port);
      InetAddress inetAddress = ((InetSocketAddress) remoteDestination).getAddress();
      if (inetAddress instanceof Inet6Address)
      {
         Inet6Address inet6Address = (Inet6Address) inetAddress;
         if (inet6Address.getScopeId() != 0)
         {
            try
            {
               remoteDestination = new InetSocketAddress(InetAddress.getByAddress(inet6Address.getAddress()), ((InetSocketAddress) remoteDestination).getPort());
            }
            catch (UnknownHostException e)
            {
               throw new IllegalArgumentException(e.getMessage());
            }
View Full Code Here

      // HORNETQ-907 - strip off IPv6 scope-id (if necessary)
      remoteDestination = new InetSocketAddress(host, port);
      InetAddress inetAddress = ((InetSocketAddress) remoteDestination).getAddress();
      if (inetAddress instanceof Inet6Address)
      {
         Inet6Address inet6Address = (Inet6Address) inetAddress;
         if (inet6Address.getScopeId() != 0)
         {
            try
            {
               remoteDestination = new InetSocketAddress(InetAddress.getByAddress(inet6Address.getAddress()), ((InetSocketAddress) remoteDestination).getPort());
            }
            catch (UnknownHostException e)
            {
               throw new IllegalArgumentException(e.getMessage());
            }
View Full Code Here

                tryToConnect(address.getInetSocketAddress(), 0);
            } else if (thisAddress.isIPv6() && thisAddress.getScopeId() != null) {
                // Both remote and this addresses are IPv6.
                // This is a local IPv6 address and scope id is known.
                // find correct inet6 address for remote and connect...
                final Inet6Address inetAddress = AddressUtil
                        .getInetAddressFor((Inet6Address) address.getInetAddress(), thisAddress.getScopeId());
                tryToConnect(new InetSocketAddress(inetAddress, address.getPort()), 0);
            } else {
                // remote is IPv6 and this is either IPv4 or a global IPv6.
                // find possible remote inet6 addresses and try each one to connect...
View Full Code Here

  }

  @Test
  public void testCompareEqual() throws UnknownHostException {

    final Inet6Address ip1 = ip("1111:1111:1111:1111:1111:1111:1111:1111");
    final Inet6Address ip2 = ip("1111:1111:1111:1111:1111:1111:1111:1111");
    Assert.assertEquals(0, COMPARATOR.compare(ip1, ip2));
  }
View Full Code Here

  }

  @Test
  public void testCompareGreater() throws UnknownHostException {

    final Inet6Address ip1 = ip("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF");
    final Inet6Address ip2 = ip("AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA:AAAA");
    Assert.assertTrue(COMPARATOR.compare(ip1, ip2) > 0);
  }
View Full Code Here

  }

  @Test
  public void testCompareLesser() throws UnknownHostException {

    final Inet6Address ip1 = ip("6666:6666:6666:6666:6666:6666:6666:6666");
    final Inet6Address ip2 = ip("7777:7777:7777:7777:7777:7777:7777:7777");
    Assert.assertTrue(COMPARATOR.compare(ip1, ip2) < 0);
  }
View Full Code Here

  }

  @Test
  public void testCompareEqual6() throws UnknownHostException {

    final Inet6Address ip1 = Inet6AddressComparatorTest
        .ip("1111:1111:1111:1111:1111:1111:1111:1111");
    final Inet6Address ip2 = Inet6AddressComparatorTest
        .ip("1111:1111:1111:1111:1111:1111:1111:1111");
    Assert.assertEquals(0, V6_LESS.compare(ip1, ip2));
  }
View Full Code Here

TOP

Related Classes of java.net.Inet6Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.