tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r884887 - /tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
Date Fri, 27 Nov 2009 14:55:27 GMT
Author: markt
Date: Fri Nov 27 14:55:26 2009
New Revision: 884887

URL: http://svn.apache.org/viewvc?rev=884887&view=rev
Log:
Double-check getResource() works as intended after report of issue with Grails (http://jira.codehaus.org/browse/GRAILS-5038)
All seems OK. Maybe a Grails issue?

Modified:
    tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java

Modified: tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java?rev=884887&r1=884886&r2=884887&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestTomcat.java Fri Nov 27 14:55:26 2009
@@ -18,7 +18,11 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.net.URL;
+import java.net.URLConnection;
 import java.security.Principal;
 import java.util.HashMap;
 import java.util.Map;
@@ -95,8 +99,33 @@
             if (url == null) {
                 res.getWriter().write("null");
             } else {
-                res.getWriter().write(url.toString());
+                res.getWriter().write(url.toString() + "\n");
+                res.getWriter().write("The first 20 characters of that resource are:\n");
+
+                // Read some content from the resource
+                URLConnection conn = url.openConnection();
+                
+                InputStream is = null;
+                Reader reader = null;
+                char cbuf[] = new char[20];
+                try {
+                    is = conn.getInputStream();
+                    reader = new InputStreamReader(is);
+                    reader.read(cbuf);
+                    res.getWriter().write(cbuf);
+                } finally {
+                    if (reader != null) {
+                        try { reader.close(); } catch(IOException ioe) {/*Ignore*/}
+                    }
+                    if (is != null) {
+                        try { is.close(); } catch(IOException ioe) {/*Ignore*/}
+                    }
+                }
+                
+                
             }
+            
+            
         }
     }
     
@@ -242,9 +271,12 @@
         
         tomcat.start();
         
+        ByteChunk res = new ByteChunk();
+        
         int rc =getUrl("http://localhost:" + getPort() + contextPath +
-                "/testGetResource", new ByteChunk(), null);
+                "/testGetResource", res, null);
         assertEquals(HttpServletResponse.SC_OK, rc);
+        assertTrue(res.toString().contains("<?xml version=\"1.0\" "));
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message