commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons/discovery/src/test/org/apache/commons/discovery/test TestAll.java
Date Sat, 12 Oct 2002 17:09:47 GMT
jstrachan    2002/10/12 10:09:47

  Modified:    discovery/src/test/org/apache/commons/discovery/test
                        TestAll.java
  Log:
  Added another test case using the lower level API
  
  Revision  Changes    Path
  1.4       +28 -0     jakarta-commons/discovery/src/test/org/apache/commons/discovery/test/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/discovery/src/test/org/apache/commons/discovery/test/TestAll.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestAll.java	30 Aug 2002 00:15:20 -0000	1.3
  +++ TestAll.java	12 Oct 2002 17:09:47 -0000	1.4
  @@ -68,11 +68,16 @@
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  +
  +import org.apache.commons.discovery.ResourceClass;
  +import org.apache.commons.discovery.ResourceClassIterator;
   import org.apache.commons.discovery.tools.DefaultClassHolder;
   import org.apache.commons.discovery.tools.DiscoverSingleton;
   import org.apache.commons.discovery.tools.ManagedProperties;
   import org.apache.commons.discovery.tools.PropertiesHolder;
   import org.apache.commons.discovery.tools.SPInterface;
  +import org.apache.commons.discovery.resource.ClassLoaders;
  +import org.apache.commons.discovery.resource.classes.DiscoverClasses;
   
   
   /**
  @@ -255,6 +260,29 @@
           }
       }
   
  +    public void testLowLevelFind() {
  +        ClassLoaders loaders = ClassLoaders.getAppLoaders(TestInterface2.class, getClass(),
false);
  +        String name = TestInterface2.class.getName();
  +        
  +        DiscoverClasses discovery = new DiscoverClasses(loaders);
  +        ResourceClassIterator iter = discovery.findResourceClasses(name);
  +        while (iter.hasNext()) {
  +            ResourceClass resource = iter.nextResourceClass();
  +            try {                
  +                Class typeClass = resource.loadClass();
  +                if ( typeClass != null ) {
  +                    // worked
  +                    return;
  +                }
  +            }
  +            catch (Exception e) {
  +                fail("Could not load service: " + resource );
  +            }
  +        }
  +        fail("failed to load resource: " + name);
  +        
  +    }
  +    
       /**
        * This allows the tests to run as a standalone application.
        */
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message