geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1064425 - in /geronimo/xbean/trunk: xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/ xbean-finder/src/main/java/org/apache/xbean/finder/ xbean-finder/src/test/java/org/apache/xbean/finder/
Date Fri, 28 Jan 2011 02:13:40 GMT
Author: djencks
Date: Fri Jan 28 02:13:40 2011
New Revision: 1064425

URL: http://svn.apache.org/viewvc?rev=1064425&view=rev
Log:
XBEAN-162 genericize usage of Class

Modified:
    geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
    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/ResourceFinder.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderTest.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ResourceFinderTest.java

Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassFinder.java?rev=1064425&r1=1064424&r2=1064425&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleClassFinder.java
Fri Jan 28 02:13:40 2011
@@ -81,8 +81,8 @@ public class BundleClassFinder {
         this.discoveryFilter = discoveryFilter;
     }
 
-    public List<Class> loadClasses(Set<String> classes) {
-        List<Class> loadedClasses = new ArrayList<Class>(classes.size());
+    public List<Class<?>> loadClasses(Set<String> classes) {
+        List<Class<?>> loadedClasses = new ArrayList<Class<?>>(classes.size());
         for (String clazz : classes) {
             try {
                 loadedClasses.add(bundle.loadClass(clazz));

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java?rev=1064425&r1=1064424&r2=1064425&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AbstractFinder.java
Fri Jan 28 02:13:40 2011
@@ -31,7 +31,6 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -190,9 +189,9 @@ public abstract class AbstractFinder {
         return packages;
     }
 
-    public List<Class> findAnnotatedClasses(Class<? extends Annotation> annotation)
{
+    public List<Class<?>> findAnnotatedClasses(Class<? extends Annotation>
annotation) {
         classesNotLoaded.clear();
-        List<Class> classes = new ArrayList<Class>();
+        List<Class<?>> classes = new ArrayList<Class<?>>();
         List<Info> infos = getAnnotationInfos(annotation.getName());
         for (Info info : infos) {
             if (info instanceof ClassInfo) {
@@ -217,9 +216,9 @@ public abstract class AbstractFinder {
      * @param annotation
      * @return list of directly or indirectly (inherited) annotated classes
      */
-    public List<Class> findInheritedAnnotatedClasses(Class<? extends Annotation>
annotation) {
+    public List<Class<?>> findInheritedAnnotatedClasses(Class<? extends Annotation>
annotation) {
         classesNotLoaded.clear();
-        List<Class> classes = new ArrayList<Class>();
+        List<Class<?>> classes = new ArrayList<Class<?>>();
         List<Info> infos = getAnnotationInfos(annotation.getName());
         for (Info info : infos) {
             try {
@@ -356,9 +355,9 @@ public abstract class AbstractFinder {
         return fields;
     }
 
-    public List<Class> findClassesInPackage(String packageName, boolean recursive)
{
+    public List<Class<?>> findClassesInPackage(String packageName, boolean recursive)
{
         classesNotLoaded.clear();
-        List<Class> classes = new ArrayList<Class>();
+        List<Class<?>> classes = new ArrayList<Class<?>>();
         for (ClassInfo classInfo : classInfos.values()) {
             try {
                 if (recursive && classInfo.getPackageName().startsWith(packageName)){
@@ -381,26 +380,25 @@ public abstract class AbstractFinder {
         final ClassInfo classInfo = classInfos.get(clazz.getName());
 
         List<Class<? extends T>> found = new ArrayList<Class<? extends
T>>();
-        List<Class<? extends T>> found2 = new LinkedList<Class<? extends
T>>();
 
         if (classInfo == null) return found;
 
-        findSubclasses(classInfo, found);
+        findSubclasses(classInfo, found, clazz);
 
         return found;
     }
 
-    private <T> void findSubclasses(ClassInfo classInfo, List<Class<? extends
T>> found) {
+    private <T> void findSubclasses(ClassInfo classInfo, List<Class<? extends
T>> found, Class<T> clazz) {
 
         for (ClassInfo subclassInfo : classInfo.subclassInfos) {
 
             try {
-                found.add(subclassInfo.get());
+                found.add(subclassInfo.get().asSubclass(clazz));
             } catch (ClassNotFoundException e) {
                 classesNotLoaded.add(subclassInfo.getName());
             }
 
-            findSubclasses(subclassInfo, found);
+            findSubclasses(subclassInfo, found, clazz);
         }
     }
 
@@ -418,9 +416,9 @@ public abstract class AbstractFinder {
 
                     if (clazz.isAssignableFrom(classInfo.get())) {
 
-                        classes.add(classInfo.get());
+                        classes.add(classInfo.get().asSubclass(clazz));
 
-                        classes.addAll(_findSubclasses(classInfo.get()));
+                        classes.addAll(_findSubclasses(classInfo.get().asSubclass(clazz)));
                     }
                 }
 
@@ -505,6 +503,14 @@ public abstract class AbstractFinder {
     }
 
     protected void readClassDef(String className) {
+        int pos = className.indexOf("<");
+        if (pos > -1) {
+            className = className.substring(0, pos);
+        }
+        pos = className.indexOf(">");
+        if (pos > -1) {
+            className = className.substring(0, pos);
+        }
         if (!className.endsWith(".class")) {
             className = className.replace('.', '/') + ".class";
         }
@@ -717,7 +723,7 @@ public abstract class AbstractFinder {
             return superType;
         }
 
-        public Class get() throws ClassNotFoundException {
+        public Class<?> get() throws ClassNotFoundException {
             if (clazz != null) return clazz;
             try {
                 String fixedName = name.replaceFirst("<.*>", "");

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=1064425&r1=1064424&r2=1064425&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
Fri Jan 28 02:13:40 2011
@@ -19,9 +19,6 @@ package org.apache.xbean.finder;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.net.JarURLConnection;
 import java.net.URL;
 import java.net.URLDecoder;
@@ -126,13 +123,13 @@ public class ClassFinder extends Abstrac
         }
     }
 
-    public ClassFinder(Class... classes){
+    public ClassFinder(Class<?>... classes){
         this(Arrays.asList(classes));
     }
 
-    public ClassFinder(List<Class> classes){
+    public ClassFinder(List<Class<?>> classes){
         this.classLoader = null;
-        for (Class clazz : classes) {
+        for (Class<?> clazz : classes) {
             try {
                 readClassDef(clazz);
             } catch (NoClassDefFoundError e) {

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ResourceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ResourceFinder.java?rev=1064425&r1=1064424&r2=1064425&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ResourceFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/ResourceFinder.java
Fri Jan 28 02:13:40 2011
@@ -312,9 +312,9 @@ public class ResourceFinder {
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    public Class findClass(String uri) throws IOException, ClassNotFoundException {
+    public Class<?> findClass(String uri) throws IOException, ClassNotFoundException
{
         String className = findString(uri);
-        return (Class) classLoader.loadClass(className);
+        return classLoader.loadClass(className);
     }
 
     /**
@@ -328,11 +328,11 @@ public class ResourceFinder {
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    public List<Class> findAllClasses(String uri) throws IOException, ClassNotFoundException
{
-        List<Class> classes = new ArrayList<Class>();
+    public List<Class<?>> findAllClasses(String uri) throws IOException, ClassNotFoundException
{
+        List<Class<?>> classes = new ArrayList<Class<?>>();
         List<String> strings = findAllStrings(uri);
         for (String className : strings) {
-            Class clazz = classLoader.loadClass(className);
+            Class<?> clazz = classLoader.loadClass(className);
             classes.add(clazz);
         }
         return classes;
@@ -349,13 +349,13 @@ public class ResourceFinder {
      * @return
      * @throws IOException if classLoader.getResources throws an exception
      */
-    public List<Class> findAvailableClasses(String uri) throws IOException {
+    public List<Class<?>> findAvailableClasses(String uri) throws IOException
{
         resourcesNotLoaded.clear();
-        List<Class> classes = new ArrayList<Class>();
+        List<Class<?>> classes = new ArrayList<Class<?>>();
         List<String> strings = findAvailableStrings(uri);
         for (String className : strings) {
             try {
-                Class clazz = classLoader.loadClass(className);
+                Class<?> clazz = classLoader.loadClass(className);
                 classes.add(clazz);
             } catch (Exception notAvailable) {
                 resourcesNotLoaded.add(className);
@@ -387,14 +387,13 @@ public class ResourceFinder {
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    public Map<String, Class> mapAllClasses(String uri) throws IOException, ClassNotFoundException
{
-        Map<String, Class> classes = new HashMap<String, Class>();
+    public Map<String, Class<?>> mapAllClasses(String uri) throws IOException,
ClassNotFoundException {
+        Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
         Map<String, String> map = mapAllStrings(uri);
-        for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String string = (String) entry.getKey();
-            String className = (String) entry.getValue();
-            Class clazz = classLoader.loadClass(className);
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            String string = entry.getKey();
+            String className = entry.getValue();
+            Class<?> clazz = classLoader.loadClass(className);
             classes.put(string, clazz);
         }
         return classes;
@@ -423,16 +422,15 @@ public class ResourceFinder {
      * @return
      * @throws IOException if classLoader.getResources throws an exception
      */
-    public Map<String, Class> mapAvailableClasses(String uri) throws IOException {
+    public Map<String, Class<?>> mapAvailableClasses(String uri) throws IOException
{
         resourcesNotLoaded.clear();
-        Map<String, Class> classes = new HashMap<String, Class>();
+        Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
         Map<String, String> map = mapAvailableStrings(uri);
-        for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String string = (String) entry.getKey();
-            String className = (String) entry.getValue();
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            String string = entry.getKey();
+            String className = entry.getValue();
             try {
-                Class clazz = classLoader.loadClass(className);
+                Class<?> clazz = classLoader.loadClass(className);
                 classes.put(string, clazz);
             } catch (Exception notAvailable) {
                 resourcesNotLoaded.add(className);
@@ -468,9 +466,9 @@ public class ResourceFinder {
      * @throws ClassNotFoundException if the class found is not loadable
      * @throws ClassCastException     if the class found is not assignable to the specified
superclass or interface
      */
-    public Class findImplementation(Class interfase) throws IOException, ClassNotFoundException
{
+    public Class<?> findImplementation(Class<?> interfase) throws IOException,
ClassNotFoundException {
         String className = findString(interfase.getName());
-        Class impl = classLoader.loadClass(className);
+        Class<?> impl = classLoader.loadClass(className);
         if (!interfase.isAssignableFrom(impl)) {
             throw new ClassCastException("Class not of type: " + interfase.getName());
         }
@@ -502,14 +500,11 @@ public class ResourceFinder {
      * @throws ClassNotFoundException if the class found is not loadable
      * @throws ClassCastException     if the class found is not assignable to the specified
superclass or interface
      */
-    public List<Class> findAllImplementations(Class interfase) throws IOException,
ClassNotFoundException {
-        List<Class> implementations = new ArrayList<Class>();
+    public <T> List<Class<? extends T>> findAllImplementations(Class<T>
interfase) throws IOException, ClassNotFoundException {
+        List<Class<? extends T>> implementations = new ArrayList<Class<?
extends T>>();
         List<String> strings = findAllStrings(interfase.getName());
         for (String className : strings) {
-            Class impl = classLoader.loadClass(className);
-            if (!interfase.isAssignableFrom(impl)) {
-                throw new ClassCastException("Class not of type: " + interfase.getName());
-            }
+            Class<? extends T> impl = classLoader.loadClass(className).asSubclass(interfase);
             implementations.add(impl);
         }
         return implementations;
@@ -538,15 +533,15 @@ public class ResourceFinder {
      * @return
      * @throws IOException if classLoader.getResources throws an exception
      */
-    public List<Class> findAvailableImplementations(Class interfase) throws IOException
{
+    public <T> List<Class<? extends T>> findAvailableImplementations(Class<T>
interfase) throws IOException {
         resourcesNotLoaded.clear();
-        List<Class> implementations = new ArrayList<Class>();
+        List<Class<? extends T>> implementations = new ArrayList<Class<?
extends T>>();
         List<String> strings = findAvailableStrings(interfase.getName());
         for (String className : strings) {
             try {
-                Class impl = classLoader.loadClass(className);
+                Class<?> impl = classLoader.loadClass(className);
                 if (interfase.isAssignableFrom(impl)) {
-                    implementations.add(impl);
+                    implementations.add(impl.asSubclass(interfase));
                 } else {
                     resourcesNotLoaded.add(className);
                 }
@@ -582,17 +577,13 @@ public class ResourceFinder {
      * @throws ClassNotFoundException if the class found is not loadable
      * @throws ClassCastException     if the class found is not assignable to the specified
superclass or interface
      */
-    public Map<String, Class> mapAllImplementations(Class interfase) throws IOException,
ClassNotFoundException {
-        Map<String, Class> implementations = new HashMap<String, Class>();
+    public <T> Map<String, Class<? extends T>> mapAllImplementations(Class<T>
interfase) throws IOException, ClassNotFoundException {
+        Map<String, Class<? extends T>> implementations = new HashMap<String,
Class<? extends T>>();
         Map<String, String> map = mapAllStrings(interfase.getName());
-        for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String string = (String) entry.getKey();
-            String className = (String) entry.getValue();
-            Class impl = classLoader.loadClass(className);
-            if (!interfase.isAssignableFrom(impl)) {
-                throw new ClassCastException("Class not of type: " + interfase.getName());
-            }
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            String string = entry.getKey();
+            String className = entry.getValue();
+            Class<? extends T> impl = classLoader.loadClass(className).asSubclass(interfase);
             implementations.put(string, impl);
         }
         return implementations;
@@ -621,18 +612,17 @@ public class ResourceFinder {
      * @return
      * @throws IOException if classLoader.getResources throws an exception
      */
-    public Map<String, Class> mapAvailableImplementations(Class interfase) throws IOException
{
+    public <T> Map<String, Class<? extends T>> mapAvailableImplementations(Class<T>
interfase) throws IOException {
         resourcesNotLoaded.clear();
-        Map<String, Class> implementations = new HashMap<String, Class>();
+        Map<String, Class<? extends T>> implementations = new HashMap<String,
Class<? extends T>>();
         Map<String, String> map = mapAvailableStrings(interfase.getName());
-        for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) {
-            Map.Entry entry = (Map.Entry) iterator.next();
-            String string = (String) entry.getKey();
-            String className = (String) entry.getValue();
+        for (Map.Entry<String, String> entry : map.entrySet()) {
+            String string = entry.getKey();
+            String className = entry.getValue();
             try {
-                Class impl = classLoader.loadClass(className);
+                Class<?> impl = classLoader.loadClass(className);
                 if (interfase.isAssignableFrom(impl)) {
-                    implementations.put(string, impl);
+                    implementations.put(string, impl.asSubclass(interfase));
                 } else {
                     resourcesNotLoaded.add(className);
                 }

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java?rev=1064425&r1=1064424&r2=1064425&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
Fri Jan 28 02:13:40 2011
@@ -16,11 +16,14 @@
  */
 package org.apache.xbean.finder;
 
-import junit.framework.TestCase;
-
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.List;
 
+import junit.framework.TestCase;
+
 /**
  * @version $Rev$ $Date$
  */
@@ -73,6 +76,14 @@ public class ClassFinderDepthTest extend
         assertImplementations(finder, HSB.class, Color.class, Red.class, Crimson.class);
         assertImplementations(finder, Hue.class, HSB.class, Color.class, Red.class, Crimson.class);
     }
+    
+    public void testAnnotationImpl() throws Exception {
+        URL url1 = new File("/Users/david/.m2/repository/org/apache/geronimo/specs/geronimo-jcdi_1.0_spec/1.0/geronimo-jcdi_1.0_spec-1.0.jar").toURI().toURL();
+        URL url2 = new File("/Users/david/.m2/repository/org/jboss/jsr299/tck/jsr299-tck-impl/1.0.4.CR1/jsr299-tck-impl-1.0.4.CR1.jar").toURI().toURL();
+
+        ClassLoader parent = getClass().getClassLoader();
+        final AbstractFinder finder = new ClassFinder(new URLClassLoader(new URL[] {url1,
url2}, parent)).link();
+    }
 
     private void assertSubclasses(AbstractFinder finder, Class<?> clazz, Class... subclasses)
{
         final List<Class<?>> classes = new ArrayList(finder.findSubclasses(clazz));

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=1064425&r1=1064424&r2=1064425&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
Fri Jan 28 02:13:40 2011
@@ -16,22 +16,34 @@
  */
 package org.apache.xbean.finder;
 
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
 import junit.framework.TestCase;
+import org.acme.bar.AnnType;
+import org.acme.bar.Construct;
+import org.acme.bar.FullyAnnotated;
 import org.acme.bar.Get;
 import org.acme.bar.ParamA;
-import org.acme.bar.Construct;
 import org.acme.bar.Type;
-import org.acme.bar.AnnType;
-import org.acme.bar.FullyAnnotated;
-import org.acme.foo.*;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.Arrays;
+import org.acme.foo.Blue;
+import org.acme.foo.Color;
+import org.acme.foo.Deployable;
+import org.acme.foo.FamilyHalloween;
+import org.acme.foo.FunnyFamilyHalloween;
+import org.acme.foo.GenericHoliday;
+import org.acme.foo.Green;
+import org.acme.foo.Halloween;
+import org.acme.foo.Holiday;
+import org.acme.foo.Primary;
+import org.acme.foo.Property;
+import org.acme.foo.Red;
+import org.acme.foo.StringGenericHoliday;
+import org.acme.foo.Thanksgiving;
+import org.acme.foo.ValentinesDay;
 
 /**
  * @author David Blevins
@@ -66,7 +78,7 @@ public class ClassFinderTest extends Tes
     public void testFindAnnotatedClasses() throws Exception {
 
         Class[] expected = {Halloween.class, Thanksgiving.class, ValentinesDay.class, GenericHoliday.class};
-        List<Class> actual = classFinder.findAnnotatedClasses(Holiday.class);
+        List<Class<?>> actual = classFinder.findAnnotatedClasses(Holiday.class);
 
         assertNotNull(actual);
         assertEquals(expected.length, actual.size());
@@ -95,7 +107,7 @@ public class ClassFinderTest extends Tes
 
     public void testFindInheritedAnnotatedClassesInherited() throws Exception {
         Class[] expected = {FunnyFamilyHalloween.class, FamilyHalloween.class, Halloween.class,
Thanksgiving.class, ValentinesDay.class, GenericHoliday.class, StringGenericHoliday.class};
-        List<Class> actual = classFinder.findInheritedAnnotatedClasses(Holiday.class);
+        List<Class<?>> actual = classFinder.findInheritedAnnotatedClasses(Holiday.class);
 
         assertNotNull(actual);
         assertEquals(expected.length, actual.size());
@@ -155,11 +167,11 @@ public class ClassFinderTest extends Tes
         testFindAnnotatedPackages();
     }
     public void testFindClassesInPackage() throws Exception{
-    	List<Class> classesInPackage = classFinder.findClassesInPackage("org.acme.foo",
false);
-    	Class[] classesArray = {Blue.class, Blue.Navy.class, Blue.Sky.class, Green.class, Green.Emerald.class,
Red.class,
+    	List<Class<?>> classesInPackage = classFinder.findClassesInPackage("org.acme.foo",
false);
+    	Class<?>[] classesArray = {Blue.class, Blue.Navy.class, Blue.Sky.class, Green.class,
Green.Emerald.class, Red.class,
                 Red.CandyApple.class, Red.Pink.class, Halloween.class, Holiday.class, Deployable.class,
Primary.class,
                 Property.class, Thanksgiving.class, ValentinesDay.class};
-    	List<Class> classes = Arrays.asList(classesArray);
+    	List<Class<?>> classes = Arrays.asList(classesArray);
     	assertEquals(true, classesInPackage.containsAll(classes));
     }
 }

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ResourceFinderTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ResourceFinderTest.java?rev=1064425&r1=1064424&r2=1064425&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ResourceFinderTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ResourceFinderTest.java
Fri Jan 28 02:13:40 2011
@@ -19,6 +19,13 @@ package org.apache.xbean.finder;
 /**
  * @version $Rev$ $Date$
  */
+
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
 import junit.framework.TestCase;
 import org.acme.BarUrlHandler;
 import org.acme.FooUrlHandler;
@@ -29,13 +36,6 @@ import org.acme.javaURLContextFactory;
 import org.acme.kernelURLContextFactory;
 import org.acme.ldapURLContextFactory;
 
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.ArrayList;
-
 public class ResourceFinderTest extends TestCase {
     ResourceFinder resourceFinder = new ResourceFinder("META-INF/");
 
@@ -84,7 +84,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testFindAllStrings() throws Exception {
-        List<String> manifests = null;
+        List<String> manifests;
         try {
             manifests = resourceFinder.findAllStrings("MANIFEST.MF");
         } catch (Exception thisIsLegal) {
@@ -155,7 +155,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testFindAllClasses() throws Exception {
-        List<Class> classes = resourceFinder.findAllClasses("java.io.Serializable");
+        List<Class<?>> classes = resourceFinder.findAllClasses("java.io.Serializable");
         assertEquals("size", 1, classes.size());
         assertEquals(One.class, classes.get(0));
 
@@ -170,7 +170,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testFindAvailableClasses() throws Exception {
-        List<Class> classes = resourceFinder.findAvailableClasses("java.io.Serializable");
+        List<Class<?>> classes = resourceFinder.findAvailableClasses("java.io.Serializable");
         assertEquals("size", 1, classes.size());
         assertEquals(One.class, classes.get(0));
 
@@ -179,7 +179,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testMapAllClasses() throws Exception {
-        Map<String, Class> resourcesMap = resourceFinder.mapAllClasses("serializables");
+        Map<String, Class<?>> resourcesMap = resourceFinder.mapAllClasses("serializables");
 
         assertEquals("map size", 3, resourcesMap.size());
         assertTrue("map contains key 'one'", resourcesMap.containsKey("one"));
@@ -202,7 +202,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testMapAvailableClasses() throws Exception {
-        Map<String, Class> resourcesMap = resourceFinder.mapAvailableClasses("externalizables");
+        Map<String, Class<?>> resourcesMap = resourceFinder.mapAvailableClasses("externalizables");
 
         assertEquals("map size", 2, resourcesMap.size());
         assertTrue("map contains key 'one'", resourcesMap.containsKey("one"));
@@ -233,7 +233,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testFindAllImplementations() throws Exception {
-        List<Class> classes = resourceFinder.findAllImplementations(java.io.Serializable.class);
+        List<Class<? extends java.io.Serializable>> classes = resourceFinder.findAllImplementations(java.io.Serializable.class);
         assertEquals("size", 1, classes.size());
         assertEquals(One.class, classes.get(0));
 
@@ -247,7 +247,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testMapAllImplementations() throws Exception {
-        Map<String, Class> resourcesMap = resourceFinder.mapAllImplementations(javax.naming.spi.ObjectFactory.class);
+        Map<String, Class<? extends javax.naming.spi.ObjectFactory>> resourcesMap
= resourceFinder.mapAllImplementations(javax.naming.spi.ObjectFactory.class);
 
         assertEquals("map size", 3, resourcesMap.size());
         assertTrue("map contains key 'java'", resourcesMap.containsKey("java"));
@@ -270,7 +270,7 @@ public class ResourceFinderTest extends 
     }
 
     public void testMapAvailableImplementations() throws Exception {
-        Map<String, Class> resourcesMap = resourceFinder.mapAvailableImplementations(java.net.URLStreamHandler.class);
+        Map<String, Class<? extends java.net.URLStreamHandler>> resourcesMap
= resourceFinder.mapAvailableImplementations(java.net.URLStreamHandler.class);
 
         assertEquals("map size", 2, resourcesMap.size());
         assertTrue("map contains key 'bar'", resourcesMap.containsKey("bar"));



Mime
View raw message