1   package org.apache.maven.util;
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  
23  import junit.framework.Test;
24  import junit.framework.TestCase;
25  import junit.framework.TestSuite;
26  
27  /**
28   * Unit test for <code>MavenTool</code>.
29   *
30   * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
31   * @version $Id: MavenToolTest.java 517014 2007-03-11 21:15:50Z ltheussl $
32   */
33  public class MavenToolTest
34      extends TestCase
35  {
36      /** fragment to be resolved */
37      private static final String NEEDLE = "org/apache/maven/util/MavenTool.java";
38  
39      /** where to search for the fragment */
40      private static final String[] HAYSTACK = { "docs", "src" + File.separator + "java", "xdocs" };
41  
42      /**
43       * Create the test with the given name
44       *
45       * @param testName the name of the test
46       */
47      public MavenToolTest( String testName )
48      {
49          super( testName );
50      }
51  
52      /**
53       * @return the suite of tests being tested
54       */
55      public static Test suite()
56      {
57          return new TestSuite( MavenToolTest.class );
58      }
59  
60      /**
61       * Tests {@link MavenTool.resolvePathFragment(String, String, String[])}.
62       */
63      public void testResolvePathFragment()
64      {
65          MavenTool tool = new MavenTool();
66  
67          /*
68           * The basedir for the project is passed into the system properties
69           * by the junit task.
70           */
71          String basedir = System.getProperty( "basedir" );
72          assertNotNull( "The system property basedir was not defined.", basedir );
73  
74          String path = tool.resolvePathFragment( basedir, NEEDLE, HAYSTACK );
75          assertEquals( "Couldn't resolve fragment using a base directory of " + basedir, HAYSTACK[1], path );
76      }
77  }