1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.rat.analysis.license;
20
21 import junit.framework.TestCase;
22
23 import org.apache.rat.api.Document;
24 import org.apache.rat.document.MockLocation;
25 import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
26
27 public class W3CLicenseTest extends TestCase {
28
29 public static final String COPYRIGHT_URL
30 = "http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231";
31
32 public static final String COPYRIGHT_URL_COMMENTED
33 = "# http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 #";
34
35 public static final String COPYRIGHT_URL_XML
36 = "<!-- http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -->";
37
38 W3CLicense license;
39 MockClaimReporter reporter;
40
41 protected void setUp() throws Exception {
42 super.setUp();
43 license = new W3CLicense();
44 reporter = new MockClaimReporter();
45 }
46
47 protected void tearDown() throws Exception {
48 super.tearDown();
49 }
50
51 public void testMatch() throws Exception {
52 final Document subject = new MockLocation("subject");
53 assertTrue("Expected matcher to return license", license.match(subject, COPYRIGHT_URL));
54 assertTrue("Expected matcher to return license", license.match(subject, COPYRIGHT_URL_COMMENTED));
55 assertTrue("Expected matcher to return license", license.match(subject, COPYRIGHT_URL_XML));
56 assertFalse("Return null if the license isn't matched", license.match(subject, "Bogus"));
57 }
58 }