Code example for DatagramPacket

Methods: getAddress, getLength, getOffset, getPort

0
    /** 
     * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, int, 
     *        java.net.InetAddress, int) 
     */ 
    public void test_Constructor$BIILjava_net_InetAddressI() throws IOException { 
        DatagramPacket dp = new DatagramPacket("Hello".getBytes(), 2, 3,
                InetAddress.getLocalHost(), 0);
        assertEquals("Wrong host", InetAddress.getLocalHost(), dp.getAddress());
        assertEquals("Wrong port", 0, dp.getPort());
        assertEquals("Wrong length", 3, dp.getLength());
        assertEquals("Wrong offset", 2, dp.getOffset());
    } 
 
    /** 
     * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, 
     *        java.net.InetAddress, int) 
     */ 
    public void test_Constructor$BILjava_net_InetAddressI() throws IOException { 
        DatagramPacket dp = new DatagramPacket("Hello".getBytes(), 5,
                InetAddress.getLocalHost(), 0);
        assertEquals("Wrong address", InetAddress.getLocalHost(), dp