Code example for DatagramPacket

Methods: getPort, setPort

0
 
    /** 
     * @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());
    } 
 
    /** 
     * @tests java.net.DatagramPacket#DatagramPacket(byte[], int, 
     *        java.net.SocketAddress) 
     */ 
    public void test_Constructor$BILjava_net_SocketAddress() throws IOException { 
        @SuppressWarnings("serial") 
        class UnsupportedSocketAddress extends SocketAddress {
 
            public UnsupportedSocketAddress() { 
            }