View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   */
19  package org.apache.rat.analysis.license;
20  
21  import java.util.stream.Stream;
22  
23  import org.junit.jupiter.params.provider.Arguments;
24  
25  /**
26   * Apache Software License detection tests.
27   *
28   */
29  public class ApacheSoftwareLicenseTest extends AbstractLicenseTest {
30  
31      public static final String id = "AL";
32      public static final String name = "Apache License Version 2.0";
33      private static String[][] targets = {
34              { "short", "Licensed under the Apache License, Version 2.0 (the \"License\")" },
35              { "short2",
36                      "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0." },
37              { "http", "http://www.apache.org/licenses/LICENSE-2.0" },
38              { "https", "https://www.apache.org/licenses/LICENSE-2.0" },
39              { "html", "http://www.apache.org/licenses/LICENSE-2.0.html" },
40              { "htmls", "https://www.apache.org/licenses/LICENSE-2.0.html" },
41              { "txt", "http://www.apache.org/licenses/LICENSE-2.0.txt" },
42              { "txts", "https://www.apache.org/licenses/LICENSE-2.0.txt" },
43              { "fullTxt",
44                      "Licensed under the Apache License, Version 2.0 (the \"License\")\nyou may not use this file except "
45                              + "in compliance with the License.\nYou may obtain a copy of the License at\n"
46                              + "http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable "
47                              + "law or agreed to in writing, software\ndistributed under the License is "
48                              + "distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either "
49                              + "express or implied.\nSee the License for the specific language governing permissions and\n"
50                              + "limitations under the License.\n" },
51              { "spdx-tab", "SPDX-License-Identifier:\tApache-2.0" },
52              { "spdx-space", "SPDX-License-Identifier: Apache-2.0" },
53              { "long text",
54                      "/*\n" + " *  Licensed under the Apache License, Version 2.0 (the \"License\");\n"
55                              + " *  you may not use this file except in compliance with the License.\n" + " *\n"
56                              + " *  You may obtain a copy of the License at\n"
57                              + " *       http://www.apache.org/licenses/LICENSE-2.0\n" + " *\n"
58                              + " *  Unless required by applicable law or agreed to in writing, software\n"
59                              + " *  distributed under the License is distributed on an \"AS IS\" BASIS,\n"
60                              + " *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
61                              + " *  See the License for the specific language governing permissions and\n"
62                              + " *  limitations under the License.\n" + " */\n" }
63  
64      };
65  
66      public static Stream<Arguments> parameterProvider() {
67          return Stream.of(Arguments.of(id, id, name, null, targets));
68      }
69  
70  //
71  //    @Test(timeout = 2000) // may need to be adjusted if many more files are added
72  //    public void goodFiles() throws Exception {
73  //        IHeaderMatcher matcher = new MultiplexLicense("goodFiles", AbstractMatcherTest.extractCategory(category));
74  //        DirectoryScanner.testFilesInDir("appliedAL20/good", matcher, true);
75  //    }
76  //
77  //    @Test(timeout = 2000) // may need to be adjusted if many more files are added
78  //    public void badFiles() throws Exception {
79  //        IHeaderMatcher matcher = new MultiplexLicense("badFiles", AbstractMatcherTest.extractCategory(category));
80  //        DirectoryScanner.testFilesInDir("appliedAL20/bad", matcher, false);
81  //    }
82  
83  }