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 familyId = "AL";
32      public static final String licenseId = "AL2.0";
33      public static final String name = "Apache License 2.0";
34      private static final String[][] targets = {
35              { "short", "Licensed under the Apache License, Version 2.0 (the \"License\")" },
36              { "short2",
37                      "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0." },
38              { "http", "http://www.apache.org/licenses/LICENSE-2.0" },
39              { "https", "https://www.apache.org/licenses/LICENSE-2.0" },
40              { "html", "http://www.apache.org/licenses/LICENSE-2.0.html" },
41              { "htmls", "https://www.apache.org/licenses/LICENSE-2.0.html" },
42              { "txt", "http://www.apache.org/licenses/LICENSE-2.0.txt" },
43              { "txts", "https://www.apache.org/licenses/LICENSE-2.0.txt" },
44              { "fullTxt",
45                      "Licensed under the Apache License, Version 2.0 (the \"License\")\nyou may not use this file except "
46                              + "in compliance with the License.\nYou may obtain a copy of the License at\n"
47                              + "http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable "
48                              + "law or agreed to in writing, software\ndistributed under the License is "
49                              + "distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either "
50                              + "express or implied.\nSee the License for the specific language governing permissions and\n"
51                              + "limitations under the License.\n" },
52              { "spdx-tab", "SPDX-License-Identifier:\tApache-2.0" },
53              { "spdx-space", "SPDX-License-Identifier: Apache-2.0" },
54              { "long text",
55                      "/*\n" + " *  Licensed under the Apache License, Version 2.0 (the \"License\");\n"
56                              + " *  you may not use this file except in compliance with the License.\n" + " *\n"
57                              + " *  You may obtain a copy of the License at\n"
58                              + " *       http://www.apache.org/licenses/LICENSE-2.0\n" + " *\n"
59                              + " *  Unless required by applicable law or agreed to in writing, software\n"
60                              + " *  distributed under the License is distributed on an \"AS IS\" BASIS,\n"
61                              + " *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
62                              + " *  See the License for the specific language governing permissions and\n"
63                              + " *  limitations under the License.\n" + " */\n" }
64  
65      };
66  
67      public static Stream<Arguments> parameterProvider() {
68          return Stream.of(Arguments.of(licenseId, familyId, name, null, targets));
69      }
70  }