You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2005/06/08 17:35:38 UTC

svn commit: r189594 - /cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java

Author: danielf
Date: Wed Jun  8 08:35:38 2005
New Revision: 189594

URL: http://svn.apache.org/viewcvs?rev=189594&view=rev
Log:
More fine grained exception handling

Modified:
    cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java

Modified: cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java?rev=189594&r1=189593&r2=189594&view=diff
==============================================================================
--- cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java (original)
+++ cocoon/trunk/src/test/org/apache/cocoon/test/SitemapTestCase.java Wed Jun  8 08:35:38 2005
@@ -16,6 +16,7 @@
 package org.apache.cocoon.test;
 
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -52,7 +53,7 @@
     protected void setUp() throws Exception {
         super.setUp();
 
-        String level = System.getProperty("junit.test.loglevel", "" + ConsoleLogger.LEVEL_WARN);
+        String level = System.getProperty("junit.test.loglevel", "" + ConsoleLogger.LEVEL_DEBUG);
         this.logger = new ConsoleLogger(Integer.parseInt(level));
 
         objectmodel.clear();
@@ -103,12 +104,20 @@
      */
     protected URL getClassDirURL() throws RuntimeException {
         String className = getClass().getName().replace( '.', '/' ) + ".class";
+        String classURL = null;
+        String classDir = null;
         try {
-            String classURL =
+            classURL =
                 getClass().getClassLoader().getResource( className ).toExternalForm();
-            String classDir = classURL.substring(0, classURL.lastIndexOf('/') + 1);
-
+            getLogger().debug("classURL=" + classURL);
+            classDir = classURL.substring(0, classURL.lastIndexOf('/') + 1);
+            getLogger().debug("classDir=" + classDir);
             return new URL(classDir);
+        } catch (SecurityException e) {
+            throw new RuntimeException("Not allowed to access classloader for " + className, e);
+        } catch (MalformedURLException e) {
+            throw new RuntimeException("Malformed URL for className=" + className +
+                                       " classURL=" + classURL + " classDir=" + classDir, e);
         } catch (Exception e) {
             throw new RuntimeException("Couldn't create URL for " + className, e);
         }
@@ -183,7 +192,7 @@
         this.request.setEnvironment(env);
         env.setObjectModel(this.objectmodel);
 
-	return env;
+        return env;
     }
 
     protected byte[] process(String uri) throws Exception {