415548 migrate ProxyHTTPToSPDYTest to use HttpClient to avoid intermittent NPE part 2

This commit is contained in:
Thomas Becker 2013-08-30 16:08:18 +02:00
parent 566065dd34
commit 669ee75720
1 changed files with 4 additions and 42 deletions

View File

@ -18,12 +18,7 @@
package org.eclipse.jetty.spdy.server.proxy; package org.eclipse.jetty.spdy.server.proxy;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
@ -399,27 +394,8 @@ public class ProxyHTTPToSPDYTest
} }
})); }));
Socket client = new Socket(); ContentResponse response = httpClient.newRequest("localhost", proxyAddress.getPort()).method(HttpMethod.GET).send();
client.connect(proxyAddress); assertThat("response code is 200 OK", response.getStatus(), is(200));
OutputStream output = client.getOutputStream();
String request = "" +
"GET / HTTP/1.1\r\n" +
"Host: localhost:" + proxyAddress.getPort() + "\r\n" +
"\r\n";
output.write(request.getBytes("UTF-8"));
output.flush();
client.setSoTimeout(1000);
InputStream input = client.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
String line = reader.readLine();
Assert.assertTrue(line.contains(" 200"));
while (line.length() > 0)
line = reader.readLine();
Assert.assertFalse(reader.ready());
client.close();
} }
@Test @Test
@ -440,21 +416,7 @@ public class ProxyHTTPToSPDYTest
} }
})); }));
Socket client = new Socket(); ContentResponse response = httpClient.newRequest("localhost", proxyAddress.getPort()).method(HttpMethod.GET).send();
client.connect(proxyAddress); assertThat("response code is 500 OK", response.getStatus(), is(500));
OutputStream output = client.getOutputStream();
String request = "" +
"GET / HTTP/1.1\r\n" +
"Host: localhost:" + proxyAddress.getPort() + "\r\n" +
"\r\n";
output.write(request.getBytes("UTF-8"));
output.flush();
InputStream input = client.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input, "UTF-8"));
Assert.assertNull(reader.readLine());
client.close();
} }
} }