Author: rdonkin
Date: Mon Dec 9 05:40:05 2013
New Revision: 1549400
URL: http://svn.apache.org/r1549400
Log:
Format Code.
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java?rev=1549400&r1=1549399&r2=1549400&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
Mon Dec 9 05:40:05 2013
@@ -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;
import org.apache.rat.analysis.util.HeaderMatcherMultiplexer;
@@ -30,97 +30,114 @@ import static org.junit.Assert.assertEqu
import static org.junit.Assert.assertTrue;
public class ReportTest {
- private static final String HEADER =
- "\n" +
- "*****************************************************\n" +
- "Summary\n" +
- "-------\n" +
- "Generated at: ";
-
- private static String getElementsReports(String pElementsPath) {
- return
- "Notes: 2\n" +
- "Binaries: 1\n" +
- "Archives: 1\n" +
- "Standards: 6\n" +
- "\n" +
- "Apache Licensed: 3\n" +
- "Generated Documents: 0\n" +
- "\n" +
- "JavaDocs are generated and so license header is optional\n" +
- "Generated files do not required license headers\n" +
- "\n" +
- "2 Unknown Licenses\n" +
- "\n" +
- "*******************************\n" +
- "\n" +
- "Unapproved licenses:\n" +
- "\n" +
- " " + pElementsPath + "/Source.java\n" +
- " " + pElementsPath + "/sub/Empty.txt\n" +
- "\n" +
- "*******************************\n" +
- "\n" +
- "Archives:\n" +
- "\n" +
- " + " + pElementsPath + "/dummy.jar\n" +
- " \n" +
- "*****************************************************\n" +
- " Files with Apache License headers will be marked AL\n" +
- " Binary files (which do not require AL headers) will be marked
B\n" +
- " Compressed archives will be marked A\n" +
- " Notices, licenses etc will be marked N\n" +
- " MIT " + pElementsPath + "/ILoggerFactory.java\n" +
- " B " + pElementsPath + "/Image.png\n" +
- " N " + pElementsPath + "/LICENSE\n" +
- " N " + pElementsPath + "/NOTICE\n" +
- " !????? " + pElementsPath + "/Source.java\n" +
- " AL " + pElementsPath + "/Text.txt\n" +
- " AL " + pElementsPath + "/Xml.xml\n" +
- " AL " + pElementsPath + "/buildr.rb\n" +
- " A " + pElementsPath + "/dummy.jar\n" +
- " !????? " + pElementsPath + "/sub/Empty.txt\n" +
- " \n" +
- "*****************************************************\n" +
- " Printing headers for files without AL header...\n" +
- " \n" +
- " \n" +
-
"=======================================================================\n" +
- "==" + pElementsPath + "/Source.java\n" +
-
"=======================================================================\n" +
- "package elements;\n" +
- "\n" +
- "/*\n" +
- " * This file does intentionally *NOT* contain an AL license
header,\n" +
- " * because it is used in the test suite.\n" +
- " */\n" +
- "public class Source {\n" +
- "\n" +
- "}\n" +
- "\n" +
-
"=======================================================================\n" +
- "==" + pElementsPath + "/sub/Empty.txt\n" +
-
"=======================================================================\n" +
- "\n";
- }
-
- @Test
- public void plainReport() throws Exception {
- StringWriter out = new StringWriter();
- HeaderMatcherMultiplexer matcherMultiplexer = new
HeaderMatcherMultiplexer(Defaults.DEFAULT_MATCHERS);
- final String elementsPath =
Resources.getResourceDirectory("elements/Source.java");
- final ReportConfiguration configuration = new ReportConfiguration();
- configuration.setHeaderMatcher(matcherMultiplexer);
- Report.report(out, new DirectoryWalker(new File(elementsPath)),
- Defaults.getPlainStyleSheet(), configuration);
- String result = out.getBuffer().toString();
- final String nl = System.getProperty("line.separator");
- assertTrue("'Generated at' is present in " + result,
- result.startsWith(HEADER.replaceAll("\n", nl)));
- final int generatedAtLineEnd = result.indexOf(nl, HEADER.length());
- final String elementsReports = getElementsReports(elementsPath);
- assertEquals("Report created",
- elementsReports.replaceAll("\n", nl),
- result.substring(generatedAtLineEnd + nl.length()));
- }
+ private static final String HEADER = "\n"
+ +
"*****************************************************\n"
+ + "Summary\n" + "-------\n" + "Generated at: ";
+
+ private static String getElementsReports(String pElementsPath) {
+ return "Notes: 2\n" + "Binaries: 1\n" + "Archives: 1\n"
+ + "Standards: 6\n" + "\n" + "Apache Licensed:
3\n"
+ + "Generated Documents: 0\n" + "\n"
+ + "JavaDocs are generated and so license header
is optional\n"
+ + "Generated files do not required license
headers\n" + "\n"
+ + "2 Unknown Licenses\n" + "\n"
+ + "*******************************\n" + "\n"
+ + "Unapproved licenses:\n" + "\n" + " "
+ + pElementsPath
+ + "/Source.java\n"
+ + " "
+ + pElementsPath
+ + "/sub/Empty.txt\n"
+ + "\n"
+ + "*******************************\n"
+ + "\n"
+ + "Archives:\n"
+ + "\n"
+ + " + "
+ + pElementsPath
+ + "/dummy.jar\n"
+ + " \n"
+ +
"*****************************************************\n"
+ + " Files with Apache License headers will be
marked AL\n"
+ + " Binary files (which do not require AL
headers) will be marked B\n"
+ + " Compressed archives will be marked A\n"
+ + " Notices, licenses etc will be marked N\n"
+ + " MIT "
+ + pElementsPath
+ + "/ILoggerFactory.java\n"
+ + " B "
+ + pElementsPath
+ + "/Image.png\n"
+ + " N "
+ + pElementsPath
+ + "/LICENSE\n"
+ + " N "
+ + pElementsPath
+ + "/NOTICE\n"
+ + " !????? "
+ + pElementsPath
+ + "/Source.java\n"
+ + " AL "
+ + pElementsPath
+ + "/Text.txt\n"
+ + " AL "
+ + pElementsPath
+ + "/Xml.xml\n"
+ + " AL "
+ + pElementsPath
+ + "/buildr.rb\n"
+ + " A "
+ + pElementsPath
+ + "/dummy.jar\n"
+ + " !????? "
+ + pElementsPath
+ + "/sub/Empty.txt\n"
+ + " \n"
+ +
"*****************************************************\n"
+ + " Printing headers for files without AL
header...\n"
+ + " \n"
+ + " \n"
+ +
"=======================================================================\n"
+ + "=="
+ + pElementsPath
+ + "/Source.java\n"
+ +
"=======================================================================\n"
+ + "package elements;\n"
+ + "\n"
+ + "/*\n"
+ + " * This file does intentionally *NOT*
contain an AL license header,\n"
+ + " * because it is used in the test suite.\n"
+ + " */\n"
+ + "public class Source {\n"
+ + "\n"
+ + "}\n"
+ + "\n"
+ +
"=======================================================================\n"
+ + "=="
+ + pElementsPath
+ + "/sub/Empty.txt\n"
+ +
"=======================================================================\n"
+ + "\n";
+ }
+
+ @Test
+ public void plainReport() throws Exception {
+ StringWriter out = new StringWriter();
+ HeaderMatcherMultiplexer matcherMultiplexer = new
HeaderMatcherMultiplexer(
+ Defaults.DEFAULT_MATCHERS);
+ final String elementsPath = Resources
+ .getResourceDirectory("elements/Source.java");
+ final ReportConfiguration configuration = new
ReportConfiguration();
+ configuration.setHeaderMatcher(matcherMultiplexer);
+ Report.report(out, new DirectoryWalker(new File(elementsPath)),
+ Defaults.getPlainStyleSheet(), configuration);
+ String result = out.getBuffer().toString();
+ final String nl = System.getProperty("line.separator");
+ assertTrue("'Generated at' is present in " + result,
+ result.startsWith(HEADER.replaceAll("\n", nl)));
+ final int generatedAtLineEnd = result.indexOf(nl,
HEADER.length());
+ final String elementsReports = getElementsReports(elementsPath);
+ assertEquals("Report created", elementsReports.replaceAll("\n",
nl),
+ result.substring(generatedAtLineEnd +
nl.length()));
+ }
}