// Path: activeio-core/src/main/java/org/apache/activeio/packet/Packet.java
// public interface Packet {
//     
//     public int position();
//     public void position(int position);
//     public int limit();
//     public void limit(int limit);
//     public void flip();
//     public int remaining();
//     public void rewind();
//     public boolean hasRemaining();
//     public void clear();
//     public Packet slice();
//     public Packet duplicate();
//     public Object duplicate(ClassLoader cl) throws IOException;
//     public int capacity();
//     public void dispose();
//     
//     public ByteSequence asByteSequence();
//     public byte[] sliceAsBytes();
//     
//     /**
//      *  @Return object that is an instance of requested type and is associated this this object.  May return null if no 
//      *  object of that type is associated.
//      */
//     Object getAdapter(Class target);
//     
//     
//     /**
//      * Writes the remaing bytes in the packet to the output stream.
//      * 
//      * @param out
//      * @return
//      */
//     void writeTo(OutputStream out) throws IOException;   
//     void writeTo(DataOutput out) throws IOException;
//     
//     // To read data out of the packet.
//     public int read();
//     public int read(byte data[], int offset, int length);
// 
//     // To write data into the packet.
//     public boolean write( int data );
//     public int write( byte data[], int offset, int length );
//     public int read(Packet dest);
//     
// }


import java.util.Arrays;
import org.apache.activeio.packet.Packet;
import junit.framework.TestCase;
    }

    public void testLimit() {
        Packet packet = createTestPacket(100);
        packet.limit(10);
        assertEquals( 10, packet.limit() );        
    }

    public void testRemaining() {
        Packet packet = createTestPacket(100);
        packet.position(5);
        packet.limit(95);
        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
        packet.limit(5);
        assertEquals(0, packet.remaining());
        assertFalse(packet.hasRemaining());
    }
    
    public void testFlip() {
        Packet packet = createTestPacket(100);
        packet.position(95);
        packet.flip();        
        assertEquals(0, packet.position());
        assertEquals(95, packet.limit());
    }
    
    public void testClear() {
// Path: activeio-core/src/main/java/org/apache/activeio/packet/Packet.java
// public interface Packet {
//     
//     public int position();
//     public void position(int position);
//     public int limit();
//     public void limit(int limit);
//     public void flip();
//     public int remaining();
//     public void rewind();
//     public boolean hasRemaining();
//     public void clear();
//     public Packet slice();
//     public Packet duplicate();
//     public Object duplicate(ClassLoader cl) throws IOException;
//     public int capacity();
//     public void dispose();
//     
//     public ByteSequence asByteSequence();
//     public byte[] sliceAsBytes();
//     
//     /**
//      *  @Return object that is an instance of requested type and is associated this this object.  May return null if no 
//      *  object of that type is associated.
//      */
//     Object getAdapter(Class target);
//     
//     
//     /**
//      * Writes the remaing bytes in the packet to the output stream.
//      * 
//      * @param out
//      * @return
//      */
//     void writeTo(OutputStream out) throws IOException;   
//     void writeTo(DataOutput out) throws IOException;
//     
//     // To read data out of the packet.
//     public int read();
//     public int read(byte data[], int offset, int length);
// 
//     // To write data into the packet.
//     public boolean write( int data );
//     public int write( byte data[], int offset, int length );
//     public int read(Packet dest);
//     
// }


// Path: activeio-core/src/test/java/org/apache/activeio/packet/PacketTestSupport.java
import java.util.Arrays;
import org.apache.activeio.packet.Packet;
import junit.framework.TestCase;

    }

    public void testLimit() {
        Packet packet = createTestPacket(100);
        packet.limit(10);
        assertEquals( 10, packet.limit() );        
    }

    public void testRemaining() {
        Packet packet = createTestPacket(100);
        packet.position(5);
        packet.limit(95);
        assertEquals(90, packet.remaining());
        assertTrue(packet.hasRemaining());

        packet.position(5);
        packet.limit(5);
        assertEquals(0, packet.remaining());
        assertFalse(packet.hasRemaining());
    }
    
    public void testFlip() {
        Packet packet = createTestPacket(100);
        packet.position(95);
        packet.flip();        
        assertEquals(0, packet.position());
        assertEquals(95, packet.limit());
    }
    
    public void testClear() {
        Packet packet = createTestPacket(100);