geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r634085 - in /geronimo/xbean/trunk/xbean-finder: pom.xml src/main/java/org/apache/xbean/finder/ClassFinder.java src/main/java/org/apache/xbean/finder/UrlSet.java src/test/java/org/apache/xbean/finder/ClassFinderTest.java
Date Wed, 05 Mar 2008 23:50:55 GMT
Author: dblevins
Date: Wed Mar  5 15:50:50 2008
New Revision: 634085

URL: http://svn.apache.org/viewvc?rev=634085&view=rev
Log:
Fixed out of memory error in tests

Modified:
    geronimo/xbean/trunk/xbean-finder/pom.xml
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/UrlSet.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java

Modified: geronimo/xbean/trunk/xbean-finder/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/pom.xml?rev=634085&r1=634084&r2=634085&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/pom.xml (original)
+++ geronimo/xbean/trunk/xbean-finder/pom.xml Wed Mar  5 15:50:50 2008
@@ -33,26 +33,6 @@
     <packaging>bundle</packaging>
     <name>XBean :: Classpath Resource Finder</name>
     
-    <properties>
-        <!-- HACK: Disable tests until OOME can be resolved -->
-        <test>false</test>
-    </properties>
-    
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-surefire-plugin</artifactId>
-                <configuration>
-                    <excludes>
-                        <!-- Disable this test which fails on Windows platforms -->
-                        <exclude>**/UrlSetTest*</exclude>
-                    </excludes>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
     <dependencies>
         <dependency>
            <groupId>asm</groupId>

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java?rev=634085&r1=634084&r2=634085&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ClassFinder.java
Wed Mar  5 15:50:50 2008
@@ -352,25 +352,11 @@
     }
 
     private static Collection<URL> getUrls(ClassLoader classLoader, ClassLoader excludeParent)
throws IOException {
-        Map<String, URL> urls = toMap(classLoader.getResources("META-INF"));
-
-        if (excludeParent != null) {
-            Map<String, URL> parentUrls = toMap(excludeParent.getResources("META-INF"));
-            for (String url : parentUrls.keySet()) {
-                urls.remove(url);
-            }
+        UrlSet urlSet = new UrlSet(classLoader);
+        if (excludeParent != null){
+            urlSet = urlSet.exclude(excludeParent);
         }
-
-        return urls.values();
-    }
-
-    private static Map<String, URL> toMap(Enumeration<URL> enumeration) {
-        Map<String, URL> urls = new HashMap<String, URL>();
-        while (enumeration.hasMoreElements()) {
-            URL url = enumeration.nextElement();
-            urls.put(url.toExternalForm(), url);
-        }
-        return urls;
+        return urlSet.getUrls();
     }
 
     private List<String> file(URL location) {

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/UrlSet.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/UrlSet.java?rev=634085&r1=634084&r2=634085&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/UrlSet.java (original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/UrlSet.java Wed
Mar  5 15:50:50 2008
@@ -17,7 +17,6 @@
 package org.apache.xbean.finder;
 
 import java.net.URL;
-import java.net.JarURLConnection;
 import java.net.MalformedURLException;
 import java.util.Collection;
 import java.util.List;
@@ -121,7 +120,14 @@
 
     public UrlSet excludeJavaHome() throws MalformedURLException {
         String path = System.getProperty("java.home");
-        return exclude(new File(path));
+
+        File java = new File(path);
+
+        if (path.matches("/System/Library/Frameworks/JavaVM.framework/Versions/[^/]+/Home")){
+            java = java.getParentFile();
+        }
+
+        return exclude(java);
     }
 
     public UrlSet excludePaths(String pathString) throws MalformedURLException {

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java?rev=634085&r1=634084&r2=634085&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
Wed Mar  5 15:50:50 2008
@@ -51,7 +51,16 @@
 
     public void setUp() throws Exception {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-        classFinder = new ClassFinder(classLoader);
+
+        UrlSet urlSet = new UrlSet(classLoader);
+
+        if (classLoader.getParent() != null){
+            urlSet = urlSet.exclude(classLoader.getParent());
+        }
+
+        urlSet = urlSet.excludeJavaHome();
+
+        classFinder = new ClassFinder(classLoader, urlSet.getUrls());
     }
 
     public void testFindAnnotatedPackages() throws Exception {



Mime
View raw message