Package org.dhcp4java

Examples of org.dhcp4java.DHCPOption


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


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

    DHCPOption opt = new DHCPOption(DHO_WWW_SERVER, new byte[3]);
    opt.getValueAsInetAddrs();
  }
  @Test (expected=DHCPBadPacketException.class)
  public void testGetValueAsInetAddressesBadSize9() {
    DHCPOption opt = new DHCPOption(DHO_WWW_SERVER, new byte[9]);
    opt.getValueAsInetAddrs();
  }
View Full Code Here

  }

  // String
  @Test
  public void testNewOptionAsStringGetValueAsString() {
    DHCPOption opt = DHCPOption.newOptionAsString(DHO_TFTP_SERVER, "foobar");
    assertEquals(DHO_TFTP_SERVER, opt.getCode());
    assertTrue(Arrays.equals("foobar".getBytes(), opt.getValue()));
   
    assertEquals("foobar", opt.getValueAsString());
   
    opt = new DHCPOption(DHO_TFTP_SERVER, new byte[0]);
    assertEquals("", opt.getValueAsString());
    opt = new DHCPOption(DHO_TFTP_SERVER, new byte[1]);
    assertEquals("", opt.getValueAsString());
    opt = new DHCPOption(DHO_TFTP_SERVER, new byte[2]);
    assertEquals("", opt.getValueAsString());
  }
View Full Code Here

  public void testNewOptionAsStringBad() {
    DHCPOption.newOptionAsString(DHO_SUBNET_MASK, "foo");
  }
  @Test (expected=IllegalArgumentException.class)
  public void testGetValueAsStringBad() {
    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, "foobar".getBytes());
    opt.getValueAsString();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, "foobar".getBytes());
    opt.getValueAsString();
  }
  @Test (expected=IllegalStateException.class)
  public void testGetValueAsStringIllegalState() {
    DHCPOption opt = new DHCPOption(DHO_TFTP_SERVER, null);
    opt.getValueAsString();
  }
View Full Code Here

  // Bytes
  @Test
  public void testGetValueAsBytes() {
    byte[] bb = HexUtils.hexToBytes("00010000FC0AE003FFFFFFFF");
    DHCPOption opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, bb);
    assertEquals(DHO_DHCP_PARAMETER_REQUEST_LIST, opt.getCode());
    assertTrue(Arrays.equals(HexUtils.hexToBytes("00010000FC0AE003FFFFFFFF"), opt.getValue()));
    assertTrue(Arrays.equals(HexUtils.hexToBytes("00010000FC0AE003FFFFFFFF"), opt.getValueAsBytes()));
   
    opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, new byte[0]);
    assertTrue(Arrays.equals(new byte[0], opt.getValueAsBytes()));
    opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, new byte[1]);
    assertTrue(Arrays.equals(HexUtils.hexToBytes("00"), opt.getValueAsBytes()));
    opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, new byte[2]);
    assertTrue(Arrays.equals(HexUtils.hexToBytes("0000"), opt.getValueAsBytes()));
  }
View Full Code Here

    opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, new byte[2]);
    assertTrue(Arrays.equals(HexUtils.hexToBytes("0000"), opt.getValueAsBytes()));
  }
  @Test (expected=IllegalArgumentException.class)
  public void testGetValueAsBytesBad() {
    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, new byte[1]);
    opt.getValueAsBytes();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_SUBNET_MASK, new byte[1]);
    opt.getValueAsBytes();
  }
  @Test (expected=IllegalStateException.class)
  public void testGetValueAsBytesIllegalState() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_PARAMETER_REQUEST_LIST, null);
    opt.getValueAsBytes();
  }
View Full Code Here

  // append
 
  @Test
  public void testAppendNullValue() {
    StringBuilder buf;
    DHCPOption opt;

    buf = new StringBuilder();
    opt = new DHCPOption((byte) -2, null);
    opt.append(buf);
    assertEquals("(254)=<null>", buf.toString());

    buf = new StringBuilder();
    opt = new DHCPOption(DHO_DHCP_MESSAGE_TYPE, null);
    opt.append(buf);
    assertEquals("DHO_DHCP_MESSAGE_TYPE(53)=<null>", buf.toString());
   
    buf = new StringBuilder();
    opt = new DHCPOption(DHO_DHCP_LEASE_TIME, null);
    opt.append(buf);
    assertEquals("DHO_DHCP_LEASE_TIME(51)=<null>", buf.toString());
  }
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.