Code example for DatagramPacket

Methods: getData, setData

0
 
    /** 
     * @tests java.net.DatagramPacket#setData(byte[]) 
     */ 
    public void test_setData$B() { 
        DatagramPacket dp = new DatagramPacket("Hello".getBytes(), 5);
        dp.setData("Ralph".getBytes());
        assertEquals("Incorrect data set", "Ralph", new String(dp.getData(), 0,
                dp.getData().length));
    } 
 
    /** 
     * @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());
    } 
 
    /**