commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r369755 - in /jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl: TcclDisabledTestCase.java props_disable_tccl/commons-logging.properties
Date Tue, 17 Jan 2006 11:29:51 GMT
Author: skitching
Date: Tue Jan 17 03:29:42 2006
New Revision: 369755

URL: http://svn.apache.org/viewcvs?rev=369755&view=rev
Log:
Fix bug in test; custom MyFactory class wasn't specified in commons-logging.properties!
Also, use constants instead of repeating custom class name as literal.

Modified:
    jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/TcclDisabledTestCase.java
    jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/props_disable_tccl/commons-logging.properties

Modified: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/TcclDisabledTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/TcclDisabledTestCase.java?rev=369755&r1=369754&r2=369755&view=diff
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/TcclDisabledTestCase.java
(original)
+++ jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/TcclDisabledTestCase.java
Tue Jan 17 03:29:42 2006
@@ -33,6 +33,12 @@
 
 public class TcclDisabledTestCase extends TestCase {
 
+    public static final String MY_LOG_FACTORY_PKG = 
+        "org.apache.commons.logging.tccl.custom";
+
+    public static final String MY_LOG_FACTORY_IMPL =
+        MY_LOG_FACTORY_PKG + ".MyLogFactoryImpl";
+
     // ------------------------------------------- JUnit Infrastructure Methods
 
 
@@ -70,7 +76,7 @@
         // hack to ensure that the testcase classloader can't see
         // the cust MyLogFactoryImpl
         parentLoader.useExplicitLoader(
-            "org.apache.commons.logging.tccl.custom.", emptyLoader);
+            MY_LOG_FACTORY_PKG + ".", emptyLoader);
         
         URL propsEnableUrl = new URL(baseUrl, "props_disable_tccl/");
         parentLoader.addURL(propsEnableUrl);
@@ -111,8 +117,7 @@
 
         // MyLogFactoryImpl should not be loadable via parent loader
         try {
-            Class clazz = thisClassLoader.loadClass(
-                "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
+            Class clazz = thisClassLoader.loadClass(MY_LOG_FACTORY_IMPL);
             fail("Unexpectedly able to load MyLogFactoryImpl via test class classloader");
         } catch(ClassNotFoundException ex) {
             // ok, expected
@@ -120,8 +125,7 @@
         
         // MyLogFactoryImpl should be loadable via tccl loader
         try {
-            Class clazz = tcclLoader.loadClass(
-                "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl");
+            Class clazz = tcclLoader.loadClass(MY_LOG_FACTORY_IMPL);
         } catch(ClassNotFoundException ex) {
             fail("Unexpectedly unable to load MyLogFactoryImpl via tccl classloader");
         }
@@ -134,11 +138,14 @@
      * we should see the default LogFactoryImpl rather than the custom one.
      */
     public void testTcclLoading() throws Exception {
-        LogFactory instance = LogFactory.getFactory();
-        
-        assertEquals(
-            "Correct LogFactory loaded", 
-            "org.apache.commons.logging.impl.LogFactoryImpl",
-            instance.getClass().getName());
+        try {
+            LogFactory instance = LogFactory.getFactory();
+            fail("Unexpectedly succeeded in loading custom factory, though TCCL disabled.");
+        } catch(org.apache.commons.logging.LogConfigurationException ex) {
+            // ok, custom MyLogFactoryImpl as specified in props_disable_tccl
+            // could not be found.
+            int index = ex.getMessage().indexOf(MY_LOG_FACTORY_IMPL);
+            assertTrue("MylogFactoryImpl not found", index >= 0);
+        }
     }
 }

Modified: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/props_disable_tccl/commons-logging.properties
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/props_disable_tccl/commons-logging.properties?rev=369755&r1=369754&r2=369755&view=diff
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/props_disable_tccl/commons-logging.properties
(original)
+++ jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/tccl/props_disable_tccl/commons-logging.properties
Tue Jan 17 03:29:42 2006
@@ -1 +1,2 @@
 use_tccl=false
+org.apache.commons.logging.LogFactory=org.apache.commons.logging.tccl.custom.MyLogFactoryImpl



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


Mime
View raw message