You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by se...@apache.org on 2013/05/19 04:25:25 UTC
svn commit: r1484210 [1/3] - in /creadur/rat/trunk/apache-rat-core/src/test:
java/org/apache/rat/analysis/license/ resources/oasis/ resources/oasis/bad/
resources/oasis/good/
Author: sebb
Date: Sun May 19 02:25:25 2013
New Revision: 1484210
URL: http://svn.apache.org/r1484210
Log:
Add some test cases for OASIS licenses
Added:
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java (with props)
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt (with props)
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad2.txt (with props)
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/good/
creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/good/oasisgood1.txt (with props)
Modified:
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java
Added: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java?rev=1484210&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java (added)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java Sun May 19 02:25:25 2013
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY 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.junit.Assert.assertEquals;
+
+import java.io.BufferedReader;
+import java.io.File;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.rat.analysis.IHeaderMatcher;
+import org.apache.rat.api.Document;
+import org.apache.rat.document.MockLocation;
+import org.apache.rat.test.utils.Resources;
+
+class DirectoryScanner {
+
+ @SuppressWarnings("boxing")
+ /**
+ * Get list of files in a directory, and scan for license matches
+ * @param directory the directory containing the files
+ * @param matcher the license matcher
+ * @param expected the expected result of the each scan
+ * @throws Exception
+ */
+ public static void testFilesInDir(String directory, IHeaderMatcher matcher, boolean expected) throws Exception {
+ for(File f : Resources.getResourceFiles(directory)) {
+ final Document subject = new MockLocation(f.toString());
+ BufferedReader br = null;
+ try {
+ boolean result = false;
+ br = Resources.getBufferedReader(f);
+ String line;
+ while(!result && (line = br.readLine()) != null) {
+ result = matcher.match(subject, line);
+ }
+ assertEquals(f.toString(), expected, result);
+ } finally {
+ matcher.reset();
+ IOUtils.closeQuietly(br);
+ }
+ }
+ }
+
+}
Propchange: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/DirectoryScanner.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java?rev=1484210&r1=1484209&r2=1484210&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/analysis/license/OASISLicenseTest.java Sun May 19 02:25:25 2013
@@ -18,6 +18,7 @@
*/
package org.apache.rat.analysis.license;
+import org.apache.commons.io.IOUtils;
import org.apache.rat.api.Document;
import org.apache.rat.document.MockLocation;
import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
@@ -26,6 +27,7 @@ import org.junit.Before;
import org.junit.Test;
import java.io.BufferedReader;
+import java.io.File;
import java.io.StringReader;
import static org.junit.Assert.assertFalse;
@@ -92,5 +94,15 @@ public class OASISLicenseTest {
assertFalse("OASIS license should not be matched", result);
license.reset();
}
+
+ @Test
+ public void goodFiles() throws Exception {
+ DirectoryScanner.testFilesInDir("oasis/good", license, true);
+ }
+
+ @Test
+ public void baddFiles() throws Exception {
+ DirectoryScanner.testFilesInDir("oasis/bad", license, false);
+ }
}
Added: creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt?rev=1484210&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt (added)
+++ creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt Sun May 19 02:25:25 2013
@@ -0,0 +1,6 @@
+CopyrightOASIS Open
+
+This document and translations of it may be copied and furnished to
+others, and derivative works that comment on or otherwise explain it
+or assist in its implementation may be prepared, copied, published,
+and distributed
\ No newline at end of file
Propchange: creadur/rat/trunk/apache-rat-core/src/test/resources/oasis/bad/oasisbad1.txt
------------------------------------------------------------------------------
svn:eol-style = native