You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2008/11/15 01:53:29 UTC
svn commit: r714204 - in /geronimo/sandbox/djencks/jetty7:
geronimo-jetty7-builder/pom.xml geronimo-jetty7/pom.xml
geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java
Author: djencks
Date: Fri Nov 14 16:53:29 2008
New Revision: 714204
URL: http://svn.apache.org/viewvc?rev=714204&view=rev
Log:
Merge cl changes, remove excess dependencies
Modified:
geronimo/sandbox/djencks/jetty7/geronimo-jetty7-builder/pom.xml
geronimo/sandbox/djencks/jetty7/geronimo-jetty7/pom.xml
geronimo/sandbox/djencks/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java
Modified: geronimo/sandbox/djencks/jetty7/geronimo-jetty7-builder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/jetty7/geronimo-jetty7-builder/pom.xml?rev=714204&r1=714203&r2=714204&view=diff
==============================================================================
--- geronimo/sandbox/djencks/jetty7/geronimo-jetty7-builder/pom.xml (original)
+++ geronimo/sandbox/djencks/jetty7/geronimo-jetty7-builder/pom.xml Fri Nov 14 16:53:29 2008
@@ -74,11 +74,11 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>jcl104-over-slf4j</artifactId>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
</dependencies>
<build>
Modified: geronimo/sandbox/djencks/jetty7/geronimo-jetty7/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/jetty7/geronimo-jetty7/pom.xml?rev=714204&r1=714203&r2=714204&view=diff
==============================================================================
--- geronimo/sandbox/djencks/jetty7/geronimo-jetty7/pom.xml (original)
+++ geronimo/sandbox/djencks/jetty7/geronimo-jetty7/pom.xml Fri Nov 14 16:53:29 2008
@@ -118,16 +118,16 @@
<artifactId>jetty-plus</artifactId>
</dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl104-over-slf4j</artifactId>
- <scope>test</scope>
- </dependency>
+ <!--<dependency>-->
+ <!--<groupId>xerces</groupId>-->
+ <!--<artifactId>xercesImpl</artifactId>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
+ <!--<dependency>-->
+ <!--<groupId>org.slf4j</groupId>-->
+ <!--<artifactId>jcl104-over-slf4j</artifactId>-->
+ <!--<scope>test</scope>-->
+ <!--</dependency>-->
</dependencies>
<build>
Modified: geronimo/sandbox/djencks/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java?rev=714204&r1=714203&r2=714204&view=diff
==============================================================================
--- geronimo/sandbox/djencks/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java (original)
+++ geronimo/sandbox/djencks/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/ClassLoaderTest.java Fri Nov 14 16:53:29 2008
@@ -19,11 +19,16 @@
import java.io.File;
import java.net.URL;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+import java.util.Collections;
import org.apache.geronimo.testsupport.TestSupport;
import org.apache.geronimo.kernel.config.MultiParentClassLoader;
import org.apache.geronimo.kernel.repository.Artifact;
+import org.apache.geronimo.kernel.repository.ClassLoadingRules;
/**
* Tests loading various classes (as classes and URL resources) with different
@@ -36,13 +41,17 @@
Artifact configId = new Artifact("foo", "bar", "1", "car");
ClassLoader cl;
URL[] urls;
- private static final String[] HIDDEN = {"org.apache.geronimo", "org.mortbay", "org.xml", "org.w3c"};
- private static final String[] NON_OVERRIDABLE = {"java.", "javax."};
+ private static final Set<String> HIDDEN = new HashSet<String>(Arrays.asList("org.apache.geronimo", "org.mortbay", "org.xml", "org.w3c"));
+ private static final Set<String> NON_OVERRIDABLE = new HashSet<String>(Arrays.asList("java.", "javax."));
+ private final ClassLoadingRules clRules = new ClassLoadingRules();
public void setUp() throws Exception {
super.setUp();
URL url = new File(BASEDIR, "src/test/resources/deployables/cltest/").toURL();
urls = new URL[]{url};
+ clRules.setInverseClassLoading(false);
+ clRules.getHiddenRule().setClassPrefixes(HIDDEN);
+ clRules.getNonOverrideableRule().setClassPrefixes(NON_OVERRIDABLE);
}
//todo: try more restricted prefixed besides javax.*
@@ -52,7 +61,7 @@
* parent ClassLoader. This should work.
*/
public void testFalseNonexistantJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
cl.loadClass("javax.foo.Foo");
} catch(ClassNotFoundException e) {
@@ -65,7 +74,8 @@
* parent ClassLoader. This should work.
*/
public void testTrueNonexistantJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, HIDDEN, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
cl.loadClass("javax.foo.Foo");
} catch(ClassNotFoundException e) {
@@ -79,7 +89,7 @@
* This should always load the parent's copy.
*/
public void testFalseExistantJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
Class cls = cl.loadClass("javax.servlet.Servlet");
assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0);
@@ -94,7 +104,8 @@
* This should always load the parent's copy.
*/
public void testTrueExistantJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, HIDDEN, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
Class cls = cl.loadClass("javax.servlet.Servlet");
assertTrue("Loaded wrong class first; expected to find parent CL's copy of javax.servlet.Servlet",cls.getDeclaredMethods().length > 0);
@@ -111,7 +122,7 @@
* copy when the contextPriorityClassLoader is set to true.
*/
public void xtestFalseExistantNonJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
Class cls = cl.loadClass("mx4j.MBeanDescription");
assertTrue("Should not have overriden parent CL definition of class mx4j.MBeanDescription", cls.getDeclaredMethods().length > 0);
@@ -128,7 +139,8 @@
* the contextPriorityClassLoader is set to true (as here).
*/
public void xtestTrueExistantNonJavaxClass() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, HIDDEN, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
try {
Class cls = cl.loadClass("mx4j.MBeanDescription");
assertTrue("Should be able to override a class that is not in java.*, javax.*, etc.", cls.getDeclaredMethods().length == 0);
@@ -142,7 +154,7 @@
* parent ClassLoader. This should work.
*/
public void testFalseNonexistantJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("javax/foo/Foo.class");
if(url == null) {
fail("Should be able to load a javax.* class that is not defined by my parent CL");
@@ -155,7 +167,8 @@
* parent ClassLoader. This should work.
*/
public void testTrueNonexistantJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, HIDDEN, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("javax/foo/Foo.class");
if(url == null) {
fail("Should be able to load a javax.* class that is not defined by my parent CL");
@@ -169,7 +182,7 @@
* This should always load the parent's copy.
*/
public void testFalseExistantJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("javax/servlet/Servlet.class");
if(url == null) {
fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
@@ -183,7 +196,8 @@
* This should always load the parent's copy.
*/
public void testTrueExistantJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, HIDDEN, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("javax/servlet/Servlet.class");
if(url == null) {
fail("Problem with test; expecting to have javax.servlet.* on the ClassPath");
@@ -199,7 +213,7 @@
* copy when the contextPriorityClassLoader is set to true.
*/
public void xtestFalseExistantNonJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), false, HIDDEN, NON_OVERRIDABLE);
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("mx4j/MBeanDescription.class");
if(url == null) {
fail("Problem with test; expecting to have mx4j.* on the ClassPath");
@@ -215,7 +229,9 @@
* the contextPriorityClassLoader is set to true (as here).
*/
public void testTrueExistantNonJavaxResource() {
- cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), true, new String[] {}, NON_OVERRIDABLE);
+ clRules.setInverseClassLoading(true);
+ clRules.getHiddenRule().setClassPrefixes(Collections.<String>emptySet());
+ cl = new MultiParentClassLoader(configId, urls, getClass().getClassLoader(), clRules);
URL url = cl.getResource("mx4j/MBeanDescription.class");
if(url == null) {
fail("Problem with test; expecting to have mx4j.* on the ClassPath");