Code example for DatagramPacket

Methods: getData, setData

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