Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 30784 invoked from network); 2 Aug 2006 00:19:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Aug 2006 00:19:21 -0000 Received: (qmail 16975 invoked by uid 500); 2 Aug 2006 00:19:18 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 16903 invoked by uid 500); 2 Aug 2006 00:19:18 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 16887 invoked by uid 500); 2 Aug 2006 00:19:18 -0000 Received: (qmail 16884 invoked by uid 99); 2 Aug 2006 00:19:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Aug 2006 17:19:18 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Aug 2006 17:19:17 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 453D61A981A; Tue, 1 Aug 2006 17:18:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r427814 - /jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java Date: Wed, 02 Aug 2006 00:18:56 -0000 To: commons-cvs@jakarta.apache.org From: skitching@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060802001857.453D61A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: skitching Date: Tue Aug 1 17:18:56 2006 New Revision: 427814 URL: http://svn.apache.org/viewvc?rev=427814&view=rev Log: Make test compatible with maven2 surefire. Modified: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java Modified: jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java?rev=427814&r1=427813&r2=427814&view=diff ============================================================================== --- jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java (original) +++ jakarta/commons/proper/logging/trunk/src/test/org/apache/commons/logging/pathable/ParentFirstTestCase.java Tue Aug 1 17:18:56 2006 @@ -20,6 +20,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Enumeration; +import java.util.HashSet; +import java.util.Set; import junit.framework.Test; import junit.framework.TestCase; @@ -86,6 +88,21 @@ } /** + * Utility method to return the set of all classloaders in the + * parent chain starting from the one that loaded the class for + * this object instance. + */ + private Set getAncestorCLs() { + Set s = new HashSet(); + ClassLoader cl = this.getClass().getClassLoader(); + while (cl != null) { + s.add(cl); + cl = cl.getParent(); + } + return s; + } + + /** * Test that the classloader hierarchy is as expected, and that * calling loadClass() on various classloaders works as expected. * Note that for this test case, parent-first classloading is @@ -130,11 +147,13 @@ PathableClassLoader.class.getName().equals( systemLoader.getClass().getName())); - // junit classes should be visible; their classloader is system. - // this will of course throw an exception if not found. + // junit classes should be visible; their classloader is not + // in the hierarchy of parent classloaders for this class, + // though it is accessable due to trickery in the PathableClassLoader. Class junitTest = contextLoader.loadClass("junit.framework.Test"); - assertSame("Junit not loaded via systemloader", - systemLoader, junitTest.getClassLoader()); + Set ancestorCLs = getAncestorCLs(); + assertFalse("Junit not loaded by ancestor classloader", + ancestorCLs.contains(junitTest.getClassLoader())); // jcl api classes should be visible only via the parent Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log"); --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org