Package org.dhcp4java

Examples of org.dhcp4java.DHCPOption


    new DHCPOption(DHO_END, null);
  }

  @Test
  public void testConstructor() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_MESSAGE, buf0);
   
    assertEquals(opt.getCode(), DHO_DHCP_MESSAGE);
    assertFalse(opt.isMirror());
    assertTrue(Arrays.equals(opt.getValue(), buf0));
    assertTrue(opt.getValue() != buf0);    // value should be cloned
  }
View Full Code Here


    assertTrue(opt.getValue() != buf0);    // value should be cloned
  }
 
  @Test
  public void testConstructorNull() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_MESSAGE, null);
   
    assertEquals(opt.getCode(), DHO_DHCP_MESSAGE);
    assertFalse(opt.isMirror());
    assertEquals(opt.getValue(), null);
  }
View Full Code Here

    assertEquals(opt.getValue(), null);
  }
 
  @Test
  public void testEquals() {
    DHCPOption opt1 = new DHCPOption(DHO_BOOTFILE, buf0);
    DHCPOption opt2 = new DHCPOption(DHO_BOOTFILE, buf0.clone());
   
    assertTrue(opt1.equals(opt1));
    assertTrue(opt1.equals(opt2));
    assertTrue(opt2.equals(opt1));
    assertFalse(opt1.equals(null));
    assertFalse(opt1.equals(new Integer(1)));
    assertFalse(opt1.equals(new DHCPOption(DHO_BOOTFILE, null)));
  }
View Full Code Here

    assertFalse(opt1.equals(new Integer(1)));
    assertFalse(opt1.equals(new DHCPOption(DHO_BOOTFILE, null)));
  }
  @Test
  public void testEqualsNull() {
    DHCPOption opt1 = new DHCPOption(DHO_BOOTFILE, null);
    DHCPOption opt2 = new DHCPOption(DHO_BOOTFILE, null);
   
    assertTrue(opt1.equals(opt1));
    assertTrue(opt1.equals(opt2));
    assertTrue(opt2.equals(opt1));
    assertFalse(opt1.equals(null));
    assertFalse(opt1.equals(new Integer(1)));
    assertFalse(opt1.equals(new DHCPOption(DHO_BOOTFILE, buf0)));
  }
View Full Code Here

    assertFalse(opt1.equals(new Integer(1)));
    assertFalse(opt1.equals(new DHCPOption(DHO_BOOTFILE, buf0)));
  }
  @Test
  public void testEqualsMirror() {
    DHCPOption opt1 = new DHCPOption(DHO_BOOTFILE, null);
    DHCPOption opt2 = new DHCPOption(DHO_BOOTFILE, null, false);
    DHCPOption opt3 = new DHCPOption(DHO_BOOTFILE, null, true);
    DHCPOption opt4 = new DHCPOption(DHO_BOOTFILE, null, true);
   
    assertTrue(opt1.equals(opt1));
    assertTrue(opt1.equals(opt2));
    assertTrue(opt2.equals(opt1));
   
    assertTrue(opt3.equals(opt3));
    assertTrue(opt3.equals(opt4));
    assertTrue(opt4.equals(opt3));
   
    assertFalse(opt1.equals(opt3));
    assertFalse(opt3.equals(opt1));
  }
View Full Code Here

    assertFalse(opt3.equals(opt1));
  }
 
  @Test
  public void testHashCode() {
    DHCPOption opt1 = new DHCPOption(DHO_BOOTFILE, buf0);
    DHCPOption opt2 = new DHCPOption(DHO_DHCP_MESSAGE, buf0);
    assertTrue(opt1.hashCode() != 0);
    assertTrue(opt1.hashCode() != opt2.hashCode());
  }
View Full Code Here

    assertTrue(opt1.hashCode() != opt2.hashCode());
  }
 
  @Test
  public void testToString() {
    DHCPOption opt1 = new DHCPOption(DHO_BOOTFILE, buf0);
    assertEquals(opt1.toString(), "DHO_BOOTFILE(67)=\"foobar\"");
  }
View Full Code Here

  // high level static constructors
 
  // Byte
  @Test
  public void testNewOptionAsByteGetValueAsByte() {
    DHCPOption opt = DHCPOption.newOptionAsByte(DHO_IP_FORWARDING, (byte)1);
    assertEquals(opt.getCode(), DHO_IP_FORWARDING);
    assertTrue(Arrays.equals(opt.getValue(), HexUtils.hexToBytes("01")));
   
    assertEquals(opt.getValueAsByte(), (byte) 1);
  }
View Full Code Here

  public void testNewOptionAsByteBad() {
    DHCPOption.newOptionAsByte(DHO_DHCP_LEASE_TIME, (byte) 0);
  }
  @Test (expected=IllegalArgumentException.class)
  public void testGetValueAsByteBad() {
    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[0]);
    opt.getValueAsByte();
  }
View Full Code Here

    DHCPOption opt = new DHCPOption(DHO_DHCP_LEASE_TIME, new byte[0]);
    opt.getValueAsByte();
  }
  @Test (expected=IllegalStateException.class)
  public void testGetValueAsByteIllegalState() {
    DHCPOption opt = new DHCPOption(DHO_IP_FORWARDING, null);
    opt.getValueAsByte();
  }
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.