Package org.dhcp4java

Examples of org.dhcp4java.DHCPPacket.serialize()


    // serialize
    @Test
    public void testSerializeLimits() {
      byte[] buf;
      DHCPPacket pac = new DHCPPacket();
      buf = pac.serialize();
      assertEquals(300, buf.length);
     
      pac.setOptionRaw(DHO_HOST_NAME, new byte[255]);
      buf = pac.serialize();
      assertEquals(498, buf.length);
View Full Code Here


      DHCPPacket pac = new DHCPPacket();
      buf = pac.serialize();
      assertEquals(300, buf.length);
     
      pac.setOptionRaw(DHO_HOST_NAME, new byte[255]);
      buf = pac.serialize();
      assertEquals(498, buf.length);
     
      buf = pac.serialize(1500, 1500);
      assertEquals(1500, buf.length);
    }
View Full Code Here

     
      pac.setOptionRaw(DHO_HOST_NAME, new byte[255]);
      buf = pac.serialize();
      assertEquals(498, buf.length);
     
      buf = pac.serialize(1500, 1500);
      assertEquals(1500, buf.length);
    }
    @Test (expected=DHCPBadPacketException.class)
    public void testSerializeOptionOver256() {
      DHCPPacket pac = new DHCPPacket();
View Full Code Here

    }
    @Test (expected=DHCPBadPacketException.class)
    public void testSerializeOptionOver256() {
      DHCPPacket pac = new DHCPPacket();
      pac.setOptionRaw(DHO_HOST_NAME, new byte[256]);
      pac.serialize();
    }
    @Test (expected=DHCPBadPacketException.class)
    public void testSerializePacketTooBig() {
      DHCPPacket pac = new DHCPPacket();
      pac.setOptionRaw((byte)11, new byte[255]);
View Full Code Here

      pac.setOptionRaw((byte)11, new byte[255]);
      pac.setOptionRaw((byte)12, new byte[255]);
      pac.setOptionRaw((byte)13, new byte[255]);
      pac.setOptionRaw((byte)14, new byte[255]);
      pac.setOptionRaw((byte)15, new byte[255]);
      pac.serialize();
    }
   
    // Limit tests for setters/getter
    @Test
    public void testSetCHAddrUnderLimit() {
View Full Code Here

      DHCPServletTestServletWithGoodResponse servlet2 = new DHCPServletTestServletWithGoodResponse();
      DHCPPacket pac = new DHCPPacket();
      pac.setDHCPMessageType(DHCPDISCOVER);
      pac.setOp(BOOTREQUEST);
      servlet2.postProcessPassed = false;
      byte[] buf = pac.serialize();
      DatagramPacket udp = new DatagramPacket(buf, buf.length);
     
      servlet2.addressToReturn = null;
      servlet2.portToReturn = 0;
      assertNull(servlet2.serviceDatagram(udp));    // reject is address returned is null
View Full Code Here

    public void testDiscover() throws Exception {
      byte[] buf;
      DatagramPacket udp;
      DHCPPacket pac = new DHCPPacket();
      pac.setOp(BOOTREQUEST);
      buf = pac.serialize();
      udp = new DatagramPacket(buf, buf.length);
      udp.setAddress(InetAddress.getByName(SERVER_ADDR));
      udp.setPort(SERVER_PORT);
      socket.send(udp);
      udp = new DatagramPacket(new byte[1500], 1500);
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.