ASYNCWEB-36

Added another unit test that tests the boundary condition.

git-svn-id: https://svn.apache.org/repos/asf/mina/asyncweb/branches/1.0-mina1@810307 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/client/src/test/java/org/apache/asyncweb/client/ChunkedTest.java b/client/src/test/java/org/apache/asyncweb/client/ChunkedTest.java
index 69f4ee4..a74b018 100644
--- a/client/src/test/java/org/apache/asyncweb/client/ChunkedTest.java
+++ b/client/src/test/java/org/apache/asyncweb/client/ChunkedTest.java
@@ -86,5 +86,30 @@
         assertTrue(
             Arrays.equals(response.getContent(), "abcdefghijklmnopqrstuvwxyz1234567890abcdef".getBytes()));
     }
-
+    
+    public void testChunkingBoundary() throws Exception {
+        // create a boundary condition where the last CRLF is around the edge of the buffer
+    	int size = FAKE_HTTP.length();
+        ByteBuffer buffer = ByteBuffer.allocate(size-1);
+        buffer.put(FAKE_HTTP.getBytes(), 0, size-1);
+        buffer.flip();
+        
+        HttpRequestMessage request = new HttpRequestMessage(null, null);
+        IoSession session = new FakeIoSession();
+        session.setAttribute(HttpIoHandler.CURRENT_REQUEST, request);
+        HttpResponseDecoder decoder = new HttpResponseDecoder();
+        FakeProtocolDecoderOutput out = new FakeProtocolDecoderOutput();
+        decoder.decode(session, buffer, out);
+        
+        // create a new buffer that carries the last remaining byte
+        buffer = ByteBuffer.allocate(size-1);
+        buffer.put(FAKE_HTTP.getBytes(), size-1, 1);
+        buffer.flip();
+        // finish decoding
+        decoder.decode(session, buffer, out);
+        
+        HttpResponseMessage response = (HttpResponseMessage)out.getObject();
+        assertTrue(
+            Arrays.equals(response.getContent(), "abcdefghijklmnopqrstuvwxyz1234567890abcdef".getBytes()));
+    }
 }