geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r405886 - in /geronimo/branches/1.1/modules/kernel/src: java/org/apache/geronimo/kernel/classloader/ test-data/ test-data/resourceFinderTest/ test-data/resourceFinderTest/jar1/ test-data/resourceFinderTest/jar2/ test/org/apache/geronimo/ker...
Date Fri, 12 May 2006 21:37:33 GMT
Author: djencks
Date: Fri May 12 14:37:33 2006
New Revision: 405886

URL: http://svn.apache.org/viewcvs?rev=405886&view=rev
Log:
GERONIMO-2009 fix JarFileResourceFinder

Added:
    geronimo/branches/1.1/modules/kernel/src/test-data/
    geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/
    geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar1/
    geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar1/resource
    geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar2/
    geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar2/resource
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/
    geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/JarFileResourceFinderTest.java
Modified:
    geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/classloader/JarFileResourceFinder.java

Modified: geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/classloader/JarFileResourceFinder.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/classloader/JarFileResourceFinder.java?rev=405886&r1=405885&r2=405886&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/classloader/JarFileResourceFinder.java
(original)
+++ geronimo/branches/1.1/modules/kernel/src/java/org/apache/geronimo/kernel/classloader/JarFileResourceFinder.java
Fri May 12 14:37:33 2006
@@ -283,6 +283,9 @@
             if (iterator == null) {
                 return;
             }
+            if (next != null) {
+                return;
+            }
 
             try {
                 while (iterator.hasNext()) {

Added: geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar1/resource
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar1/resource?rev=405886&view=auto
==============================================================================
    (empty)

Added: geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar2/resource
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test-data/resourceFinderTest/jar2/resource?rev=405886&view=auto
==============================================================================
    (empty)

Added: geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/JarFileResourceFinderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/JarFileResourceFinderTest.java?rev=405886&view=auto
==============================================================================
--- geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/JarFileResourceFinderTest.java
(added)
+++ geronimo/branches/1.1/modules/kernel/src/test/org/apache/geronimo/kernel/classloader/JarFileResourceFinderTest.java
Fri May 12 14:37:33 2006
@@ -0,0 +1,52 @@
+/**
+ *
+ * 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.geronimo.kernel.classloader;
+
+import java.net.URL;
+import java.util.Enumeration;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class JarFileResourceFinderTest extends TestCase {
+
+    /**
+     * There are 2 "jars" with a "resource" inside.  Make sure the enumeration has exactly
2 elements and
+     * that hasMoreElements() doesn't advance the iterator.
+     *
+     * @throws Exception
+     */
+    public void testResourceEnumeration() throws Exception {
+        ClassLoader cl = this.getClass().getClassLoader();
+        URL jar1 = cl.getResource("resourceFinderTest/jar1/");
+        URL jar2 = cl.getResource("resourceFinderTest/jar2/");
+        JarFileResourceFinder resourceFinder = new JarFileResourceFinder(new URL[] {jar1,
jar2});
+        Enumeration enumeration = resourceFinder.findResources("resource");
+        assertTrue(enumeration.hasMoreElements());
+        assertTrue(enumeration.hasMoreElements());
+        URL resource1 = (URL) enumeration.nextElement();
+        assertNotNull(resource1);
+        assertTrue(enumeration.hasMoreElements());
+        assertTrue(enumeration.hasMoreElements());
+        URL resource2 = (URL) enumeration.nextElement();
+        assertNotNull(resource2);
+        assertFalse(enumeration.hasMoreElements());
+    }
+}



Mime
View raw message