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:26:08 GMT
jstrachan    2002/10/12 10:26:08

  Modified:    discovery/src/test/org/apache/commons/discovery/test
                        TestAll.java
  Log:
  Added another test case using the DiscoverClass mechanism directly
  
  Revision  Changes    Path
  1.5       +16 -4     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestAll.java	12 Oct 2002 17:09:47 -0000	1.4
  +++ TestAll.java	12 Oct 2002 17:26:08 -0000	1.5
  @@ -72,6 +72,7 @@
   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.DiscoverClass;
   import org.apache.commons.discovery.tools.DiscoverSingleton;
   import org.apache.commons.discovery.tools.ManagedProperties;
   import org.apache.commons.discovery.tools.PropertiesHolder;
  @@ -262,16 +263,16 @@
   
       public void testLowLevelFind() {
           ClassLoaders loaders = ClassLoaders.getAppLoaders(TestInterface2.class, getClass(),
false);
  -        String name = TestInterface2.class.getName();
  +        String name = "org.apache.commons.discovery.test.TestImpl2_1";
           
           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
  +                Class implClass = resource.loadClass();
  +                if ( implClass != null ) {
  +                    assertEquals("org.apache.commons.discovery.test.TestImpl2_1", implClass.getName());
                       return;
                   }
               }
  @@ -280,6 +281,17 @@
               }
           }
           fail("failed to load resource: " + name);
  +        
  +    }
  +
  +    public void testViaDiscoverClass() {
  +        ClassLoaders loaders = ClassLoaders.getAppLoaders(TestInterface2.class, getClass(),
false);
  +        
  +        DiscoverClass discover = new DiscoverClass(loaders);
  +        Class implClass = discover.find(TestInterface2.class);
  +        
  +        assertTrue("Failed to find an implementation class", implClass != null);
  +        assertEquals("org.apache.commons.discovery.test.TestImpl2_1", implClass.getName());
           
       }
       
  
  
  

--
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