hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r831531 - in /httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http: ./ impl/nio/reactor/ mockup/
Date Sat, 31 Oct 2009 11:28:15 GMT
Author: olegk
Date: Sat Oct 31 11:28:14 2009
New Revision: 831531

URL: http://svn.apache.org/viewvc?rev=831531&view=rev
Log:
Test cases to print out exception stack traces to the std out; improved failure recovery in
the TestDefaultIOReactorsSSL#testGracefulShutdown() test case

Added:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
  (with props)
Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/SimpleEventListener.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java?rev=831531&r1=831530&r2=831531&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOSSLTestBase.java
Sat Oct 31 11:28:14 2009
@@ -28,11 +28,9 @@
 package org.apache.http;
 
 import java.io.IOException;
-import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.http.impl.nio.reactor.ExceptionEvent;
 import org.apache.http.mockup.TestHttpSSLClient;
 import org.apache.http.mockup.TestHttpSSLServer;
 import org.apache.http.params.CoreConnectionPNames;
@@ -56,24 +54,26 @@
     protected void setUp() throws Exception {
         HttpParams serverParams = new SyncBasicHttpParams();
         serverParams
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
+            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
         
         this.server = new TestHttpSSLServer(serverParams);
+        this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
         
         HttpParams clientParams = new SyncBasicHttpParams();
         clientParams
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
-            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 2000)
+            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 120000)
+            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 120000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
         
         this.client = new TestHttpSSLClient(clientParams);
+        this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
     @Override
@@ -83,29 +83,10 @@
         } catch (IOException ex) {
             ex.printStackTrace(System.out);
         }
-        List<ExceptionEvent> clogs = this.client.getAuditLog();
-        if (clogs != null) {
-            for (ExceptionEvent clog: clogs) {
-                Throwable cause = clog.getCause();
-                if (!(cause instanceof OoopsieRuntimeException)) {
-                    cause.printStackTrace(System.out);
-                }
-            }
-        }
-
         try {
             this.server.shutdown();
         } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-        List<ExceptionEvent> slogs = this.server.getAuditLog();
-        if (slogs != null) {
-            for (ExceptionEvent slog: slogs) {
-                Throwable cause = slog.getCause();
-                if (!(cause instanceof OoopsieRuntimeException)) {
-                    cause.printStackTrace(System.out);
-                }
-            }
+            ex.printStackTrace(System.out);
         }
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java?rev=831531&r1=831530&r2=831531&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/HttpCoreNIOTestBase.java
Sat Oct 31 11:28:14 2009
@@ -28,11 +28,9 @@
 package org.apache.http;
 
 import java.io.IOException;
-import java.util.List;
 
 import junit.framework.TestCase;
 
-import org.apache.http.impl.nio.reactor.ExceptionEvent;
 import org.apache.http.mockup.TestHttpClient;
 import org.apache.http.mockup.TestHttpServer;
 import org.apache.http.params.CoreConnectionPNames;
@@ -57,24 +55,26 @@
     protected void setUp() throws Exception {
         HttpParams serverParams = new SyncBasicHttpParams();
         serverParams
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 180000)
+            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.ORIGIN_SERVER, "TEST-SERVER/1.1");
 
         this.server = new TestHttpServer(serverParams);
+        this.server.setExceptionHandler(new SimpleIOReactorExceptionHandler());
 
         HttpParams clientParams = new SyncBasicHttpParams();
         clientParams
-            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 180000)
-            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 180000)
+            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 60000)
+            .setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 60000)
             .setIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024)
             .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
             .setBooleanParameter(CoreConnectionPNames.TCP_NODELAY, true)
             .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");
 
         this.client = new TestHttpClient(clientParams);
+        this.client.setExceptionHandler(new SimpleIOReactorExceptionHandler());
     }
 
     @Override
@@ -82,31 +82,12 @@
         try {
             this.client.shutdown();
         } catch (IOException ex) {
-            ex.printStackTrace();
+            ex.printStackTrace(System.out);
         }
-        List<ExceptionEvent> clogs = this.client.getAuditLog();
-        if (clogs != null) {
-            for (ExceptionEvent clog: clogs) {
-                Throwable cause = clog.getCause();
-                if (!(cause instanceof OoopsieRuntimeException)) {
-                    cause.printStackTrace();
-                }
-            }
-        }
-
         try {
             this.server.shutdown();
         } catch (IOException ex) {
-            ex.printStackTrace();
-        }
-        List<ExceptionEvent> slogs = this.server.getAuditLog();
-        if (slogs != null) {
-            for (ExceptionEvent slog: slogs) {
-                Throwable cause = slog.getCause();
-                if (!(cause instanceof OoopsieRuntimeException)) {
-                    cause.printStackTrace();
-                }
-            }
+            ex.printStackTrace(System.out);
         }
     }
 

Added: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java?rev=831531&view=auto
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
(added)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
Sat Oct 31 11:28:14 2009
@@ -0,0 +1,47 @@
+/*
+ * ====================================================================
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+package org.apache.http;
+
+import java.io.IOException;
+
+import org.apache.http.nio.reactor.IOReactorExceptionHandler;
+
+class SimpleIOReactorExceptionHandler implements IOReactorExceptionHandler {
+
+    public boolean handle(final RuntimeException ex) {
+        if (!(ex instanceof OoopsieRuntimeException)) {
+            ex.printStackTrace(System.out);
+        }
+        return false;
+    }
+
+    public boolean handle(final IOException ex) {
+        ex.printStackTrace(System.out);
+        return false;
+    }
+    
+}
\ No newline at end of file

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/SimpleIOReactorExceptionHandler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java?rev=831531&r1=831530&r2=831531&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/TestDefaultIOReactorsSSL.java
Sat Oct 31 11:28:14 2009
@@ -115,6 +115,9 @@
             }
 
             public void finalizeContext(final HttpContext context) {
+                while (requestConns.getCount() > 0) {
+                    requestConns.countDown();
+                }
             }
 
             public HttpRequest submitRequest(final HttpContext context) {

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/SimpleEventListener.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/SimpleEventListener.java?rev=831531&r1=831530&r2=831531&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/SimpleEventListener.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/mockup/SimpleEventListener.java
Sat Oct 31 11:28:14 2009
@@ -43,17 +43,18 @@
     }
 
     public void connectionTimeout(final NHttpConnection conn) {
+        System.out.println("Connection timed out");
     }
 
     public void connectionClosed(final NHttpConnection conn) {
     }
 
     public void fatalIOException(final IOException ex, final NHttpConnection conn) {
-        ex.printStackTrace();
+        ex.printStackTrace(System.out);
     }
 
-    public void fatalProtocolException(final HttpException ex, NHttpConnection conn) {
-        ex.printStackTrace();
+    public void fatalProtocolException(final HttpException ex, final NHttpConnection conn)
{
+        ex.printStackTrace(System.out);
     }
         
 }



Mime
View raw message