commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1203678 - /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java
Date Fri, 18 Nov 2011 14:48:26 GMT
Author: ggregory
Date: Fri Nov 18 14:48:25 2011
New Revision: 1203678

URL: http://svn.apache.org/viewvc?rev=1203678&view=rev
Log:
[VFS-386] Build tests HTTP file system with an embedded HTTP server (Apache HttpComponent
Core). Forgot to make test quiet on the console.

Modified:
    commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java

Modified: commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java?rev=1203678&r1=1203677&r2=1203678&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java
(original)
+++ commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs2/provider/http/test/NHttpServer.java
Fri Nov 18 14:48:25 2011
@@ -97,27 +97,27 @@ public class NHttpServer
     {
         public void connectionClosed(final NHttpConnection conn)
         {
-            System.out.println("Connection closed: " + conn);
+            debug("Connection closed: " + conn);
         }
 
         public void connectionOpen(final NHttpConnection conn)
         {
-            System.out.println("Connection open: " + conn);
+            debug("Connection open: " + conn);
         }
 
         public void connectionTimeout(final NHttpConnection conn)
         {
-            System.out.println("Connection timed out: " + conn);
+            debug("Connection timed out: " + conn);
         }
 
         public void fatalIOException(final IOException ex, final NHttpConnection conn)
         {
-            System.err.println("I/O error: " + ex.getMessage());
+            debug("I/O error: " + ex.getMessage());
         }
 
         public void fatalProtocolException(final HttpException ex, final NHttpConnection
conn)
         {
-            System.err.println("HTTP error: " + ex.getMessage());
+            debug("HTTP error: " + ex.getMessage());
         }
     }
 
@@ -144,7 +144,7 @@ public class NHttpServer
             {
                 HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
                 byte[] entityContent = EntityUtils.toByteArray(entity);
-                System.out.println("Incoming entity content (bytes): " + entityContent.length);
+                debug("Incoming entity content (bytes): " + entityContent.length);
             }
 
             String target = request.getRequestLine().getUri();
@@ -156,7 +156,7 @@ public class NHttpServer
                         + " not found</h1></body></html>", "UTF-8");
                 entity.setContentType("text/html; charset=UTF-8");
                 response.setEntity(entity);
-                System.out.println("File " + file.getPath() + " not found");
+                debug("File " + file.getPath() + " not found");
 
             } else if (!file.canRead())
             {
@@ -164,7 +164,7 @@ public class NHttpServer
                 NStringEntity entity = new NStringEntity("<html><body><h1>Access
denied</h1></body></html>", "UTF-8");
                 entity.setContentType("text/html; charset=UTF-8");
                 response.setEntity(entity);
-                System.out.println("Cannot read file " + file.getPath());
+                debug("Cannot read file " + file.getPath());
 
             } else
             {
@@ -175,11 +175,21 @@ public class NHttpServer
                 {
                     response.addHeader(HttpHeaders.LAST_MODIFIED, DateUtil.formatDate(new
Date(file.lastModified())));
                 }
-                System.out.println("Serving file " + file.getPath());
+                debug("Serving file " + file.getPath());
             }
         }
     }
 
+    static final boolean Debug = false;
+
+    private static void debug(String s)
+    {
+        if (Debug)
+        {
+            System.out.println(s);
+        }
+    }
+
     public static void main(String[] args) throws Exception
     {
         new NHttpServer().run(0, null, 0);
@@ -238,12 +248,12 @@ public class NHttpServer
             ioReactor.execute(ioEventDispatch);
         } catch (InterruptedIOException ex)
         {
-            System.err.println("Interrupted");
+            debug("Interrupted");
         } catch (IOException e)
         {
-            System.err.println("I/O error: " + e.getMessage());
+            debug("I/O error: " + e.getMessage());
         }
-        System.out.println("Shutdown");
+        debug("Shutdown");
     }
 
     public void stop() throws IOException



Mime
View raw message