commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skitch...@apache.org
Subject svn commit: r370739 - in /jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet: ./ BasicServletTestCase.java
Date Fri, 20 Jan 2006 05:54:31 GMT
Author: skitching
Date: Thu Jan 19 21:54:27 2006
New Revision: 370739

URL: http://svn.apache.org/viewcvs?rev=370739&view=rev
Log:
Add unit tests for ServletContextCleaner class.

Added:
    jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/
    jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
  (with props)

Added: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java?rev=370739&view=auto
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
(added)
+++ jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
Thu Jan 19 21:54:27 2006
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */ 
+
+package org.apache.commons.logging.log4j.log4j12;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.PathableClassLoader;
+import org.apache.commons.logging.PathableTestSuite;
+import org.apache.commons.logging.impl.ServletContextCleaner;
+
+
+/**
+ * Tests for ServletContextCleaner utility class.
+ */
+
+public class BasicServletTestCase extends TestCase {
+
+    /**
+     * Return the tests included in this test suite.
+     */
+    public static Test suite() throws Exception {
+        // LogFactory in parent
+        // LogFactory in child (loads test)
+        // LogFactory in tccl
+        //
+        // Having the test loaded via a loader above the tccl emulates the situation
+        // where a web.xml file specifies ServletContextCleaner as a listener, and
+        // that class is deployed via a shared classloader.
+
+        PathableClassLoader parent = new PathableClassLoader(null);
+        parent.useSystemLoader("junit.");
+        parent.addLogicalLib("commons-logging");
+        parent.addLogicalLib("servletapi");
+
+        PathableClassLoader child = new PathableClassLoader(parent);
+        child.setParentFirst(false);
+        child.addLogicalLib("commons-logging");
+        child.addLogicalLib("testclasses");
+
+        PathableClassLoader tccl = new PathableClassLoader(child);
+        tccl.setParentFirst(false);
+        tccl.addLogicalLib("commons-logging");
+
+        Class testClass = child.loadClass(BasicServletTestCase.class.getName());
+        return new PathableTestSuite(testClass, tccl);
+    }
+    
+    /**
+     * Test that calling ServletContextCleaner.contextDestroyed doesn't crash.
+     * Testing anything else is rather difficult...
+     */
+    public void testBasics() {
+        ServletContextCleaner scc = new ServletContextCleaner();
+        scc.contextDestroyed(null);
+    }
+}

Propchange: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/servlet/BasicServletTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
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