You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2015/05/25 00:05:01 UTC
svn commit: r1681534 [2/2] - in /creadur/rat/trunk: ./
apache-rat-core/src/main/java/org/apache/rat/
apache-rat-core/src/main/java/org/apache/rat/analysis/license/
apache-rat-core/src/main/java/org/apache/rat/annotation/
apache-rat-core/src/test/java/o...
Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java Sun May 24 22:05:01 2015
@@ -15,7 +15,7 @@
* KIND, either express or implied. See the License for the *
* specific language governing permissions and limitations *
* under the License. *
- */
+ */
package org.apache.rat.annotation;
import org.apache.rat.test.utils.Resources;
@@ -33,9 +33,16 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertFalse;
public class TestLicenceAppender {
- private static final String FIRST_LICENSE_LINE = " Licensed to the Apache Software Foundation (ASF) under one";
- /** Used to ensure that temporary files have unq */
+ // TODO pottlinger refactor test to use:
+ //@Rule
+ //TemporaryFolder baseTempFolder = new TemporaryFolder();
+
+ private static final String FIRST_LICENSE_LINE = " Licensed to the Apache Software Foundation (ASF) under one";
+
+ /**
+ * Used to ensure that temporary files have unq
+ */
private Random random = new Random();
private interface FileCreator {
@@ -48,13 +55,13 @@ public class TestLicenceAppender {
private static String qualify(String fileName) {
return new File(new File(System.getProperty("java.io.tmpdir")),
- fileName)
- .getAbsolutePath();
+ fileName)
+ .getAbsolutePath();
}
private static void createTestFile(String fileName,
FileCreator creator)
- throws IOException {
+ throws IOException {
FileWriter w = null;
try {
creator.createFile(w = new FileWriter(fileName));
@@ -74,13 +81,13 @@ public class TestLicenceAppender {
private static void commonTestTemplate(String relativeName,
FileCreator creator,
NewFileReader reader)
- throws IOException {
+ throws IOException {
String name = qualify(relativeName);
try {
createTestFile(name, creator);
ApacheV2LicenceAppender appender =
- new ApacheV2LicenceAppender();
+ new ApacheV2LicenceAppender();
appender.append(new File(name));
BufferedReader r = null;
@@ -104,11 +111,11 @@ public class TestLicenceAppender {
public void readFile(BufferedReader r) throws IOException {
String line = r.readLine();
assertEquals("First line is incorrect",
- firstLine, line);
+ firstLine, line);
if (secondLine != null) {
line = r.readLine();
assertEquals("Second line is incorrect",
- secondLine, line);
+ secondLine, line);
}
}
};
@@ -121,43 +128,43 @@ public class TestLicenceAppender {
public void readFile(BufferedReader r) throws IOException {
String line = r.readLine();
assertEquals("First line is incorrect",
- firstLine, line);
+ firstLine, line);
if (secondLine != null) {
line = r.readLine();
assertEquals("Second line is incorrect",
- secondLine, line);
+ secondLine, line);
}
if (thirdLine != null) {
line = r.readLine();
assertEquals("Third line is incorrect",
- thirdLine, line);
+ thirdLine, line);
}
}
};
}
@Test
- public void addLicenceToUnknownFile() throws IOException {
+ public void addLicenseToUnknownFile() throws IOException {
String filename = qualify("tmp" + random.nextLong()
- + ".unknownType");
+ + ".unknownType");
File file = null;
File newFile = null;
try {
createTestFile(filename, new FileCreator() {
- public void createFile(Writer writer)
+ public void createFile(Writer writer)
throws IOException {
- writer.write("Unknown file type\n");
- }
- });
+ writer.write("Unknown file type\n");
+ }
+ });
file = new File(filename);
ApacheV2LicenceAppender appender =
- new ApacheV2LicenceAppender();
+ new ApacheV2LicenceAppender();
appender.append(file);
newFile = new File(filename + ".new");
assertFalse("No new file should have been written",
- newFile.exists());
+ newFile.exists());
} finally {
tryToDelete(file);
tryToDelete(newFile);
@@ -165,199 +172,199 @@ public class TestLicenceAppender {
}
@Test
- public void addLicenceToJava() throws IOException {
+ public void addLicenseToJava() throws IOException {
String filename = "tmp.java";
final String firstLine = "package foo;";
final String secondLine = "";
final String thirdLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("\n");
- writer.write("public class test {\n");
- writer.write("}\n");
- }
- },
- checkLines(firstLine, secondLine, thirdLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("\n");
+ writer.write("public class test {\n");
+ writer.write("}\n");
+ }
+ },
+ checkLines(firstLine, secondLine, thirdLine));
}
@Test
- public void addLicenceToJavaWithoutPackage() throws IOException {
+ public void addLicenseToJavaWithoutPackage() throws IOException {
String filename = "tmp.java";
String commentLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("public class test {\n");
- writer.write("}\n");
- }
- },
- checkLines(commentLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("public class test {\n");
+ writer.write("}\n");
+ }
+ },
+ checkLines(commentLine, null));
}
@Test
- public void addLicenceToXML() throws IOException {
+ public void addLicenseToXML() throws IOException {
String filename = "tmp.xml";
final String firstLine = "<?xml version='1.0'?>";
final String secondLine = "";
final String thirdLine = "<!--";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("\n");
- writer.write("<xml>\n");
- writer.write("</xml>\n");
- }
- },
- checkLines(firstLine, secondLine, thirdLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("\n");
+ writer.write("<xml>\n");
+ writer.write("</xml>\n");
+ }
+ },
+ checkLines(firstLine, secondLine, thirdLine));
}
@Test
- public void addLicenceToXMLWithoutDecl() throws IOException {
+ public void addLicenseToXMLWithoutDecl() throws IOException {
String filename = "tmp.xml";
final String firstLine = "<?xml version='1.0'?>";
final String secondLine = "<!--";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("<xml>\n");
- writer.write("</xml>\n");
- }
- },
- checkLines(firstLine, secondLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("<xml>\n");
+ writer.write("</xml>\n");
+ }
+ },
+ checkLines(firstLine, secondLine));
}
@Test
- public void addLicenceToHTML() throws IOException {
+ public void addLicenseToHTML() throws IOException {
String filename = "tmp.html";
String commentLine = "<!--";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("<html>\n");
- writer.write("\n");
- writer.write("</html>\n");
- }
- },
- checkLines(commentLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("<html>\n");
+ writer.write("\n");
+ writer.write("</html>\n");
+ }
+ },
+ checkLines(commentLine, null));
}
@Test
- public void addLicenceToCSS() throws IOException {
+ public void addLicenseToCSS() throws IOException {
String filename = "tmp.css";
String firstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(".class {\n");
- writer.write(" background-color: red;");
- writer.write("}\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(".class {\n");
+ writer.write(" background-color: red;");
+ writer.write("}\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToJavascript() throws IOException {
+ public void addLicenseToJavascript() throws IOException {
String filename = "tmp.js";
String firstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("if (a ==b) {>\n");
- writer.write(" alert(\"how useful!\");");
- writer.write("}\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("if (a ==b) {>\n");
+ writer.write(" alert(\"how useful!\");");
+ writer.write("}\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToAPT() throws IOException {
+ public void addLicenseToAPT() throws IOException {
String filename = "tmp.apt";
String firstLine = "~~" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("A Simple APT file");
- writer.write(" This file contains nothing\n");
- writer.write(" of any importance\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("A Simple APT file");
+ writer.write(" This file contains nothing\n");
+ writer.write(" of any importance\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToProperties() throws IOException {
+ public void addLicenseToProperties() throws IOException {
String filename = "tmp.properties";
String firstLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("property = value\n");
- writer.write("fun = true\n");
- writer.write("cool = true\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("property = value\n");
+ writer.write("fun = true\n");
+ writer.write("cool = true\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToScala() throws IOException {
+ public void addLicenseToScala() throws IOException {
String filename = "tmp.scala";
final String firstLine = "package foo {";
final String newFirstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("\n");
- writer.write(" object X { val x = 1; }\n");
- writer.write("}\n");
- }
- },
- new NewFileReader() {
- public void readFile(BufferedReader reader)
- throws IOException {
- String line = reader.readLine();
- assertEquals("First line is incorrect",
- newFirstLine, line);
- while ((line = reader.readLine()) != null) {
- if (line.length() == 0) {
- line = reader.readLine();
- break;
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("\n");
+ writer.write(" object X { val x = 1; }\n");
+ writer.write("}\n");
+ }
+ },
+ new NewFileReader() {
+ public void readFile(BufferedReader reader)
+ throws IOException {
+ String line = reader.readLine();
+ assertEquals("First line is incorrect",
+ newFirstLine, line);
+ while ((line = reader.readLine()) != null) {
+ if (line.length() == 0) {
+ line = reader.readLine();
+ break;
+ }
}
+ assertEquals("Package line is incorrect",
+ firstLine, line);
}
- assertEquals("Package line is incorrect",
- firstLine, line);
- }
- });
+ });
}
@Test
public void addLicenseToRubyWithoutHashBang()
- throws IOException {
+ throws IOException {
String filename = "tmp.rb";
String firstLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("class Foo\n");
- writer.write("end\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("class Foo\n");
+ writer.write("end\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
@@ -367,29 +374,29 @@ public class TestLicenceAppender {
String secondLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("class Foo\n");
- writer.write("end\n");
- }
- },
- checkLines(firstLine, secondLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("class Foo\n");
+ writer.write("end\n");
+ }
+ },
+ checkLines(firstLine, secondLine));
}
@Test
public void addLicenseToPerlWithoutHashBang()
- throws IOException {
+ throws IOException {
String filename = "tmp.pl";
String firstLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("print \"Hello world\"\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("print \"Hello world\"\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
@@ -399,28 +406,28 @@ public class TestLicenceAppender {
String secondLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("print \"Hello world\"\n");
- }
- },
- checkLines(firstLine, secondLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("print \"Hello world\"\n");
+ }
+ },
+ checkLines(firstLine, secondLine));
}
@Test
public void addLicenseToTclWithoutHashBang()
- throws IOException {
+ throws IOException {
String filename = "tmp.tcl";
String firstLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("puts \"Hello world\"\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("puts \"Hello world\"\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
@@ -430,81 +437,81 @@ public class TestLicenceAppender {
String secondLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("puts \"Hello world\"\n");
- }
- },
- checkLines(firstLine, secondLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("puts \"Hello world\"\n");
+ }
+ },
+ checkLines(firstLine, secondLine));
}
@Test
- public void addLicenceToPHP() throws IOException {
+ public void addLicenseToPHP() throws IOException {
String filename = "tmp.php";
final String firstLine = "<?php";
final String secondLine = "";
final String thirdLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("echo 'Hello World'\n");
- writer.write("?>\n");
- }
- },
- checkLines(firstLine, secondLine, thirdLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("echo 'Hello World'\n");
+ writer.write("?>\n");
+ }
+ },
+ checkLines(firstLine, secondLine, thirdLine));
}
@Test
- public void addLicenceToCSharp() throws IOException {
+ public void addLicenseToCSharp() throws IOException {
String filename = "tmp.cs";
String firstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("namespace org.example {\n");
- writer.write(" public class Foo {\n");
- writer.write(" }\n");
- writer.write("}\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("namespace org.example {\n");
+ writer.write(" public class Foo {\n");
+ writer.write(" }\n");
+ writer.write("}\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToGroovy() throws IOException {
+ public void addLicenseToGroovy() throws IOException {
String filename = "tmp.groovy";
String firstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("package org.example \n");
- writer.write(" class Foo {\n");
- writer.write(" }\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("package org.example \n");
+ writer.write(" class Foo {\n");
+ writer.write(" }\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
- public void addLicenceToCPlusPlus() throws IOException {
+ public void addLicenseToCPlusPlus() throws IOException {
String filename = "tmp.cpp";
String firstLine = "/*";
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write("namespace org.example {\n");
- writer.write(" public class Foo {\n");
- writer.write(" }\n");
- writer.write("}\n");
- }
- },
- checkLines(firstLine, null));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write("namespace org.example {\n");
+ writer.write(" public class Foo {\n");
+ writer.write(" }\n");
+ writer.write("}\n");
+ }
+ },
+ checkLines(firstLine, null));
}
@Test
@@ -512,13 +519,13 @@ public class TestLicenceAppender {
File f = Resources.getResourceFile("violations/FilterTest.cs");
try {
ApacheV2LicenceAppender appender =
- new ApacheV2LicenceAppender();
+ new ApacheV2LicenceAppender();
appender.append(f);
BufferedReader r = null;
try {
r = new BufferedReader(new FileReader(f.getAbsolutePath()
- + ".new"));
+ + ".new"));
assertEquals("/*", r.readLine());
String line = null;
while ((line = r.readLine()) != null) {
@@ -538,171 +545,171 @@ public class TestLicenceAppender {
}
@Test
- public void addLicenceToVS2003solution() throws IOException {
+ public void addLicenseToVS2003solution() throws IOException {
String filename = "tmp.sln";
final String firstLine = "Microsoft Visual Studio Solution File,"
- + " Format Version 8.0";
+ + " Format Version 8.0";
String secondLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ConsoleApp\", \"Tutorials\\ConsoleApp\\cs\\src\\ConsoleApp.csproj\", \"{933969DF-2BC5-44E6-8B1A-400FC276A23F}\"\n");
- writer.write("\tProjectSection(WebsiteProperties) = preProject\n");
- writer.write("\t\tDebug.AspNetCompiler.Debug = \"True\"\n");
- writer.write("\t\tRelease.AspNetCompiler.Debug = \"False\"\n");
- writer.write("\tEndProjectSection\n");
- writer.write("EndProject\n");
- }
- },
- checkLines(firstLine, secondLine));
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ConsoleApp\", \"Tutorials\\ConsoleApp\\cs\\src\\ConsoleApp.csproj\", \"{933969DF-2BC5-44E6-8B1A-400FC276A23F}\"\n");
+ writer.write("\tProjectSection(WebsiteProperties) = preProject\n");
+ writer.write("\t\tDebug.AspNetCompiler.Debug = \"True\"\n");
+ writer.write("\t\tRelease.AspNetCompiler.Debug = \"False\"\n");
+ writer.write("\tEndProjectSection\n");
+ writer.write("EndProject\n");
+ }
+ },
+ checkLines(firstLine, secondLine));
}
@Test
- public void addLicenceToVS2005solution() throws IOException {
+ public void addLicenseToVS2005solution() throws IOException {
String filename = "tmp.sln";
final String firstLine = "Microsoft Visual Studio Solution File,"
- + " Format Version 9.0";
+ + " Format Version 9.0";
final String secondLine = "# Visual Studio 2005";
final String thirdLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write(secondLine + "\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ConsoleApp\", \"Tutorials\\ConsoleApp\\cs\\src\\ConsoleApp.csproj\", \"{933969DF-2BC5-44E6-8B1A-400FC276A23F}\"\n");
- writer.write("\tProjectSection(WebsiteProperties) = preProject\n");
- writer.write("\t\tDebug.AspNetCompiler.Debug = \"True\"\n");
- writer.write("\t\tRelease.AspNetCompiler.Debug = \"False\"\n");
- writer.write("\tEndProjectSection\n");
- writer.write("EndProject\n");
- }
- },
- new NewFileReader() {
- public void readFile(BufferedReader r) throws IOException {
- String line = r.readLine();
- assertEquals("First line is incorrect",
- firstLine, line);
- line = r.readLine();
- assertEquals("Second line is incorrect",
- secondLine, line);
- line = r.readLine();
- assertEquals("Third line is incorrect",
- thirdLine, line);
- }
- });
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write(secondLine + "\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"ConsoleApp\", \"Tutorials\\ConsoleApp\\cs\\src\\ConsoleApp.csproj\", \"{933969DF-2BC5-44E6-8B1A-400FC276A23F}\"\n");
+ writer.write("\tProjectSection(WebsiteProperties) = preProject\n");
+ writer.write("\t\tDebug.AspNetCompiler.Debug = \"True\"\n");
+ writer.write("\t\tRelease.AspNetCompiler.Debug = \"False\"\n");
+ writer.write("\tEndProjectSection\n");
+ writer.write("EndProject\n");
+ }
+ },
+ new NewFileReader() {
+ public void readFile(BufferedReader r) throws IOException {
+ String line = r.readLine();
+ assertEquals("First line is incorrect",
+ firstLine, line);
+ line = r.readLine();
+ assertEquals("Second line is incorrect",
+ secondLine, line);
+ line = r.readLine();
+ assertEquals("Third line is incorrect",
+ thirdLine, line);
+ }
+ });
}
@Test
- public void addLicenceToVS2010ExpressSolution() throws IOException {
+ public void addLicenseToVS2010ExpressSolution() throws IOException {
String filename = "tmp.sln";
final String firstLine = "Microsoft Visual Studio Solution File, "
- + "Format Version 11.00";
+ + "Format Version 11.00";
final String secondLine = "# Visual C# Express 2010";
final String thirdLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write(secondLine + "\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Lucene.Net\", \"..\\..\\..\\src\\core\\Lucene.Net.csproj\", \"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}\"\n");
- writer.write("EndProject\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Contrib.Highlighter\", \"..\\..\\..\\src\\contrib\\Highlighter\\Contrib.Highlighter.csproj\", \"{901D5415-383C-4AA6-A256-879558841BEA}\"\n");
- writer.write("EndProject\n");
- writer.write("Global\n");
- writer.write("GlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
- writer.write("Debug|Any CPU = Debug|Any CPU\n");
- writer.write("Release|Any CPU = Release|Any CPU\n");
- writer.write("EndGlobalSection\n");
- writer.write("GlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.Build.0 = Release|Any CPU\n");
- writer.write("EndGlobalSection\n");
- writer.write("GlobalSection(SolutionProperties) = preSolution\n");
- writer.write("HideSolutionNode = FALSE\n");
- writer.write("EndGlobalSection\n");
- writer.write("EndGlobal \n");
- }
- },
- new NewFileReader() {
- public void readFile(BufferedReader r) throws IOException {
- String line = r.readLine();
- assertEquals("First line is incorrect",
- firstLine, line);
- line = r.readLine();
- assertEquals("Second line is incorrect",
- secondLine, line);
- line = r.readLine();
- assertEquals("Third line is incorrect",
- thirdLine, line);
- }
- });
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write(secondLine + "\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Lucene.Net\", \"..\\..\\..\\src\\core\\Lucene.Net.csproj\", \"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}\"\n");
+ writer.write("EndProject\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Contrib.Highlighter\", \"..\\..\\..\\src\\contrib\\Highlighter\\Contrib.Highlighter.csproj\", \"{901D5415-383C-4AA6-A256-879558841BEA}\"\n");
+ writer.write("EndProject\n");
+ writer.write("Global\n");
+ writer.write("GlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
+ writer.write("Debug|Any CPU = Debug|Any CPU\n");
+ writer.write("Release|Any CPU = Release|Any CPU\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("GlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.Build.0 = Release|Any CPU\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("GlobalSection(SolutionProperties) = preSolution\n");
+ writer.write("HideSolutionNode = FALSE\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("EndGlobal \n");
+ }
+ },
+ new NewFileReader() {
+ public void readFile(BufferedReader r) throws IOException {
+ String line = r.readLine();
+ assertEquals("First line is incorrect",
+ firstLine, line);
+ line = r.readLine();
+ assertEquals("Second line is incorrect",
+ secondLine, line);
+ line = r.readLine();
+ assertEquals("Third line is incorrect",
+ thirdLine, line);
+ }
+ });
}
@Test
- public void addLicenceToVS2010SolutionWithBlankLine() throws IOException {
+ public void addLicenseToVS2010SolutionWithBlankLine() throws IOException {
String filename = "tmp.sln";
final String firstLine = "";
final String secondLine = "Microsoft Visual Studio Solution File, "
- + "Format Version 11.00";
+ + "Format Version 11.00";
final String thirdLine = "# Visual C# Express 2010";
final String forthLine = "#" + FIRST_LICENSE_LINE;
commonTestTemplate(filename, new FileCreator() {
- public void createFile(Writer writer)
- throws IOException {
- writer.write(firstLine + "\n");
- writer.write(secondLine + "\n");
- writer.write(thirdLine + "\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Lucene.Net\", \"..\\..\\..\\src\\core\\Lucene.Net.csproj\", \"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}\"\n");
- writer.write("EndProject\n");
- writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Contrib.Highlighter\", \"..\\..\\..\\src\\contrib\\Highlighter\\Contrib.Highlighter.csproj\", \"{901D5415-383C-4AA6-A256-879558841BEA}\"\n");
- writer.write("EndProject\n");
- writer.write("Global\n");
- writer.write("GlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
- writer.write("Debug|Any CPU = Debug|Any CPU\n");
- writer.write("Release|Any CPU = Release|Any CPU\n");
- writer.write("EndGlobalSection\n");
- writer.write("GlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
- writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
- writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.Build.0 = Release|Any CPU\n");
- writer.write("EndGlobalSection\n");
- writer.write("GlobalSection(SolutionProperties) = preSolution\n");
- writer.write("HideSolutionNode = FALSE\n");
- writer.write("EndGlobalSection\n");
- writer.write("EndGlobal \n");
- }
- },
- new NewFileReader() {
- public void readFile(BufferedReader r) throws IOException {
- String line = r.readLine();
- assertEquals("First line is incorrect",
- firstLine, line);
- line = r.readLine();
- assertEquals("Second line is incorrect",
- secondLine, line);
- line = r.readLine();
- assertEquals("Third line is incorrect",
- thirdLine, line);
- line = r.readLine();
- assertEquals("Forth line is incorrect",
- forthLine, line);
- }
- });
+ public void createFile(Writer writer)
+ throws IOException {
+ writer.write(firstLine + "\n");
+ writer.write(secondLine + "\n");
+ writer.write(thirdLine + "\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Lucene.Net\", \"..\\..\\..\\src\\core\\Lucene.Net.csproj\", \"{5D4AD9BE-1FFB-41AB-9943-25737971BF57}\"\n");
+ writer.write("EndProject\n");
+ writer.write("Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"Contrib.Highlighter\", \"..\\..\\..\\src\\contrib\\Highlighter\\Contrib.Highlighter.csproj\", \"{901D5415-383C-4AA6-A256-879558841BEA}\"\n");
+ writer.write("EndProject\n");
+ writer.write("Global\n");
+ writer.write("GlobalSection(SolutionConfigurationPlatforms) = preSolution\n");
+ writer.write("Debug|Any CPU = Debug|Any CPU\n");
+ writer.write("Release|Any CPU = Release|Any CPU\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("GlobalSection(ProjectConfigurationPlatforms) = postSolution\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
+ writer.write("{5D4AD9BE-1FFB-41AB-9943-25737971BF57}.Release|Any CPU.Build.0 = Release|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Debug|Any CPU.Build.0 = Debug|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.ActiveCfg = Release|Any CPU\n");
+ writer.write("{901D5415-383C-4AA6-A256-879558841BEA}.Release|Any CPU.Build.0 = Release|Any CPU\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("GlobalSection(SolutionProperties) = preSolution\n");
+ writer.write("HideSolutionNode = FALSE\n");
+ writer.write("EndGlobalSection\n");
+ writer.write("EndGlobal \n");
+ }
+ },
+ new NewFileReader() {
+ public void readFile(BufferedReader r) throws IOException {
+ String line = r.readLine();
+ assertEquals("First line is incorrect",
+ firstLine, line);
+ line = r.readLine();
+ assertEquals("Second line is incorrect",
+ secondLine, line);
+ line = r.readLine();
+ assertEquals("Third line is incorrect",
+ thirdLine, line);
+ line = r.readLine();
+ assertEquals("Forth line is incorrect",
+ forthLine, line);
+ }
+ });
}
}
Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/document/impl/guesser/BinaryGuesserTest.java Sun May 24 22:05:01 2015
@@ -134,7 +134,7 @@ public class BinaryGuesserTest {
}
@Test
- public void testFileEncodingSettable() {
+ public void testFileEncodingCanBeSetAndHasFallbackInCaseOfErrors() {
System.setProperty(BinaryGuesser.FILE_ENCODING, "shouldThrowAnExceptionBecauseNotFound");
assertEquals("UTF-8", BinaryGuesser.getFileEncodingOrUTF8AsFallback().displayName());
Modified: creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java (original)
+++ creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java Sun May 24 22:05:01 2015
@@ -188,7 +188,7 @@ public abstract class AbstractRatMojo ex
private boolean excludeSubProjects;
/**
- * Will skip the plugin execution, e.g. for technical builds that do not take licence compliance into account.
+ * Will skip the plugin execution, e.g. for technical builds that do not take license compliance into account.
*
* @since 0.11
*/
Modified: creadur/rat/trunk/apache-rat-tasks/src/site/apt/examples/basic.apt.vm
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-tasks/src/site/apt/examples/basic.apt.vm?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-tasks/src/site/apt/examples/basic.apt.vm (original)
+++ creadur/rat/trunk/apache-rat-tasks/src/site/apt/examples/basic.apt.vm Sun May 24 22:05:01 2015
@@ -54,12 +54,12 @@ java -jar apache-rat-${project.version}.
</rat:report>
---
-* Adding licence headers
+* Adding license headers
The equivalent of
+------------------------------------------+
-java -jar apache-rat-${project.version}.jar --addLicence
+java -jar apache-rat-${project.version}.jar --addlicense
--copyright "Copyright 2008 Foo"
/path/to/project
+------------------------------------------+
Modified: creadur/rat/trunk/apache-rat/README-CLI.txt
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat/README-CLI.txt?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat/README-CLI.txt (original)
+++ creadur/rat/trunk/apache-rat/README-CLI.txt Sun May 24 22:05:01 2015
@@ -16,19 +16,19 @@ java -jar apache-rat-${project.version}.
This will output a help message detailing the command line options available to you.
-Adding licence headers
+Adding license headers
----------------------
-Rat can be used to automatically add licence headers to files that do not currently have them.
+Rat can be used to automatically add license headers to files that do not currently have them.
Only files that are not excluded by the Rat configurations will be affected.
-To add licence headers use a command such as:
+To add license headers use a command such as:
-java -jar apache-rat-${project.version}.jar --addLicence
+java -jar apache-rat-${project.version}.jar --addlicense
--copyright "Copyright 2008 Foo" --force
/path/to/project
-This command will add the licence header directly to the source files.
+This command will add the license header directly to the source files.
If you prefer to see which files will be changed and how then remove the "--force" option.
Using multiple excludes from a file
@@ -46,20 +46,20 @@ Command Line Options
usage: java rat.report [options] [DIR|TARBALL]
Options
- -A,--addLicense Add the default licence header to any file
- with an unknown licence that is not in the
+ -A,--addLicense Add the default license header to any file
+ with an unknown license that is not in the
exclusion list. By default new files will
- be created with the licence header, to
+ be created with the license header, to
force the modification of existing files
use the --force option.
- -a,--addLicence Add the default licence header to any file
- with an unknown licence that is not in the
+ -a,--addlicense Add the default license header to any file
+ with an unknown license that is not in the
exclusion list. By default new files will
- be created with the licence header, to
+ be created with the license header, to
force the modification of existing files
use the --force option.
-c,--copyright <arg> The copyright message to use in the
- licence headers, usually in the form of
+ license headers, usually in the form of
"Copyright 2008 Foo"
-d,--dir Used to indicate source when using
--exclude
Modified: creadur/rat/trunk/apache-rat/pom.xml
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat/pom.xml?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat/pom.xml (original)
+++ creadur/rat/trunk/apache-rat/pom.xml Sun May 24 22:05:01 2015
@@ -50,7 +50,7 @@
<targetPath>META-INF</targetPath>
<includes>
<include>RELEASE_NOTES.txt</include>
- <include>LICENCE</include>
+ <include>LICENSE</include>
<include>NOTICE</include>
</includes>
</resource>
Modified: creadur/rat/trunk/apache-rat/src/site/apt/index.apt.vm
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat/src/site/apt/index.apt.vm?rev=1681534&r1=1681533&r2=1681534&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat/src/site/apt/index.apt.vm (original)
+++ creadur/rat/trunk/apache-rat/src/site/apt/index.apt.vm Sun May 24 22:05:01 2015
@@ -39,21 +39,21 @@ java -jar apache-rat-${project.version}.
This will output a help message detailing the command line
options available to you.
-* Adding licence headers
+* Adding license headers
- Rat can be used to automatically add licence headers to
+ Rat can be used to automatically add license headers to
files that do not currently have them. Only files that
are not excluded by the Rat configurations will be affected.
- To add licence headers use a command such as:
+ To add license headers use a command such as:
+------------------------------------------+
-java -jar apache-rat-${project.version}.jar --addLicence
+java -jar apache-rat-${project.version}.jar --addlicense
--copyright "Copyright 2008 Foo" --force
/path/to/project
+------------------------------------------+
- This command will add the licence header directly to the
+ This command will add the license header directly to the
source files. If you prefer to see which files will be
changed and how then remove the "--force" option.
@@ -77,20 +77,20 @@ java -jar apache-rat-${project.version}.
+------------------------------------------+
usage: java rat.report [options] [DIR|TARBALL]
Options
- -A,--addLicense Add the default licence header to any file
- with an unknown licence that is not in the
+ -A,--addLicense Add the default license header to any file
+ with an unknown license that is not in the
exclusion list. By default new files will
- be created with the licence header, to
+ be created with the license header, to
force the modification of existing files
use the --force option.
- -a,--addLicence Add the default licence header to any file
- with an unknown licence that is not in the
+ -a,--addlicense Add the default license header to any file
+ with an unknown license that is not in the
exclusion list. By default new files will
- be created with the licence header, to
+ be created with the license header, to
force the modification of existing files
use the --force option.
-c,--copyright <arg> The copyright message to use in the
- licence headers, usually in the form of
+ license headers, usually in the form of
"Copyright 2008 Foo"
-d,--dir Used to indicate source when using
--exclude