@@ -0,0 +1,2727 @@
+package com.wizzardo.http;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.net.Socket;%0Aimport java.util.concurrent.atomic.AtomicBoolean;%0A%0A/**%0A * Created by wizzardo on 20.06.15.%0A */%0Apublic class PipeliningTest extends ServerTest %7B%0A%0A    @Test%0A    public void test_1() throws IOException %7B%0A        handler = new UrlHandler()%0A                .append(%22/%22, (request, response) -%3E response.setBody(%22ok%22)) //length = 123%0A                .append(%22/foo%22, (request, response) -%3E response.setBody(%22foo%22)) //length = 124%0A                .append(%22/foobar%22, (request, response) -%3E response.setBody(%22foobar%22)) //length = 127%0A        ;%0A%0A        Assert.assertTrue(response(request(%22/%22), 123).endsWith(%22%5Cr%5Cn%5Cr%5Cnok%22));%0A%0A        String response = response(request(%22/%22) + request(%22/foo%22) + request(%22/foobar%22), 123 + 124 + 127);%0A        Assert.assertTrue(response.contains(%22%5Cr%5Cn%5Cr%5Cnok%22));%0A        Assert.assertTrue(response.contains(%22%5Cr%5Cn%5Cr%5Cnfoo%22));%0A        Assert.assertTrue(response.endsWith(%22%5Cr%5Cn%5Cr%5Cnfoobar%22));%0A    %7D%0A%0A    protected String response(String request, int limit) %7B%0A        try %7B%0A            Socket socket = new Socket(%22localhost%22, port);%0A            InputStream in = socket.getInputStream();%0A            OutputStream out = socket.getOutputStream();%0A%0A            byte%5B%5D response = new byte%5Blimit%5D;%0A            AtomicBoolean wait = new AtomicBoolean(true);%0A            new Thread(() -%3E %7B%0A                int r = 0;%0A                int total = 0;%0A                try %7B%0A                    while (total %3C limit && (r = in.read(response, total, limit - total)) != -1) %7B%0A                        total += r;%0A                    %7D%0A                %7D catch (IOException e) %7B%0A                    e.printStackTrace();%0A                    assert false;%0A                %7D%0A                synchronized (PipeliningTest.this) %7B%0A                    wait.set(false);%0A                    PipeliningTest.this.notify();%0A                %7D%0A            %7D).start();%0A            out.write(request.getBytes());%0A%0A            synchronized (PipeliningTest.this) %7B%0A                if (wait.get())%0A                    try %7B%0A                        wait();%0A                    %7D catch (InterruptedException e) %7B%0A                        e.printStackTrace();%0A                    %7D%0A            %7D%0A            return new String(response);%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return null;%0A        %7D%0A    %7D%0A%0A    protected String request(String path) %7B%0A        return %22GET %22 + path + %22 HTTP/1.1%5Cr%5Cn%22 +%0A                %22Host: localhost:%22 + port + %22%5Cr%5Cn%22 +%0A                %22Connection: Keep-Alive%5Cr%5Cn%22 +%0A                %22%5Cr%5Cn%22;%0A    %7D%0A%0A%7D%0A

add PipeliningTest