dion        2002/06/24 06:48:27

  Modified:    src/test/org/apache/maven/plugin PluginManagerTest.java
  Log:
  Tests for installed plugins
  
  Revision  Changes    Path
  1.5       +39 -5     
jakarta-turbine-maven/src/test/org/apache/maven/plugin/PluginManagerTest.java
  
  Index: PluginManagerTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/test/org/apache/maven/plugin/PluginManagerTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- PluginManagerTest.java    24 Jun 2002 00:43:31 -0000      1.4
  +++ PluginManagerTest.java    24 Jun 2002 13:48:27 -0000      1.5
  @@ -76,6 +76,8 @@
       
       /** the instance being test */
       private PluginManager instance;
  +    /** test directory for plugins */
  +    private String testPluginDir;
       
       /**
        * Creates a new instance of the test case
  @@ -95,6 +97,13 @@
       public void setUp() throws Exception
       {
           instance = new PluginManager();
  +        String baseDir = System.getProperty("basedir");
  +        assertNotNull("The system property basedir was not defined.", baseDir);
  +        String fs = System.getProperty("file.separator");
  +        assertNotNull("The system property file.separator was not defined.", 
  +            fs);
  +        testPluginDir = baseDir + fs + "src" + fs + "test-build" + fs + 
  +            "plugins";
       }
   
       /**
  @@ -138,11 +147,36 @@
       
       /**
        * test the installed plugins
  +     *
  +     * @throws Exception when errors occur
        */
  -    public void testInstalledPlugins()
  +    public void testInstalledPlugins() throws Exception
       {
  -        // need flesh here, as this is just a stub
  -        assertNotNull("installed plugins can't be null", 
  -            instance.getInstalledPlugins());
  +        try
  +        {
  +            instance.getInstalledPlugins();
  +            fail("no plugin directory should have caused a NPE");
  +        }
  +        catch (NullPointerException npe)
  +        {
  +            if (npe.getMessage().indexOf("plugin directory") == -1)
  +            {
  +                fail("null pointer for wrong reason");
  +            }
  +        }
  +
  +        instance.setPluginDirectory(testPluginDir);
  +        List plugins = instance.getInstalledPlugins();
  +        assertNotNull("installed plugins can't be null", plugins);
  +        assertEquals("wrong number of plugins found", 3, plugins.size());
  +        // the following tests rely on BaseObject's equals method being based
  +        // on id
  +        Plugin tester = new Plugin();
  +        tester.setId("maven-clover");
  +        assertTrue("Clover plugin not found", plugins.contains(tester));
  +        tester.setId("maven-core");
  +        assertTrue("Core plugin not found", plugins.contains(tester));
  +        tester.setId("maven-j2ee");
  +        assertTrue("J2EE plugin not found", plugins.contains(tester));
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to