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 junit.framework.TestCase;
22  import org.jdom.JDOMException;
23  
24  import java.io.File;
25  import java.io.IOException;
26  import java.util.Map;
27  
28  /**
29   * @author Dion Gillard
30   */
31  public class PluginToTagsTest extends TestCase
32  {
33      private static final String basedir = System.getProperty("basedir");
34  
35      /**
36       * test the right taglibs are found 
37       * @throws JDOMException
38       * @throws IOException
39       */
40      public void testTaglibs() throws JDOMException, IOException
41      {
42          PluginToTags instance = new PluginToTags();
43          testBasedir();
44          instance.setPluginScript(basedir + "/src/test/plugin.jelly");
45          assertEquals("wrong number of taglibs", 1, instance.getTaglibs().size());
46          Map taglib = (Map)instance.getTaglibs().get(0);
47          assertEquals("bad taglib uri", "doc", taglib.get("uri"));
48      }
49  
50      /**
51       * test that basedir is passed in
52       */
53      public void testBasedir()
54      {
55          assertNotNull("no basedir", basedir);
56      }
57  
58      /**
59       * test the taglibs are written as a file
60       * @throws JDOMException
61       * @throws IOException
62       */
63      public void testTransform() throws JDOMException, IOException
64      {
65          PluginToTags instance = new PluginToTags();
66          testBasedir();
67          instance.setPluginScript(basedir + "/src/test/plugin.jelly");
68          instance.setXdoc(basedir + "/target/tags.xml");
69          instance.transform();
70          File outputFile = new File(instance.getXdoc());
71          assertTrue("xdoc not generated", outputFile.exists());
72      }
73  
74  
75  }