You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2010/04/23 21:11:57 UTC
svn commit: r937477 [8/9] - in
/httpcomponents/httpcore/trunk/httpcore-nio/src:
main/java/org/apache/http/impl/nio/
main/java/org/apache/http/impl/nio/codecs/
main/java/org/apache/http/impl/nio/reactor/
main/java/org/apache/http/impl/nio/ssl/ main/java...
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLClient.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLClient.java Fri Apr 23 19:11:53 2010
@@ -53,7 +53,7 @@ public class TestHttpSSLClient {
private final SSLContext sslcontext;
private final DefaultConnectingIOReactor ioReactor;
private final HttpParams params;
-
+
private volatile IOReactorThread thread;
public TestHttpSSLClient(final HttpParams params) throws Exception {
@@ -71,7 +71,7 @@ public class TestHttpSSLClient {
return TrustManagerFactory.getInstance("SunX509");
}
}
-
+
protected SSLContext createSSLContext() throws Exception {
ClassLoader cl = getClass().getClassLoader();
URL url = cl.getResource("test.keystore");
@@ -79,59 +79,59 @@ public class TestHttpSSLClient {
keystore.load(url.openStream(), "nopassword".toCharArray());
TrustManagerFactory tmfactory = createTrustManagerFactory();
tmfactory.init(keystore);
- TrustManager[] trustmanagers = tmfactory.getTrustManagers();
+ TrustManager[] trustmanagers = tmfactory.getTrustManagers();
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, trustmanagers, null);
return sslcontext;
}
-
+
public HttpParams getParams() {
return this.params;
}
-
+
public IOReactorStatus getStatus() {
return this.ioReactor.getStatus();
}
-
+
public List<ExceptionEvent> getAuditLog() {
return this.ioReactor.getAuditLog();
}
-
+
public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
this.ioReactor.setExceptionHandler(exceptionHandler);
}
-
+
protected IOEventDispatch createIOEventDispatch(
- final NHttpClientHandler clientHandler,
+ final NHttpClientHandler clientHandler,
final SSLContext sslcontext,
final HttpParams params) {
return new SSLClientIOEventDispatch(clientHandler, sslcontext, params);
}
-
+
private void execute(final NHttpClientHandler clientHandler) throws IOException {
IOEventDispatch ioEventDispatch = createIOEventDispatch(
- clientHandler,
+ clientHandler,
this.sslcontext,
this.params);
-
+
this.ioReactor.execute(ioEventDispatch);
}
-
+
public SessionRequest openConnection(final InetSocketAddress address, final Object attachment) {
return this.ioReactor.connect(address, null, attachment, null);
}
-
+
public void start(final NHttpClientHandler clientHandler) {
this.thread = new IOReactorThread(clientHandler);
this.thread.start();
}
-
+
public void join(long timeout) throws InterruptedException {
if (this.thread != null) {
this.thread.join(timeout);
}
}
-
+
public Exception getException() {
if (this.thread != null) {
return this.thread.getException();
@@ -139,7 +139,7 @@ public class TestHttpSSLClient {
return null;
}
}
-
+
public void shutdown() throws IOException {
this.ioReactor.shutdown();
try {
@@ -149,18 +149,18 @@ public class TestHttpSSLClient {
} catch (InterruptedException ignore) {
}
}
-
+
private class IOReactorThread extends Thread {
private final NHttpClientHandler clientHandler;
-
+
private volatile Exception ex;
-
+
public IOReactorThread(final NHttpClientHandler clientHandler) {
super();
this.clientHandler = clientHandler;
}
-
+
@Override
public void run() {
try {
@@ -169,11 +169,11 @@ public class TestHttpSSLClient {
this.ex = ex;
}
}
-
+
public Exception getException() {
return this.ex;
}
- }
-
+ }
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLServer.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpSSLServer.java Fri Apr 23 19:11:53 2010
@@ -50,24 +50,24 @@ import org.apache.http.params.HttpParams
/**
* Trivial test server based on HttpCore NIO SSL
- *
+ *
*/
public class TestHttpSSLServer {
private final SSLContext sslcontext;
private final DefaultListeningIOReactor ioReactor;
private final HttpParams params;
-
+
private volatile IOReactorThread thread;
private ListenerEndpoint endpoint;
-
+
public TestHttpSSLServer(final HttpParams params) throws Exception {
super();
this.params = params;
this.sslcontext = createSSLContext();
this.ioReactor = new DefaultListeningIOReactor(2, this.params);
}
-
+
private KeyManagerFactory createKeyManagerFactory() throws NoSuchAlgorithmException {
String algo = KeyManagerFactory.getDefaultAlgorithm();
try {
@@ -76,7 +76,7 @@ public class TestHttpSSLServer {
return KeyManagerFactory.getInstance("SunX509");
}
}
-
+
protected SSLContext createSSLContext() throws Exception {
ClassLoader cl = getClass().getClassLoader();
URL url = cl.getResource("test.keystore");
@@ -84,41 +84,41 @@ public class TestHttpSSLServer {
keystore.load(url.openStream(), "nopassword".toCharArray());
KeyManagerFactory kmfactory = createKeyManagerFactory();
kmfactory.init(keystore, "nopassword".toCharArray());
- KeyManager[] keymanagers = kmfactory.getKeyManagers();
+ KeyManager[] keymanagers = kmfactory.getKeyManagers();
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(keymanagers, null, null);
return sslcontext;
}
-
+
public HttpParams getParams() {
return this.params;
}
-
+
public IOReactorStatus getStatus() {
return this.ioReactor.getStatus();
}
-
+
public List<ExceptionEvent> getAuditLog() {
return this.ioReactor.getAuditLog();
}
-
+
public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
this.ioReactor.setExceptionHandler(exceptionHandler);
}
protected IOEventDispatch createIOEventDispatch(
- final NHttpServiceHandler serviceHandler,
+ final NHttpServiceHandler serviceHandler,
final SSLContext sslcontext,
final HttpParams params) {
return new SSLServerIOEventDispatch(serviceHandler, sslcontext, params);
}
-
+
private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
IOEventDispatch ioEventDispatch = createIOEventDispatch(
- serviceHandler,
+ serviceHandler,
this.sslcontext,
this.params);
-
+
this.ioReactor.execute(ioEventDispatch);
}
@@ -131,13 +131,13 @@ public class TestHttpSSLServer {
this.thread = new IOReactorThread(serviceHandler);
this.thread.start();
}
-
+
public void join(long timeout) throws InterruptedException {
if (this.thread != null) {
this.thread.join(timeout);
}
}
-
+
public Exception getException() {
if (this.thread != null) {
return this.thread.getException();
@@ -145,7 +145,7 @@ public class TestHttpSSLServer {
return null;
}
}
-
+
public void shutdown() throws IOException {
this.ioReactor.shutdown();
try {
@@ -155,18 +155,18 @@ public class TestHttpSSLServer {
} catch (InterruptedException ignore) {
}
}
-
+
private class IOReactorThread extends Thread {
private final NHttpServiceHandler serviceHandler;
-
+
private volatile Exception ex;
-
+
public IOReactorThread(final NHttpServiceHandler serviceHandler) {
super();
this.serviceHandler = serviceHandler;
}
-
+
@Override
public void run() {
try {
@@ -175,11 +175,11 @@ public class TestHttpSSLServer {
this.ex = ex;
}
}
-
+
public Exception getException() {
return this.ex;
}
- }
-
+ }
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpServer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpServer.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpServer.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/TestHttpServer.java Fri Apr 23 19:11:53 2010
@@ -43,7 +43,7 @@ import org.apache.http.params.HttpParams
/**
* Trivial test server based on HttpCore NIO
- *
+ *
*/
public class TestHttpServer {
@@ -52,7 +52,7 @@ public class TestHttpServer {
private volatile IOReactorThread thread;
private ListenerEndpoint endpoint;
-
+
public TestHttpServer(final HttpParams params) throws IOException {
super();
this.ioReactor = new DefaultListeningIOReactor(2, params);
@@ -62,7 +62,7 @@ public class TestHttpServer {
public HttpParams getParams() {
return this.params;
}
-
+
public void setExceptionHandler(final IOReactorExceptionHandler exceptionHandler) {
this.ioReactor.setExceptionHandler(exceptionHandler);
}
@@ -71,15 +71,15 @@ public class TestHttpServer {
final NHttpServiceHandler serviceHandler, final HttpParams params) {
return new DefaultServerIOEventDispatch(serviceHandler, params);
}
-
+
private void execute(final NHttpServiceHandler serviceHandler) throws IOException {
IOEventDispatch ioEventDispatch = createIOEventDispatch(
- serviceHandler,
+ serviceHandler,
this.params);
-
+
this.ioReactor.execute(ioEventDispatch);
}
-
+
public ListenerEndpoint getListenerEndpoint() {
return this.endpoint;
}
@@ -93,21 +93,21 @@ public class TestHttpServer {
this.thread = new IOReactorThread(serviceHandler);
this.thread.start();
}
-
+
public IOReactorStatus getStatus() {
return this.ioReactor.getStatus();
}
-
+
public List<ExceptionEvent> getAuditLog() {
return this.ioReactor.getAuditLog();
}
-
+
public void join(long timeout) throws InterruptedException {
if (this.thread != null) {
this.thread.join(timeout);
}
}
-
+
public Exception getException() {
if (this.thread != null) {
return this.thread.getException();
@@ -115,7 +115,7 @@ public class TestHttpServer {
return null;
}
}
-
+
public void shutdown() throws IOException {
this.ioReactor.shutdown();
try {
@@ -123,18 +123,18 @@ public class TestHttpServer {
} catch (InterruptedException ignore) {
}
}
-
+
private class IOReactorThread extends Thread {
private final NHttpServiceHandler serviceHandler;
-
+
private volatile Exception ex;
-
+
public IOReactorThread(final NHttpServiceHandler serviceHandler) {
super();
this.serviceHandler = serviceHandler;
}
-
+
@Override
public void run() {
try {
@@ -143,11 +143,11 @@ public class TestHttpServer {
this.ex = ex;
}
}
-
+
public Exception getException() {
return this.ex;
}
- }
-
+ }
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestAsyncNHttpHandlers.java Fri Apr 23 19:11:53 2010
@@ -90,11 +90,11 @@ public class TestAsyncNHttpHandlers exte
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -130,7 +130,7 @@ public class TestAsyncNHttpHandlers exte
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -139,7 +139,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -156,7 +156,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -170,7 +170,7 @@ public class TestAsyncNHttpHandlers exte
}
}
}
-
+
/**
* This test case executes a series of simple (non-pipelined) GET requests
* over multiple connections. This uses non-blocking output entities.
@@ -180,10 +180,10 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -198,7 +198,7 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -209,7 +209,7 @@ public class TestAsyncNHttpHandlers exte
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -224,7 +224,7 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -235,7 +235,7 @@ public class TestAsyncNHttpHandlers exte
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -250,8 +250,8 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
- HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
+ String s = testjob.getPattern() + "x" + testjob.getCount();
+ HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
HttpVersion.HTTP_1_0);
NStringEntity entity = null;
try {
@@ -261,7 +261,7 @@ public class TestAsyncNHttpHandlers exte
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -276,7 +276,7 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -287,7 +287,7 @@ public class TestAsyncNHttpHandlers exte
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -299,14 +299,14 @@ public class TestAsyncNHttpHandlers exte
*/
public void testHttpPostsWithExpectationVerification() throws Exception {
TestJob[] jobs = new TestJob[3];
- jobs[0] = new TestJob("AAAAA", 10);
- jobs[1] = new TestJob("AAAAA", 10);
- jobs[2] = new TestJob("BBBBB", 20);
+ jobs[0] = new TestJob("AAAAA", 10);
+ jobs[1] = new TestJob("AAAAA", 10);
+ jobs[2] = new TestJob("BBBBB", 20);
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
-
+
HttpExpectationVerifier expectationVerifier = new HttpExpectationVerifier() {
public void verify(
@@ -328,7 +328,7 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -339,9 +339,9 @@ public class TestAsyncNHttpHandlers exte
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
-
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -376,7 +376,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -385,7 +385,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
SessionRequest sessionRequest = this.client.openConnection(
new InetSocketAddress("localhost", serverAddress.getPort()),
queue);
@@ -395,7 +395,7 @@ public class TestAsyncNHttpHandlers exte
throw sessionRequest.getException();
}
assertNotNull(sessionRequest.getSession());
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < 2; i++) {
@@ -421,23 +421,23 @@ public class TestAsyncNHttpHandlers exte
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("HEAD", s);
}
-
+
};
-
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -470,7 +470,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -479,7 +479,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -496,7 +496,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -509,13 +509,13 @@ public class TestAsyncNHttpHandlers exte
assertNull(testjob.getResult());
}
}
-
+
/**
* This test executes a series of delayed GETs, ensuring the
* {@link NHttpResponseTrigger} works correctly.
*/
public void testDelayedHttpGets() throws Exception {
-
+
NHttpRequestHandler requestHandler = new NHttpRequestHandler() {
public ConsumingNHttpEntity entityRequest(
@@ -523,11 +523,11 @@ public class TestAsyncNHttpHandlers exte
final HttpContext context) {
return null;
}
-
+
public void handle(
- final HttpRequest request,
+ final HttpRequest request,
final HttpResponse response,
- final NHttpResponseTrigger trigger,
+ final NHttpResponseTrigger trigger,
final HttpContext context) throws HttpException, IOException {
String s = request.getRequestLine().getUri();
int idx = s.indexOf('x');
@@ -536,13 +536,13 @@ public class TestAsyncNHttpHandlers exte
}
String pattern = s.substring(0, idx);
int count = Integer.parseInt(s.substring(idx + 1, s.length()));
-
+
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < count; i++) {
buffer.append(pattern);
}
final String content = buffer.toString();
-
+
new Thread() {
@Override
public void run() {
@@ -565,14 +565,14 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
executeStandardTest(requestHandler, requestExecutionHandler);
}
-
+
/**
* This test ensures that HttpExceptions work correctly when immediate.
*/
@@ -585,10 +585,10 @@ public class TestAsyncNHttpHandlers exte
final HttpContext context) {
return null;
}
-
+
@Override
public void handle(
- final HttpRequest request,
+ final HttpRequest request,
final HttpResponse response,
final HttpContext context) throws HttpException, IOException {
throw new HttpException(request.getRequestLine().getUri());
@@ -600,21 +600,21 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -649,7 +649,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -658,7 +658,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -675,7 +675,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -689,7 +689,7 @@ public class TestAsyncNHttpHandlers exte
}
}
}
-
+
/**
* This test ensures that HttpExceptions work correctly when they are delayed by a trigger.
*/
@@ -716,26 +716,26 @@ public class TestAsyncNHttpHandlers exte
}
};
-
+
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -770,7 +770,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -779,7 +779,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -796,7 +796,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -810,7 +810,7 @@ public class TestAsyncNHttpHandlers exte
}
}
}
-
+
/**
* This test makes sure that if no service handler is installed, things still work.
*/
@@ -822,17 +822,17 @@ public class TestAsyncNHttpHandlers exte
String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
int connNo = 5;
TestJob[] jobs = new TestJob[connNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -865,7 +865,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -874,7 +874,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -891,7 +891,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -906,7 +906,7 @@ public class TestAsyncNHttpHandlers exte
}
}
}
-
+
/**
* This test case executes a series of simple (non-pipelined) POST requests
* with no entities on the client side, to ensure they are sent properly,
@@ -917,23 +917,23 @@ public class TestAsyncNHttpHandlers exte
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
r.setEntity(null);
return r;
}
-
+
};
-
+
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -968,7 +968,7 @@ public class TestAsyncNHttpHandlers exte
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -977,7 +977,7 @@ public class TestAsyncNHttpHandlers exte
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -994,7 +994,7 @@ public class TestAsyncNHttpHandlers exte
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestBufferingNHttpHandlers.java Fri Apr 23 19:11:53 2010
@@ -65,7 +65,7 @@ import org.apache.http.protocol.Response
import org.apache.http.protocol.ResponseServer;
/**
- * HttpCore NIO integration tests using buffering versions of the
+ * HttpCore NIO integration tests using buffering versions of the
* protocol handlers.
*/
public class TestBufferingNHttpHandlers extends HttpCoreNIOTestBase {
@@ -84,11 +84,11 @@ public class TestBufferingNHttpHandlers
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -124,7 +124,7 @@ public class TestBufferingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -133,7 +133,7 @@ public class TestBufferingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -150,7 +150,7 @@ public class TestBufferingNHttpHandlers
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -164,7 +164,7 @@ public class TestBufferingNHttpHandlers
}
}
}
-
+
/**
* This test case executes a series of simple (non-pipelined) GET requests
* over multiple connections.
@@ -174,10 +174,10 @@ public class TestBufferingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -191,7 +191,7 @@ public class TestBufferingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -202,7 +202,7 @@ public class TestBufferingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -216,7 +216,7 @@ public class TestBufferingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -227,7 +227,7 @@ public class TestBufferingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -241,8 +241,8 @@ public class TestBufferingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
- HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
+ String s = testjob.getPattern() + "x" + testjob.getCount();
+ HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
HttpVersion.HTTP_1_0);
NStringEntity entity = null;
try {
@@ -252,7 +252,7 @@ public class TestBufferingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -266,7 +266,7 @@ public class TestBufferingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -277,7 +277,7 @@ public class TestBufferingNHttpHandlers
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestJob.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestJob.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestJob.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestJob.java Fri Apr 23 19:11:53 2010
@@ -33,16 +33,16 @@ public class TestJob {
private static final Random RND = new Random();
private static final String TEST_CHARS = "0123456789ABCDEF";
-
+
private final int count;
private final String pattern;
-
+
private volatile boolean completed;
private volatile int statusCode;
private volatile String result;
private volatile String failureMessage;
private volatile Exception ex;
-
+
public TestJob(int maxCount) {
super();
this.count = RND.nextInt(maxCount - 1) + 1;
@@ -79,7 +79,7 @@ public class TestJob {
}
return buffer.toString();
}
-
+
public int getStatusCode() {
return this.statusCode;
}
@@ -87,19 +87,19 @@ public class TestJob {
public String getResult() {
return this.result;
}
-
+
public boolean isSuccessful() {
return this.result != null;
}
-
+
public String getFailureMessage() {
return this.failureMessage;
}
-
+
public Exception getException() {
return this.ex;
}
-
+
public boolean isCompleted() {
return this.completed;
}
@@ -113,7 +113,7 @@ public class TestJob {
this.result = result;
notifyAll();
}
-
+
public synchronized void fail(final String message, final Exception ex) {
if (this.completed) {
return;
@@ -124,15 +124,15 @@ public class TestJob {
this.ex = ex;
notifyAll();
}
-
+
public void fail(final String message) {
fail(message, null);
}
-
+
public synchronized void waitFor() throws InterruptedException {
while (!this.completed) {
wait();
}
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestNIOSSLHttp.java Fri Apr 23 19:11:53 2010
@@ -82,11 +82,11 @@ public class TestNIOSSLHttp extends Http
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -122,7 +122,7 @@ public class TestNIOSSLHttp extends Http
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -131,7 +131,7 @@ public class TestNIOSSLHttp extends Http
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -148,9 +148,9 @@ public class TestNIOSSLHttp extends Http
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
-
+
for (int i = 0; i < jobs.length; i++) {
TestJob testjob = jobs[i];
testjob.waitFor();
@@ -162,34 +162,34 @@ public class TestNIOSSLHttp extends Http
}
}
}
-
+
/**
- * This test case executes a series of simple (non-pipelined) GET requests
- * over multiple connections.
+ * This test case executes a series of simple (non-pipelined) GET requests
+ * over multiple connections.
*/
public void testHttpGets() throws Exception {
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
/**
- * This test case executes a series of simple (non-pipelined) POST requests
- * with content length delimited content over multiple connections.
+ * This test case executes a series of simple (non-pipelined) POST requests
+ * with content length delimited content over multiple connections.
*/
public void testHttpPostsWithContentLength() throws Exception {
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -200,21 +200,21 @@ public class TestNIOSSLHttp extends Http
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
/**
- * This test case executes a series of simple (non-pipelined) POST requests
- * with chunk coded content content over multiple connections.
+ * This test case executes a series of simple (non-pipelined) POST requests
+ * with chunk coded content content over multiple connections.
*/
public void testHttpPostsChunked() throws Exception {
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -225,22 +225,22 @@ public class TestNIOSSLHttp extends Http
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
/**
- * This test case executes a series of simple (non-pipelined) HTTP/1.0
- * POST requests over multiple persistent connections.
+ * This test case executes a series of simple (non-pipelined) HTTP/1.0
+ * POST requests over multiple persistent connections.
*/
public void testHttpPostsHTTP10() throws Exception {
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
- HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
+ String s = testjob.getPattern() + "x" + testjob.getCount();
+ HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
HttpVersion.HTTP_1_0);
NStringEntity entity = null;
try {
@@ -250,11 +250,11 @@ public class TestNIOSSLHttp extends Http
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
-
+
/**
* This test case executes a series of simple (non-pipelined) POST requests
* over multiple connections using the 'expect: continue' handshake. This test
@@ -265,7 +265,7 @@ public class TestNIOSSLHttp extends Http
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -276,7 +276,7 @@ public class TestNIOSSLHttp extends Http
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestExecutionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestExecutionHandler.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestExecutionHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestExecutionHandler.java Fri Apr 23 19:11:53 2010
@@ -39,15 +39,15 @@ import org.apache.http.nio.util.HeapByte
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
-abstract class TestRequestExecutionHandler
+abstract class TestRequestExecutionHandler
implements NHttpRequestExecutionHandler, HttpRequestExecutionHandler {
-
+
public void initalizeContext(final HttpContext context, final Object attachment) {
context.setAttribute("queue", attachment);
}
protected abstract HttpRequest generateRequest(TestJob testjob);
-
+
public HttpRequest submitRequest(final HttpContext context) {
@SuppressWarnings("unchecked")
@@ -55,10 +55,10 @@ abstract class TestRequestExecutionHandl
if (queue == null) {
throw new IllegalStateException("Queue is null");
}
-
+
TestJob testjob = queue.poll();
context.setAttribute("job", testjob);
-
+
if (testjob != null) {
return generateRequest(testjob);
} else {
@@ -81,7 +81,7 @@ abstract class TestRequestExecutionHandl
int statusCode = response.getStatusLine().getStatusCode();
String content = null;
-
+
HttpEntity entity = response.getEntity();
if (entity != null) {
try {
@@ -99,5 +99,5 @@ abstract class TestRequestExecutionHandl
testjob.fail("Request failed");
}
}
-
+
}
\ No newline at end of file
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestHandler.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestHandler.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestRequestHandler.java Fri Apr 23 19:11:53 2010
@@ -44,18 +44,18 @@ import org.apache.http.protocol.HttpRequ
import org.apache.http.util.EntityUtils;
final class TestRequestHandler extends SimpleNHttpRequestHandler implements HttpRequestHandler {
-
+
private final boolean chunking;
-
+
TestRequestHandler() {
this(false);
}
-
+
TestRequestHandler(boolean chunking) {
super();
this.chunking = chunking;
}
-
+
public ConsumingNHttpEntity entityRequest(
final HttpEntityEnclosingRequest request,
final HttpContext context) {
@@ -74,7 +74,7 @@ final class TestRequestHandler extends S
if (request instanceof HttpEntityEnclosingRequest) {
HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
if (entity != null) {
- content = EntityUtils.toString(entity);
+ content = EntityUtils.toString(entity);
} else {
response.setStatusCode(HttpStatus.SC_BAD_REQUEST);
content = "Request entity not avaialble";
@@ -87,7 +87,7 @@ final class TestRequestHandler extends S
}
String pattern = s.substring(0, idx);
int count = Integer.parseInt(s.substring(idx + 1, s.length()));
-
+
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < count; i++) {
buffer.append(pattern);
@@ -98,5 +98,5 @@ final class TestRequestHandler extends S
entity.setChunked(this.chunking);
response.setEntity(entity);
}
-
+
}
\ No newline at end of file
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestThrottlingNHttpHandlers.java Fri Apr 23 19:11:53 2010
@@ -88,7 +88,7 @@ import org.apache.http.util.EncodingUtil
import org.apache.http.util.EntityUtils;
/**
- * HttpCore NIO integration tests using throttling versions of the
+ * HttpCore NIO integration tests using throttling versions of the
* protocol handlers.
*/
public class TestThrottlingNHttpHandlers extends HttpCoreNIOTestBase {
@@ -101,11 +101,11 @@ public class TestThrottlingNHttpHandlers
// ------------------------------------------------------- TestCase Methods
private ExecutorService execService;
-
+
@Override
protected void setUp() throws Exception {
super.setUp();
- this.execService = Executors.newCachedThreadPool();
+ this.execService = Executors.newCachedThreadPool();
}
@Override
@@ -113,7 +113,7 @@ public class TestThrottlingNHttpHandlers
super.tearDown();
this.execService.shutdownNow();
}
-
+
private void executeStandardTest(
final HttpRequestHandler requestHandler,
final HttpRequestExecutionHandler requestExecutionHandler) throws Exception {
@@ -121,11 +121,11 @@ public class TestThrottlingNHttpHandlers
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -146,7 +146,7 @@ public class TestThrottlingNHttpHandlers
new SimpleHttpRequestHandlerResolver(requestHandler));
serviceHandler.setEventListener(
new SimpleEventListener());
-
+
HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
@@ -163,7 +163,7 @@ public class TestThrottlingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -172,7 +172,7 @@ public class TestThrottlingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -189,7 +189,7 @@ public class TestThrottlingNHttpHandlers
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -203,7 +203,7 @@ public class TestThrottlingNHttpHandlers
}
}
}
-
+
/**
* This test case executes a series of simple (non-pipelined) GET requests
* over multiple connections.
@@ -213,10 +213,10 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -230,7 +230,7 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -241,7 +241,7 @@ public class TestThrottlingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -255,7 +255,7 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -266,13 +266,13 @@ public class TestThrottlingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
/**
- * This test ensures that an Executor instance
+ * This test ensures that an Executor instance
* (under the control of a ThrottlingHttpServiceHandler)
* terminates when a connection timeout occurs.
*/
@@ -281,23 +281,23 @@ public class TestThrottlingNHttpHandlers
final int DEFAULT_SERVER_SO_TIMEOUT = 60000;
this.server.getParams().setIntParameter(
CoreConnectionPNames.SO_TIMEOUT, SHORT_TIMEOUT);
-
+
// main expectation: the executor spawned by the service must finish.
final String COMMAND_FINISHED = "CommandFinished";
final Map<String, Boolean> serverExpectations = Collections.synchronizedMap(
new HashMap<String, Boolean>());
serverExpectations.put(COMMAND_FINISHED, Boolean.FALSE);
-
- // secondary expectation: not strictly necessary, the test will wait for the
- // client to finalize the request
+
+ // secondary expectation: not strictly necessary, the test will wait for the
+ // client to finalize the request
final String CLIENT_FINALIZED = "ClientFinalized";
final Map<String, Boolean> clientExpectations = Collections.synchronizedMap(
new HashMap<String, Boolean>());
clientExpectations.put(CLIENT_FINALIZED, Boolean.FALSE);
-
+
// runs the command on a separate thread and updates the server expectation
Executor executor = new Executor() {
-
+
public void execute(final Runnable command) {
new Thread() {
@Override
@@ -310,9 +310,9 @@ public class TestThrottlingNHttpHandlers
}
}.start();
}
-
+
};
-
+
HttpRequestHandler requestHandler = new HttpRequestHandler() {
public void handle(
HttpRequest request,
@@ -325,13 +325,13 @@ public class TestThrottlingNHttpHandlers
}
}
};
-
- // convoluted client-side entity content. The byte expected by the HttpRequest will not
+
+ // convoluted client-side entity content. The byte expected by the HttpRequest will not
// be written.
final PipedOutputStream pipe = new PipedOutputStream();
final PipedInputStream producer = new PipedInputStream(pipe);
pipe.close();
-
+
// A POST request enclosing an entity with (supposedly) a content length of 1 byte.
// the connection will be closed at the end of the request.
HttpRequestExecutionHandler requestExecutionHandler = new HttpRequestExecutionHandler() {
@@ -354,9 +354,9 @@ public class TestThrottlingNHttpHandlers
public void handleResponse(final HttpResponse response, final HttpContext context) {
}
-
+
};
-
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -375,7 +375,7 @@ public class TestThrottlingNHttpHandlers
new SimpleHttpRequestHandlerResolver(requestHandler));
serviceHandler.setEventListener(
new SimpleEventListener());
-
+
HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
@@ -392,16 +392,16 @@ public class TestThrottlingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
-
+
ListenerEndpoint endpoint = this.server.getListenerEndpoint();
endpoint.waitFor();
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
-
+
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
SessionRequest sessionRequest = this.client.openConnection(
new InetSocketAddress("localhost", serverAddress.getPort()),
null);
@@ -411,9 +411,9 @@ public class TestThrottlingNHttpHandlers
throw sessionRequest.getException();
}
assertNotNull(sessionRequest.getSession());
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
-
+
// wait for the client to invoke finalizeContext().
synchronized (clientExpectations) {
if (!clientExpectations.get(CLIENT_FINALIZED).booleanValue()) {
@@ -421,7 +421,7 @@ public class TestThrottlingNHttpHandlers
assertTrue(clientExpectations.get(CLIENT_FINALIZED).booleanValue());
}
}
-
+
// wait for server to finish the command within a reasonable amount of time.
// the time constraint is not necessary, it only prevents the test from hanging.
synchronized (serverExpectations) {
@@ -430,11 +430,11 @@ public class TestThrottlingNHttpHandlers
assertTrue(serverExpectations.get(COMMAND_FINISHED).booleanValue());
}
}
-
+
this.execService.shutdown();
this.execService.awaitTermination(10, TimeUnit.SECONDS);
}
-
+
/**
* This test case executes a series of simple (non-pipelined) HTTP/1.0
* POST requests over multiple persistent connections.
@@ -444,8 +444,8 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
- HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
+ String s = testjob.getPattern() + "x" + testjob.getCount();
+ HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s,
HttpVersion.HTTP_1_0);
NStringEntity entity = null;
try {
@@ -455,7 +455,7 @@ public class TestThrottlingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -469,7 +469,7 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -480,7 +480,7 @@ public class TestThrottlingNHttpHandlers
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
executeStandardTest(new TestRequestHandler(), requestExecutionHandler);
}
@@ -491,14 +491,14 @@ public class TestThrottlingNHttpHandlers
*/
public void testHttpPostsWithExpectationVerification() throws Exception {
TestJob[] jobs = new TestJob[3];
- jobs[0] = new TestJob("AAAAA", 10);
- jobs[1] = new TestJob("AAAAA", 10);
- jobs[2] = new TestJob("BBBBB", 20);
+ jobs[0] = new TestJob("AAAAA", 10);
+ jobs[1] = new TestJob("AAAAA", 10);
+ jobs[2] = new TestJob("BBBBB", 20);
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
-
+
HttpExpectationVerifier expectationVerifier = new HttpExpectationVerifier() {
public void verify(
@@ -520,7 +520,7 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -531,9 +531,9 @@ public class TestThrottlingNHttpHandlers
r.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, true);
return r;
}
-
+
};
-
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -554,7 +554,7 @@ public class TestThrottlingNHttpHandlers
expectationVerifier);
serviceHandler.setEventListener(
new SimpleEventListener());
-
+
HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
@@ -571,7 +571,7 @@ public class TestThrottlingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -580,7 +580,7 @@ public class TestThrottlingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
SessionRequest sessionRequest = this.client.openConnection(
new InetSocketAddress("localhost", serverAddress.getPort()),
queue);
@@ -590,7 +590,7 @@ public class TestThrottlingNHttpHandlers
throw sessionRequest.getException();
}
assertNotNull(sessionRequest.getSession());
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < 2; i++) {
@@ -606,7 +606,7 @@ public class TestThrottlingNHttpHandlers
failedExpectation.waitFor();
assertEquals(HttpStatus.SC_EXPECTATION_FAILED, failedExpectation.getStatusCode());
}
-
+
/**
* This test case executes a series of simple (non-pipelined) HEAD requests
* over multiple connections.
@@ -616,23 +616,23 @@ public class TestThrottlingNHttpHandlers
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("HEAD", s);
}
-
+
};
-
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -667,7 +667,7 @@ public class TestThrottlingNHttpHandlers
this.client.getParams());
clientHandler.setEventListener(new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -676,7 +676,7 @@ public class TestThrottlingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -693,7 +693,7 @@ public class TestThrottlingNHttpHandlers
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -730,7 +730,7 @@ public class TestThrottlingNHttpHandlers
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
NStringEntity entity = null;
try {
@@ -741,17 +741,17 @@ public class TestThrottlingNHttpHandlers
r.setEntity(entity);
return r;
}
-
+
};
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob();
+ jobs[i] = new TestJob();
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -772,7 +772,7 @@ public class TestThrottlingNHttpHandlers
new SimpleHttpRequestHandlerResolver(requestHandler));
serviceHandler.setEventListener(
new SimpleEventListener());
-
+
HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
@@ -789,7 +789,7 @@ public class TestThrottlingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -798,7 +798,7 @@ public class TestThrottlingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -815,7 +815,7 @@ public class TestThrottlingNHttpHandlers
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -844,12 +844,12 @@ public class TestThrottlingNHttpHandlers
if (queue == null) {
throw new IllegalStateException("Queue is null");
}
-
+
TestJob testjob = queue.poll();
context.setAttribute("job", testjob);
-
+
if (testjob != null) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", s);
StringEntity entity = null;
try {
@@ -872,13 +872,13 @@ public class TestThrottlingNHttpHandlers
int statusCode = response.getStatusLine().getStatusCode();
String content = null;
-
+
HttpEntity entity = response.getEntity();
if (entity != null) {
try {
- // Simulate slow response handling in order to cause the
- // internal content buffer to fill up, forcing the
- // protocol handler to throttle input rate
+ // Simulate slow response handling in order to cause the
+ // internal content buffer to fill up, forcing the
+ // protocol handler to throttle input rate
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
InputStream instream = entity.getContent();
byte[] tmp = new byte[2048];
@@ -887,7 +887,7 @@ public class TestThrottlingNHttpHandlers
Thread.sleep(1);
outstream.write(tmp, 0, l);
}
- content = new String(outstream.toByteArray(),
+ content = new String(outstream.toByteArray(),
EntityUtils.getContentCharSet(entity));
} catch (InterruptedException ex) {
content = "Interrupted: " + ex.getMessage();
@@ -904,17 +904,17 @@ public class TestThrottlingNHttpHandlers
testjob.fail("Request failed");
}
}
-
+
};
int connNo = 3;
int reqNo = 20;
TestJob[] jobs = new TestJob[connNo * reqNo];
for (int i = 0; i < jobs.length; i++) {
- jobs[i] = new TestJob(10000);
+ jobs[i] = new TestJob(10000);
}
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
for (int i = 0; i < jobs.length; i++) {
- queue.add(jobs[i]);
+ queue.add(jobs[i]);
}
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
@@ -935,7 +935,7 @@ public class TestThrottlingNHttpHandlers
new SimpleHttpRequestHandlerResolver(new TestRequestHandler()));
serviceHandler.setEventListener(
new SimpleEventListener());
-
+
HttpProcessor clientHttpProc = new ImmutableHttpProcessor(new HttpRequestInterceptor[] {
new RequestContent(),
new RequestTargetHost(),
@@ -952,7 +952,7 @@ public class TestThrottlingNHttpHandlers
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -961,7 +961,7 @@ public class TestThrottlingNHttpHandlers
InetSocketAddress serverAddress = (InetSocketAddress) endpoint.getAddress();
assertEquals("Test server status", IOReactorStatus.ACTIVE, this.server.getStatus());
-
+
Queue<SessionRequest> connRequests = new LinkedList<SessionRequest>();
for (int i = 0; i < connNo; i++) {
SessionRequest sessionRequest = this.client.openConnection(
@@ -978,7 +978,7 @@ public class TestThrottlingNHttpHandlers
}
assertNotNull(sessionRequest.getSession());
}
-
+
assertEquals("Test client status", IOReactorStatus.ACTIVE, this.client.getStatus());
for (int i = 0; i < jobs.length; i++) {
@@ -992,5 +992,5 @@ public class TestThrottlingNHttpHandlers
}
}
}
-
+
}
Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java?rev=937477&r1=937476&r2=937477&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java (original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/nio/protocol/TestTruncatedChunks.java Fri Apr 23 19:11:53 2010
@@ -107,14 +107,14 @@ public class TestTruncatedChunks extends
// ------------------------------------------------------- TestCase Methods
private static final byte[] GARBAGE = new byte[] {'1', '2', '3', '4', '5' };
-
+
static class BrokenChunkEncoder extends AbstractContentEncoder {
private final CharArrayBuffer lineBuffer;
private boolean done;
-
+
public BrokenChunkEncoder(
- final WritableByteChannel channel,
+ final WritableByteChannel channel,
final SessionOutputBuffer buffer,
final HttpTransportMetricsImpl metrics) {
super(channel, buffer, metrics);
@@ -147,11 +147,11 @@ public class TestTruncatedChunks extends
}
return chunk;
}
-
+
}
static class CustomServerIOEventDispatch extends DefaultServerIOEventDispatch {
-
+
public CustomServerIOEventDispatch(
final NHttpServiceHandler handler,
final HttpParams params) {
@@ -160,11 +160,11 @@ public class TestTruncatedChunks extends
@Override
protected NHttpServerIOTarget createConnection(final IOSession session) {
-
+
return new DefaultNHttpServerConnection(
- session,
- createHttpRequestFactory(),
- this.allocator,
+ session,
+ createHttpRequestFactory(),
+ this.allocator,
this.params) {
@Override
@@ -179,14 +179,14 @@ public class TestTruncatedChunks extends
return super.createContentEncoder(len, channel, buffer, metrics);
}
}
-
+
};
}
-
+
}
static class CustomTestHttpServer extends TestHttpServer {
-
+
public CustomTestHttpServer(final HttpParams params) throws IOException {
super(params);
}
@@ -196,12 +196,12 @@ public class TestTruncatedChunks extends
NHttpServiceHandler serviceHandler, HttpParams params) {
return new CustomServerIOEventDispatch(serviceHandler, params);
}
-
+
}
-
+
protected CustomTestHttpServer server;
protected TestHttpClient client;
-
+
@Override
protected void setUp() throws Exception {
HttpParams serverParams = new SyncBasicHttpParams();
@@ -254,23 +254,23 @@ public class TestTruncatedChunks extends
}
}
}
-
+
public void testTruncatedChunkException() throws Exception {
-
+
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
-
+
};
TestJob testjob = new TestJob(2000);
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
- queue.add(testjob);
-
+ queue.add(testjob);
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -313,9 +313,9 @@ public class TestTruncatedChunks extends
TestJob testjob = (TestJob) context.getAttribute("job");
testjob.fail(ex.getMessage(), ex);
}
-
+
});
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);
@@ -334,7 +334,7 @@ public class TestTruncatedChunks extends
}
static class LenientNHttpEntity extends HttpEntityWrapper implements ConsumingNHttpEntity {
-
+
private final static int BUFFER_SIZE = 2048;
private final SimpleInputBuffer buffer;
@@ -405,33 +405,33 @@ public class TestTruncatedChunks extends
outstream.write(buffer, 0, l);
}
}
-
+
}
-
+
public void testIgnoreTruncatedChunkException() throws Exception {
-
+
NHttpRequestExecutionHandler requestExecutionHandler = new TestRequestExecutionHandler() {
@Override
protected HttpRequest generateRequest(final TestJob testjob) {
- String s = testjob.getPattern() + "x" + testjob.getCount();
+ String s = testjob.getPattern() + "x" + testjob.getCount();
return new BasicHttpRequest("GET", s);
}
@Override
public ConsumingNHttpEntity responseEntity(
- final HttpResponse response,
+ final HttpResponse response,
final HttpContext context) throws IOException {
return new LenientNHttpEntity(response.getEntity(),
new HeapByteBufferAllocator());
}
-
+
};
TestJob testjob = new TestJob(2000);
Queue<TestJob> queue = new ConcurrentLinkedQueue<TestJob>();
- queue.add(testjob);
-
+ queue.add(testjob);
+
HttpProcessor serverHttpProc = new ImmutableHttpProcessor(new HttpResponseInterceptor[] {
new ResponseDate(),
new ResponseServer(),
@@ -465,7 +465,7 @@ public class TestTruncatedChunks extends
clientHandler.setEventListener(
new SimpleEventListener());
-
+
this.server.start(serviceHandler);
this.client.start(clientHandler);