1   package org.apache.maven.plugin;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import java.io.File;
22  import java.io.FileInputStream;
23  import java.io.FileNotFoundException;
24  import java.io.IOException;
25  
26  import junit.framework.TestCase;
27  
28  import org.apache.maven.MavenException;
29  
30  /**
31   * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
32   * @version $Id: PluginCacheManagerTest.java,v 1.1 2002/12/31 07:10:06 jvanzyl
33   *      Exp $
34   */
35  public class PluginCacheManagerTest
36      extends TestCase
37  {
38      private static String PLUGIN_SCRIPT = System.getProperty( "basedir" )
39          + "/src/test/java/org/apache/maven/plugin/plugin.jelly";
40  
41      /**
42       * Constructor.
43       *
44       * @param name Name of the test.
45       */
46      public PluginCacheManagerTest( String name )
47      {
48          super( name );
49      }
50  
51      /**
52       * Test the plugin cache builder.
53       */
54      public void testPluginGraphBuilder()
55          throws FileNotFoundException, IOException, MavenException
56      {
57          PluginCacheManager pgb = new PluginCacheManager();
58          JellyScriptHousing housing = new JellyScriptHousing( new File( PLUGIN_SCRIPT ).getParentFile(), null );
59          FileInputStream fis = new FileInputStream( new File( PLUGIN_SCRIPT ) );
60          housing.parse( pgb, PLUGIN_SCRIPT, fis );
61          fis.close();
62  
63          assertEquals( "Generate docs in APT format>xdoc:generate-from-pom", pgb.getGoalCache()
64              .getProperty( "apt:generate" ) );
65  
66          assertEquals( "plugin", pgb.getPluginCache().getProperty( "apt:generate" ) );
67  
68          assertEquals( "plugin", pgb.getDynaTagLibCache().getProperty( "aptdoc" ) );
69  
70          assertEquals( "plugin", pgb.getCallbackCache().getProperty( "xdoc:transform.pre" ) );
71  
72          assertEquals( "plugin", pgb.getCallbackCache().getProperty( "foo.post" ) );
73      }
74  }