1   package org.apache.maven.doxia.linkcheck.validation;
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  /**
25   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
26   * @version $Id: LinkValidatorManagerTest.java 1004651 2010-10-05 14:09:10Z ltheussl $
27   */
28  public class LinkValidatorManagerTest
29      extends TestCase
30  {
31  
32      public void testMatchPattern() throws Exception
33      {
34          String link = "http://maven.apache.org";
35          String pattern = "http://maven.apache.org";
36          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
37  
38          link = "http://maven.apache.org/";
39          pattern = "http://maven.apache.org";
40          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
41  
42          link = "http://maven.apache.org";
43          pattern = "http://maven.apache.org/";
44          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
45  
46          link = "http://maven.apache.org/test.html";
47          pattern = "http://maven.apache.org/";
48          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
49  
50          link = "http://maven.apache.org";
51          pattern = "http://maven.apache.org/*";
52          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
53          assertTrue( LinkValidatorManager.matchPattern( link + "/", pattern ) );
54  
55          link = "http://maven.apache.org/test/test.html";
56          pattern = "http://maven.apache.org/**/*";
57          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
58  
59          link = "http://maven.apache.org/test/test.html";
60          pattern = "http://maven.apache.org/*.html";
61          assertTrue( LinkValidatorManager.matchPattern( link, pattern ) );
62  
63          link = "http://maven.apache.org/test/test.html";
64          pattern = "http://maven.apache.org/**/*.jsp";
65          assertFalse( LinkValidatorManager.matchPattern( link, pattern ) );
66  
67          link = "http://java.sun.com/";
68          pattern = "../../exclude/*";
69          assertFalse( LinkValidatorManager.matchPattern( link, pattern ) );
70      }
71  }