Package org.dhcp4java

Examples of org.dhcp4java.DHCPOption


    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[3]);
    opt.getValueAsInt();
  }
  @Test (expected=DHCPBadPacketException.class)
  public void testGetValueAsIntBadSize5() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[5]);
    opt.getValueAsInt();
  }
View Full Code Here


  }
 
  // Num
  @Test
  public void testNewOptionAsIntGetValueAsNum() {
    DHCPOption opt;
    opt = DHCPOption.newOptionAsInt(DHO_DHCP_LEASE_TIME, 0x01FE02FC);
    assertEquals(Integer.valueOf(0x01FE02FC), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsShort(DHO_INTERFACE_MTU, (short)1500);
    assertEquals(Integer.valueOf(1500), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsByte(DHO_IP_FORWARDING, (byte)1);
    assertEquals(Integer.valueOf(1), opt.getValueAsNum());
    opt = DHCPOption.newOptionAsString(DHO_TFTP_SERVER, "foobar");
    assertNull(opt.getValueAsNum());
    opt = DHCPOption.newOptionAsString(DHO_TFTP_SERVER, null);
    assertNull(opt.getValueAsNum());
  }
View Full Code Here

  }
 
  // InetAddress
  @Test
  public void testNewOptionAsInetAddressGetValueAsInetAddress() throws Exception {
    DHCPOption opt = DHCPOption.newOptionAsInetAddress(DHO_SUBNET_MASK,
                      InetAddress.getByName("252.10.224.3"));
    assertEquals(opt.getCode(), DHO_SUBNET_MASK);
    assertTrue(Arrays.equals(opt.getValue(), HexUtils.hexToBytes("FC0AE003")));
   
    assertEquals(opt.getValueAsInetAddr(), InetAddress.getByName("252.10.224.3"));
  }
View Full Code Here

   
    assertEquals(opt.getValueAsInetAddr(), InetAddress.getByName("252.10.224.3"));
  }
  @Test
  public void testNewOptionAsInetAddressGetValueAsInetAddressSingle() throws Exception {
    DHCPOption opt = DHCPOption.newOptionAsInetAddress(DHO_WWW_SERVER,
                      InetAddress.getByName("252.10.224.3"));
    assertEquals(opt.getCode(), DHO_WWW_SERVER);
    assertTrue(Arrays.equals(opt.getValue(), HexUtils.hexToBytes("FC0AE003")));
   
    InetAddress[] iadrs = opt.getValueAsInetAddrs();
    assertNotNull(iadrs);
    assertEquals(1, iadrs.length);
    assertEquals(InetAddress.getByName("252.10.224.3"), iadrs[0]);
  }
View Full Code Here

  public void testNewOptionAsInetAddressBad() throws Exception {
    DHCPOption.newOptionAsInetAddress(DHO_DHCP_LEASE_TIME, InetAddress.getByName("252.10.224.3"));
  }
  @Test (expected=IllegalArgumentException.class)
  public void testGetValueAsInetAddressBad() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[0]);
    opt.getValueAsInetAddr();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[0]);
    opt.getValueAsInetAddr();
  }
  @Test (expected=IllegalStateException.class)
  public void testGetValueAsInetAddressIllegalState() {
    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, null);
    opt.getValueAsInetAddr();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, null);
    opt.getValueAsInetAddr();
  }
  @Test (expected=DHCPBadPacketException.class)
  public void testGetValueAsInetAddressBadSize3() {
    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, new byte[3]);
    opt.getValueAsInetAddr();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, new byte[3]);
    opt.getValueAsInetAddr();
  }
  @Test (expected=DHCPBadPacketException.class)
  public void testGetValueAsInetAddressBadSize5() {
    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, new byte[5]);
    opt.getValueAsInetAddr();
  }
View Full Code Here

  public void testNewOptionAsInetAddressesGetValueAsInetAddresses() throws Exception {
    InetAddress[] iadrs = new InetAddress[3];
    iadrs[0] = InetAddress.getByName("0.0.0.0");
    iadrs[1] = InetAddress.getByName("252.10.224.3");
    iadrs[2] = InetAddress.getByName("255.255.255.255");
    DHCPOption opt = DHCPOption.newOptionAsInetAddresses(DHO_WWW_SERVER, iadrs);
    assertEquals(DHO_WWW_SERVER, opt.getCode());
    assertTrue(Arrays.equals(HexUtils.hexToBytes("00000000FC0AE003FFFFFFFF"), opt.getValue()));
   
    assertTrue(Arrays.equals(iadrs, opt.getValueAsInetAddrs()));
  }
View Full Code Here

    iadrs[0] = InetAddress.getByName("0.0.0.0");
    DHCPOption.newOptionAsInetAddresses(DHO_DHCP_LEASE_TIME, iadrs);
  }
  @Test (expected=IllegalArgumentException.class)
  public void testGetValueAsInetAddressesBad() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[0]);
    opt.getValueAsInetAddrs();
  }
View Full Code Here

TOP

Related Classes of org.dhcp4java.DHCPOption

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.