Author: rdonkin
Date: Fri Dec  6 19:32:08 2013
New Revision: 1548688

URL: http://svn.apache.org/r1548688
Log:
Refactor license to use LicenseFamily constructor

Modified:
    
creadur/rat/branches/gsoc/apache-rat-api/src/main/java/org/apache/rat/api/domain/RatLicenseFamily.java
    
creadur/rat/branches/gsoc/apache-rat-api/src/test/java/org/apache/rat/api/domain/RatLicenseFamilyTest.java
    
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
    
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/MetaData.java
    
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java

Modified: 
creadur/rat/branches/gsoc/apache-rat-api/src/main/java/org/apache/rat/api/domain/RatLicenseFamily.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-api/src/main/java/org/apache/rat/api/domain/RatLicenseFamily.java?rev=1548688&r1=1548687&r2=1548688&view=diff
==============================================================================
--- 
creadur/rat/branches/gsoc/apache-rat-api/src/main/java/org/apache/rat/api/domain/RatLicenseFamily.java
 (original)
+++ 
creadur/rat/branches/gsoc/apache-rat-api/src/main/java/org/apache/rat/api/domain/RatLicenseFamily.java
 Fri Dec  6 19:32:08 2013
@@ -25,7 +25,10 @@ import static org.apache.rat.api.domain.
  */
 public enum RatLicenseFamily {
 
-    W3C("W3C Software Copyright", "W3C  ", "");
+    W3C(
+            "W3C Software Copyright",
+            "W3C  ",
+            "Note that W3C requires a NOTICE. All modifications require notes. 
See http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.";);
 
     /** @see LicenseFamily#getName() */
     private final String name;

Modified: 
creadur/rat/branches/gsoc/apache-rat-api/src/test/java/org/apache/rat/api/domain/RatLicenseFamilyTest.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-api/src/test/java/org/apache/rat/api/domain/RatLicenseFamilyTest.java?rev=1548688&r1=1548687&r2=1548688&view=diff
==============================================================================
--- 
creadur/rat/branches/gsoc/apache-rat-api/src/test/java/org/apache/rat/api/domain/RatLicenseFamilyTest.java
 (original)
+++ 
creadur/rat/branches/gsoc/apache-rat-api/src/test/java/org/apache/rat/api/domain/RatLicenseFamilyTest.java
 Fri Dec  6 19:32:08 2013
@@ -38,6 +38,8 @@ public class RatLicenseFamilyTest {
 
     @Test
     public void testW3CLicenseFamilyNotes() {
-        assertThat(W3C.getNotes(), is(""));
+        assertThat(
+                W3C.getNotes(),
+                is("Note that W3C requires a NOTICE. All modifications require 
notes. See 
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.";));
     }
 }

Modified: 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java?rev=1548688&r1=1548687&r2=1548688&view=diff
==============================================================================
--- 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
 (original)
+++ 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/license/W3CLicense.java
 Fri Dec  6 19:32:08 2013
@@ -15,22 +15,18 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.analysis.license;
 
-import org.apache.rat.api.MetaData;
+import static org.apache.rat.api.domain.RatLicenseFamily.W3C;
 
 public class W3CLicense extends SimplePatternBasedLicense {
 
-    private static final String NOTES 
-        = "Note that W3C requires a NOTICE. All modifications require notes. 
See http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.";;
-    private static final String COPYRIGHT_URL 
-    = "http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231";;
-    
+    private static final String COPYRIGHT_URL =
+            
"http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231";;
+
     public W3CLicense() {
-        super(MetaData.RAT_LICENSE_FAMILY_CATEGORY_DATUM_W3C, 
-                MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_W3C_SOFTWARE_COPYRIGHT, 
 NOTES,
-                new String[]{COPYRIGHT_URL});
-        
+        super(W3C.licenseFamily(), new String[] { COPYRIGHT_URL });
+
     }
 }

Modified: 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/MetaData.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/MetaData.java?rev=1548688&r1=1548687&r2=1548688&view=diff
==============================================================================
--- 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/MetaData.java
 (original)
+++ 
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/MetaData.java
 Fri Dec  6 19:32:08 2013
@@ -26,7 +26,6 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
-
 /**
  * Data about the subject.
  */
@@ -92,9 +91,8 @@ public class MetaData {
     public static final Datum RAT_LICENSE_FAMILY_CATEGORY_DATUM_W3CD = new 
Datum(
             RAT_URL_LICENSE_FAMILY_CATEGORY,
             RAT_LICENSE_FAMILY_CATEGORY_VALUE_W3CD);
-    public static final Datum RAT_LICENSE_FAMILY_CATEGORY_DATUM_W3C = new 
Datum(
-            RAT_URL_LICENSE_FAMILY_CATEGORY,
-            W3C.getCategory());
+    public static final Datum RAT_LICENSE_FAMILY_CATEGORY_DATUM_W3C =
+            new Datum(RAT_URL_LICENSE_FAMILY_CATEGORY, W3C.getCategory());
     public static final Datum RAT_LICENSE_FAMILY_CATEGORY_DATUM_DOJO = new 
Datum(
             RAT_URL_LICENSE_FAMILY_CATEGORY,
             RAT_LICENSE_FAMILY_CATEGORY_VALUE_DOJO);
@@ -131,9 +129,8 @@ public class MetaData {
     public static final String RAT_LICENSE_FAMILY_NAME_VALUE_CDDL1 = "COMMON 
DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0";
     public static final String 
RAT_LICENSE_FAMILY_NAME_VALUE_ACADEMIC_FREE_LICENSE_VERSION_2_1 = "Academic 
Free License, Version 2.1";
     public static final String RAT_LICENSE_FAMILY_NAME_VALUE_UNKNOWN = "?????";
-    public static final Datum 
RAT_LICENSE_FAMILY_NAME_DATUM_W3C_SOFTWARE_COPYRIGHT = new Datum(
-            RAT_URL_LICENSE_FAMILY_NAME,
-            W3C.getName());
+    public static final Datum 
RAT_LICENSE_FAMILY_NAME_DATUM_W3C_SOFTWARE_COPYRIGHT =
+            new Datum(RAT_URL_LICENSE_FAMILY_NAME, W3C.getName());
     public static final Datum 
RAT_LICENSE_FAMILY_NAME_DATUM_W3C_DOCUMENT_COPYRIGHT = new Datum(
             RAT_URL_LICENSE_FAMILY_NAME,
             RAT_LICENSE_FAMILY_NAME_VALUE_W3C_DOCUMENT_COPYRIGHT);

Modified: 
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
URL: 
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java?rev=1548688&r1=1548687&r2=1548688&view=diff
==============================================================================
--- 
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
 (original)
+++ 
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
 Fri Dec  6 19:32:08 2013
@@ -15,45 +15,68 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.analysis.license;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
 import org.apache.rat.api.Document;
 import org.apache.rat.document.MockLocation;
 import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 public class W3CLicenseTest {
 
-    public static final String COPYRIGHT_URL 
-    = "http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231";;
-    
-    public static final String COPYRIGHT_URL_COMMENTED
-    = "# http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 
#";
-    
-    public static final String COPYRIGHT_URL_XML
-    = "<!-- 
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -->";
-    
+    public static final String COPYRIGHT_URL =
+            
"http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231";;
+
+    public static final String COPYRIGHT_URL_COMMENTED =
+            "# 
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 #";
+
+    public static final String COPYRIGHT_URL_XML =
+            "<!-- 
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 -->";
+
     W3CLicense license;
     MockClaimReporter reporter;
 
     @Before
     public void setUp() throws Exception {
-        license = new W3CLicense();
-        reporter = new MockClaimReporter();
+        this.license = new W3CLicense();
+        this.reporter = new MockClaimReporter();
     }
 
     @Test
     public void match() throws Exception {
         final Document subject = new MockLocation("subject");
-        assertTrue("Expected matcher to return license", 
license.match(subject, COPYRIGHT_URL));
-        assertTrue("Expected matcher to return license", 
license.match(subject, COPYRIGHT_URL_COMMENTED));
-        assertTrue("Expected matcher to return license", 
license.match(subject, COPYRIGHT_URL_XML));
-        assertFalse("Return null if the license isn't matched", 
license.match(subject, "Bogus"));
+        assertTrue("Expected matcher to return license",
+                this.license.match(subject, COPYRIGHT_URL));
+        assertTrue("Expected matcher to return license",
+                this.license.match(subject, COPYRIGHT_URL_COMMENTED));
+        assertTrue("Expected matcher to return license",
+                this.license.match(subject, COPYRIGHT_URL_XML));
+        assertFalse("Return null if the license isn't matched",
+                this.license.match(subject, "Bogus"));
     }
 
+    @Test
+    public void testNotes() {
+        assertThat(
+                this.license.getNotes(),
+                is("Note that W3C requires a NOTICE. All modifications require 
notes. See 
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.";));
+    }
+
+    @Test
+    public void testCategory() {
+        assertThat(this.license.getLicenseFamilyCategory(), is("W3C  "));
+    }
+
+    @Test
+    public void testName() {
+        assertThat(this.license.getLicenseFamilyName(),
+                is("W3C Software Copyright"));
+    }
 }


Reply via email to