Code example for DatagramPacket

Methods: getLengthsetLength

0
 
    /** 
     * @tests java.net.DatagramPacket#setLength(int) 
     */ 
    public void test_setLengthI() { 
        DatagramPacket dp = new DatagramPacket("Hello".getBytes(), 5);
        dp.setLength(1);
        assertEquals("Failed to set packet length", 1, dp.getLength());
    } 
 
    /** 
     * @tests java.net.DatagramPacket#setPort(int) 
     */ 
    public void test_setPortI() throws Exception { 
        DatagramPacket dp = new DatagramPacket("Hello".getBytes(), 5,
                InetAddress.getLocalHost(), 1000);
        dp.setPort(2000);
        assertEquals("Port not set", 2000, dp.getPort());
    } 
 
    /**