Examples of DHCPOption


Examples of org.dhcp4java.DHCPOption

    public void testConstructorPad() {
      new DHCPOption((byte)0, null, true);    // 0 is reserved for padding
    }
    @Test (expected=IllegalArgumentException.class)
    public void testConstructorEnd() {
      new DHCPOption((byte)0xFF, null, true)// 0xFF is reserved for "end of options"
    }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

      new DHCPOption((byte)0xFF, null, true)// 0xFF is reserved for "end of options"
    }

    @Before
    public void setupOpt() {
      opt = new DHCPOption(DHO_DHCP_LEASE_TIME, null, true);
    }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

      assertNull(opt.getValue());
    }
   
    @Test
    public void testGetMirrorValue() {
      DHCPOption mirrorOpt;
      DHCPPacket pac = new DHCPPacket();
      assertEquals(opt, opt.applyOption(pac));
     
      pac.setOptionAsInt(DHO_DHCP_LEASE_TIME, 86400);
     
      mirrorOpt = opt.applyOption(pac);
      assertEquals(DHO_DHCP_LEASE_TIME, mirrorOpt.getCode());
      assertTrue(Arrays.equals(DHCPOption.int2Bytes(86400), mirrorOpt.getValue()));
     
      pac.setOptionRaw(DHO_DHCP_LEASE_TIME, new byte[0]);
      mirrorOpt = opt.applyOption(pac);
      assertEquals(DHO_DHCP_LEASE_TIME, mirrorOpt.getCode());
      assertTrue(Arrays.equals(new byte[0], mirrorOpt.getValue()));
    }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

      opt.applyOption(null);
    }
   
    @Test
    public void testGetMirrorValueIfMirrorIsFalse() {
      DHCPOption opt2 = new DHCPOption(DHO_DHCP_LEASE_TIME, null, false);
      DHCPOption mirrorOpt;
      DHCPPacket pac = new DHCPPacket();
      assertEquals(opt2, opt2.applyOption(pac));
      pac.setOptionAsInt(DHO_DHCP_LEASE_TIME, 86400);
     
      mirrorOpt = opt2.applyOption(pac);
      assertEquals(DHO_DHCP_LEASE_TIME, mirrorOpt.getCode());
      assertEquals(opt2, mirrorOpt)// not mirrored here since isMirror is false
    }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

    }
    @Test
    public void testSetOptionNull() {
      pac0.setOptionRaw(DHO_BOOTFILE, hexToBytes("FF005498"));
      assertNotNull(pac0.getOptionRaw(DHO_BOOTFILE));
      pac0.setOption(new DHCPOption(DHO_BOOTFILE, null));
      assertFalse(pac0.containsOption(DHO_BOOTFILE));
      assertNull(pac0.getOptionRaw(DHO_BOOTFILE));
    }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

         return new JUnit4TestAdapter(DHCPOptionTest.class);
      }
 
  @Test (expected=IllegalArgumentException.class)
  public void testConstructorFailPad(){
    new DHCPOption(DHO_PAD, null);
  }
View Full Code Here

Examples of org.dhcp4java.DHCPOption

  public void testConstructorFailPad(){
    new DHCPOption(DHO_PAD, null);
  }
  @Test (expected=IllegalArgumentException.class)
  public void testConstructorFailEnd(){
    new DHCPOption(DHO_END, null);
  }
View Full Code Here

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

Examples of org.dhcp4java.DHCPOption

    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

Examples of org.dhcp4java.DHCPOption

    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
TOP
Copyright © 2018 www.massapi.com. 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.