@@ -0,0 +1,2110 @@
+// Copyright 2014, Kevin Ko %3Ckevin@faveset.com%3E%0A%0Apackage com.faveset.khttp;%0A%0Aimport java.nio.ByteBuffer;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0A@RunWith(JUnit4.class)%0Apublic class NetBufferTest %7B%0A    @Test%0A    public void test() %7B%0A        ByteBuffer buf = ByteBuffer.allocate(1024);%0A%0A        NetBuffer netBuf = NetBuffer.makeAppendBuffer(buf);%0A%0A        assertTrue(netBuf.isCleared());%0A        assertTrue(netBuf.isEmpty());%0A%0A        assertTrue(!netBuf.needsResize(100));%0A        assertTrue(!netBuf.needsResize(1024));%0A        assertTrue(netBuf.needsResize(1025));%0A%0A        buf.limit(1);%0A        assertTrue(!netBuf.isCleared());%0A%0A        buf.limit(buf.capacity());%0A        assertTrue(netBuf.isCleared());%0A%0A        buf.put((byte) 0);%0A        assertTrue(!netBuf.isCleared());%0A        assertTrue(!netBuf.isEmpty());%0A%0A        buf.put((byte) 0);%0A%0A        // Test preservation when resizing.%0A        ByteBufferFactory factory = new HeapByteBufferFactory();%0A        netBuf.resize(factory, 2048);%0A        buf = netBuf.getByteBuffer();%0A%0A        assertEquals(2048, buf.capacity());%0A        assertEquals(2, buf.position());%0A%0A        netBuf.prepareRead();%0A%0A        try %7B%0A            assertTrue(!netBuf.isEmpty());%0A            assertEquals(0, buf.get());%0A%0A            assertTrue(!netBuf.isEmpty());%0A            assertEquals(0, buf.get());%0A%0A            assertTrue(netBuf.isEmpty());%0A        %7D finally %7B%0A            netBuf.updateRead();%0A        %7D%0A%0A        // Now, test appending, which should continue from where we finished reading.%0A        netBuf.prepareAppend();%0A%0A        assertEquals(2, buf.position());%0A%0A        assertTrue(netBuf.isEmpty());%0A%0A        buf.put((byte) 0);%0A%0A        netBuf.prepareRead();%0A%0A        // We should resume reading from the last unread position (2).%0A        assertEquals(2, buf.position());%0A        assertEquals(0, buf.get());%0A        assertTrue(netBuf.isEmpty());%0A%0A        netBuf.resizeUnsafe(factory, 4096);%0A        assertTrue(netBuf.isCleared());%0A    %7D%0A%7D%0A

Add simple NetBufferTest.