[jboss-cvs] JBossAS SVN: r107115 - in projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate: support/c and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 27 10:19:09 EDT 2010
Author: alesj
Date: 2010-07-27 10:19:08 -0400 (Tue, 27 Jul 2010)
New Revision: 107115
Added:
projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/TestDelegateLoader.java
projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/c/
projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/c/TestC1.java
Modified:
projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateUnitTestCase.java
Log:
Test index.
Added: projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/TestDelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/TestDelegateLoader.java (rev 0)
+++ projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/TestDelegateLoader.java 2010-07-27 14:19:08 UTC (rev 107115)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.classloader.delegate.support;
+
+import java.net.URL;
+
+import org.jboss.classloader.spi.ClassLoaderPolicy;
+import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TestDelegateLoader extends FilteredDelegateLoader
+{
+ private boolean getResourceInvoked;
+
+ public TestDelegateLoader(ClassLoaderPolicy delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ public URL getResource(String name)
+ {
+ getResourceInvoked = true;
+ return super.getResource(name);
+ }
+
+ public boolean isGetResourceInvoked()
+ {
+ return getResourceInvoked;
+ }
+}
Added: projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/c/TestC1.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/c/TestC1.java (rev 0)
+++ projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/support/c/TestC1.java 2010-07-27 14:19:08 UTC (rev 107115)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.classloader.delegate.support.c;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class TestC1
+{
+}
Modified: projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateUnitTestCase.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateUnitTestCase.java 2010-07-27 13:54:42 UTC (rev 107114)
+++ projects/jboss-cl/trunk/classloader/src/test/java/org/jboss/test/classloader/delegate/test/DelegateUnitTestCase.java 2010-07-27 14:19:08 UTC (rev 107115)
@@ -37,12 +37,14 @@
import org.jboss.classloader.spi.filter.FilteredDelegateLoader;
import org.jboss.classloader.test.support.MockClassLoaderPolicy;
import org.jboss.test.classloader.AbstractClassLoaderTestWithSecurity;
+import org.jboss.test.classloader.delegate.support.TestDelegateLoader;
import org.jboss.test.classloader.delegate.support.a.TestA1;
import org.jboss.test.classloader.delegate.support.a.TestADelegateClassLoaderDomain;
import org.jboss.test.classloader.delegate.support.a.TestAbstractFactory;
import org.jboss.test.classloader.delegate.support.a.TestSleep;
import org.jboss.test.classloader.delegate.support.b.TestB1;
import org.jboss.test.classloader.delegate.support.b.TestFactoryImplementation;
+import org.jboss.test.classloader.delegate.support.c.TestC1;
import org.jboss.test.thread.TestThread;
import junit.framework.Test;
@@ -336,4 +338,31 @@
assertLoadClass(TestA1.class, a);
assertLoadClass(TestA1.class, b, a);
}
+
+ public void testPackageIndex() throws Exception
+ {
+ ClassLoaderSystem system = createClassLoaderSystemWithModifiedBootstrap();
+
+ MockClassLoaderPolicy pa = createMockClassLoaderPolicy("A");
+ pa.setPathsAndPackageNames(TestA1.class);
+ ClassLoader a = system.registerClassLoaderPolicy(pa);
+
+ MockClassLoaderPolicy pb = createMockClassLoaderPolicy("B");
+ pb.setPathsAndPackageNames(TestB1.class);
+ ClassLoader b = system.registerClassLoaderPolicy(pb);
+
+ MockClassLoaderPolicy pc = createMockClassLoaderPolicy("C");
+ pc.setPathsAndPackageNames(TestC1.class);
+ List<DelegateLoader> delegates = new ArrayList<DelegateLoader>();
+ TestDelegateLoader tdl = new TestDelegateLoader(pa);
+ delegates.add(tdl);
+ delegates.add(new FilteredDelegateLoader(pb));
+ pc.setDelegates(delegates);
+ ClassLoader c = system.registerClassLoaderPolicy(pc);
+
+ assertLoadClass(TestB1.class, c, b);
+ assertFalse(tdl.isGetResourceInvoked()); // index should kick in before list
+ assertLoadClass(TestA1.class, c, a);
+ assertTrue(tdl.isGetResourceInvoked());
+ }
}
More information about the jboss-cvs-commits
mailing list