Package java.net

Examples of java.net.Inet6Address


  }

  @Test
  public void testCompareGreater6() throws UnknownHostException {

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


  }

  @Test
  public void testCompareLesser6() throws UnknownHostException {

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

 
  @Test
  public void testCompareDifferentVersions() throws UnknownHostException {
   
    Inet4Address ipv4 = Inet4AddressComparatorTest.ip("10.10.10.10");
    Inet6Address ipv6 = Inet6AddressComparatorTest.ip("1111:1111:1111:1111:1111:1111:1111:1111");
   
    Assert.assertTrue(V4_LESS.compare(ipv4, ipv6) < 0);
    Assert.assertTrue(V4_LESS.compare(ipv6, ipv4) > 0);
    Assert.assertTrue(V6_LESS.compare(ipv4, ipv6) > 0);
    Assert.assertTrue(V6_LESS.compare(ipv6, ipv4) < 0);
View Full Code Here

  /**
   * @tests java.net.Inet6Address#isIPv4CompatibleAddress()
   */
  public void test_isIPv4CompatibleAddress() throws Exception {
    String addrName = "";
    Inet6Address addr = null;

                // Tests a number of addresses to see if they are compatable with
                // IPv6 addresses

                addrName = "FFFF::42:42"; // 11111111 = FFFF
                addr = (Inet6Address) InetAddress.getByName(addrName);
                assertTrue("A non-compatable IPv6 address " + addrName
                                + " incorrectly identified as a IPv4 compatable address.",
                                !addr.isIPv4CompatibleAddress());

                // IPv4-compatible IPv6 address tests
                //
                // Now create 2 IP v6 addresses that are IP v4 compatable
                // to IP v6 addresses.

                addrName = "::0.0.0.0";
                addr = (Inet6Address) InetAddress.getByName(addrName);
                assertTrue("IPv4 compatable address " + addrName
                                + " not detected correctly.", addr
                                .isIPv4CompatibleAddress());

                addrName = "::255.255.255.255"; // an ipv4 non-multicast address
                addr = (Inet6Address) InetAddress.getByName(addrName);
                assertTrue("IPv4 compatable address " + addrName
                                + " not detected correctly.", addr
                                .isIPv4CompatibleAddress());
  }
View Full Code Here

  /**
   * @throws UnknownHostException
   * @tests java.net.Inet6Address#getScopeID()
   */
  public void test_getScopeID() throws UnknownHostException {
    Inet6Address v6ia;
    byte[] addr = { (byte) 0xFE, (byte) 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x11,
        0x25, (byte) 0xFF, (byte) 0xFE, (byte) 0xF8, (byte) 0x7C,
        (byte) 0xB2 };

    v6ia = Inet6Address.getByAddress("123", addr, 3);
    assertEquals(3, v6ia.getScopeId());

    v6ia = Inet6Address.getByAddress("123", addr, 0);
    assertEquals(0, v6ia.getScopeId());

    v6ia = Inet6Address.getByAddress("123", addr, -1);
    assertEquals(0, v6ia.getScopeId());
  }
View Full Code Here

   */
  public void test_getScopedInterface() throws UnknownHostException {
    byte[] addr = { (byte) 0xFE, (byte) 0x80, (byte) 0x09, (byte) 0xb5,
        (byte) 0x6b, (byte) 0xa4, 0, 0, 0, 0, 0, 0, (byte) 0x09,
        (byte) 0xb5, (byte) 0x6b, (byte) 0xa4 };
    Inet6Address v6Addr;
    v6Addr = Inet6Address.getByAddress("123", addr, null);
    assertNull(v6Addr.getScopedInterface());
  }
View Full Code Here

     */
    public void test_hashCode() throws UnknownHostException{
        byte[] addr = { (byte) 0xFE, (byte) 0x80, 0, 0, 0, 0, 0, 0, 0x02, 0x11,
                0x25, (byte) 0xFF, (byte) 0xFE, (byte) 0xF8, (byte) 0x7C,
                (byte) 0xB2 };
        Inet6Address address1, address2;
       
        address1 = Inet6Address.getByAddress("123", addr, 0);
        address2 = Inet6Address.getByAddress("1234", addr, 0);
        assertEquals(address1.hashCode(), address2.hashCode());
    }
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

                return Float.parseFloat(propertyValue);
            } else if(InetAddress.class.equals(propertyFieldType)) {
                InetAddress retval=InetAddress.getByName(propertyValue);
                if(check_scope && retval instanceof Inet6Address && retval.isLinkLocalAddress()) {
                    // check scope
                    Inet6Address addr=(Inet6Address)retval;
                    int scope=addr.getScopeId();
                    if(scope == 0) {
                        // fix scope
                        Inet6Address ret=getScopedInetAddress(addr);
                        if(ret != null) {
                            //if(log.isWarnEnabled())
                              //  log.warn("added scope-id to link-local IPv6 address " + ret + ", but you should change " +
                                //        propertyName + " to include a scope-id");
                            retval=ret;
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.