View Javadoc
1   package org.apache.maven.jxr;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import junit.framework.TestCase;
23  
24  import java.io.File;
25  import java.util.Collections;
26  
27  /**
28   * Test include/exclude patterns.
29   *
30   * @author <a href="mailto:dennisl@apache.org">Dennis Lundberg</a>
31   * @version $Id: IncludeExcludeTest.java 637378 2008-03-15 09:47:19Z bentmann $
32   */
33  public class IncludeExcludeTest extends TestCase
34  {
35      private JXR jxr;
36  
37      protected void setUp()
38          throws Exception
39      {
40          super.setUp();
41          jxr = new JXR();
42          jxr.setDest( System.getProperty( "basedir" ) + "/target" );
43          jxr.setInputEncoding( "ISO-8859-1" );
44          jxr.setOutputEncoding( "ISO-8859-1" );
45          jxr.setJavadocLinkDir( "" );
46          jxr.setLog( new DummyLog() );
47      }
48  
49      public void testIncludeExclude()
50          throws Exception
51      {
52          String[] excludes = {"**/exclude/ExcludedClass.java"};
53          jxr.setExcludes( excludes );
54          String[] includes = {"**/exclude/*.java", "**/include/IncludedClass.java"};
55          jxr.setIncludes( includes );
56          jxr.xref( Collections.singletonList( System.getProperty( "basedir" ) + "/src/test/resources" ), "templates",
57                    "title", "title", "copyright" );
58          File excludedFile = new File( System.getProperty( "basedir" ) + "/target/exclude/ExcludedClass.html" );
59          assertFalse( excludedFile.exists() );
60          File includedFile = new File( System.getProperty( "basedir" ) + "/target/include/IncludedClass.html" );
61          assertTrue( includedFile.exists() );
62          File notIncludedFile = new File( System.getProperty( "basedir" ) + "/target/include/NotIncludedClass.html" );
63          assertFalse( notIncludedFile.exists() );
64      }
65  }