@@ -0,0 +1,2933 @@
+// Copyright 2014, Kevin Ko %3Ckevin@faveset.com%3E%0A%0Apackage com.faveset.khttp;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport org.junit.Test;%0Aimport org.junit.Ignore;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0Aimport java.nio.ByteBuffer;%0A%0A@RunWith(JUnit4.class)%0Apublic class RequestStartHandlerTest %7B%0A    @Test%0A    public void testSimple() throws InvalidRequestException %7B%0A        ByteBuffer buf = Helper.makeByteBuffer(%22GET / HTTP/1.1%5Cn%22);%0A%0A        HandlerState state = new HandlerState();%0A        HttpRequest req = state.getRequest();%0A        req.addHeader(%22foo%22, %22bar%22);%0A%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertTrue(handler.handleState(null, buf, state));%0A%0A        // Headers should be cleared.%0A        assertEquals(null, req.getHeader(%22foo%22));%0A    %7D%0A%0A    @Test(expected=InvalidRequestException.class)%0A    public void testOverflow() throws InvalidRequestException %7B%0A        // Unfinished line with too small a buffer to add more.%0A        ByteBuffer buf = Helper.makeByteBuffer(%22GET / HTTP/1.1%22);%0A%0A        HandlerState state = new HandlerState();%0A%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertFalse(handler.handleState(null, buf, state));%0A    %7D%0A%0A    @Test%0A    public void testPartial() throws InvalidRequestException %7B%0A        ByteBuffer buf = ByteBuffer.allocate(1024);%0A        buf.put(Helper.makeByteBuffer(%22GET /%22));%0A        buf.flip();%0A%0A        HandlerState state = new HandlerState();%0A%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertFalse(handler.handleState(null, buf, state));%0A%0A        buf.put(Helper.makeByteBuffer(%22 HTTP/1.1%5Cn%22));%0A        buf.flip();%0A%0A        assertTrue(handler.handleState(null, buf, state));%0A    %7D%0A%0A    @Test(expected=InvalidRequestException.class)%0A    public void testBadMethod() throws InvalidRequestException %7B%0A        ByteBuffer buf = Helper.makeByteBuffer(%22FOO / HTTP/1.1%5Cn%22);%0A        HandlerState state = new HandlerState();%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertFalse(handler.handleState(null, buf, state));%0A    %7D%0A%0A    @Test(expected=InvalidRequestException.class)%0A    public void testBadVersion() throws InvalidRequestException %7B%0A        ByteBuffer buf = Helper.makeByteBuffer(%22PUT / HTTP/1.3%5Cn%22);%0A        HandlerState state = new HandlerState();%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertFalse(handler.handleState(null, buf, state));%0A    %7D%0A%0A    @Test(expected=InvalidRequestException.class)%0A    public void testBadUri() throws InvalidRequestException %7B%0A        ByteBuffer buf = Helper.makeByteBuffer(%22POST /%5Cn%22);%0A        HandlerState state = new HandlerState();%0A        RequestStartHandler handler = new RequestStartHandler();%0A        assertFalse(handler.handleState(null, buf, state));%0A    %7D%0A%7D%0A

Add test for RequestStart.