You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by cl...@apache.org on 2025/12/15 17:03:42 UTC
(creadur-rat) branch feature/restructure created (now e5f9474d)
This is an automated email from the ASF dual-hosted git repository.
claude pushed a change to branch feature/restructure
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
at e5f9474d partial migration
This branch includes the following new commits:
new e5f9474d partial migration
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(creadur-rat) 01/01: partial migration
Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
claude pushed a commit to branch feature/restructure
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
commit e5f9474d11c43da34a2d014cb96f17fad21952a7
Author: Claude Warren <cl...@xenei.com>
AuthorDate: Mon Dec 15 17:02:59 2025 +0000
partial migration
---
.../it/resources/ReportTest/RAT_14/commandLine.txt | 0
.../resources/ReportTest/RAT_14/src/Image-png.not | Bin
.../src/it/resources/ReportTest/RAT_14/src/NOTICE | 0
.../ReportTest/RAT_14/src/UTF16_with_signature.xml | Bin
.../ReportTest/RAT_14/src/UTF8_with_signature.xml | 0
.../resources/ReportTest/RAT_14/src/dummy.tar.gz | Bin
.../it/resources/ReportTest/RAT_14/src/file.cpp | 0
.../resources/ReportTest/RAT_14/src/generated.txt | 0
.../RAT_14/src/leader-election-message-arrives.dia | Bin
.../resources/ReportTest/RAT_14/src/side_left.bmp | Bin
.../ReportTest/RAT_14/src/unix-newlines.txt.bin | 0
.../ReportTest/RAT_14/src/windows-newlines.txt.bin | 0
.../it/resources/ReportTest/RAT_14/verify.groovy | 0
.../resources/ReportTest/RAT_147/commandLine.txt | 0
.../ReportTest/RAT_147/src/unix-newlines.txt.bin | 0
.../RAT_147/src/windows-newlines.txt.bin | 0
.../it/resources/ReportTest/RAT_147/verify.groovy | 0
.../resources/ReportTest/RAT_211/commandLine.txt | 0
.../src/leader-election-message-arrives.dia | Bin
.../resources/ReportTest/RAT_211/src/side_left.bmp | Bin
.../it/resources/ReportTest/RAT_211/verify.groovy | 0
.../resources/ReportTest/RAT_246/commandLine.txt | 0
.../src/it/resources/ReportTest/RAT_246/notes.md | 0
.../ReportTest/RAT_246/src/dir1/FileToProcess | 0
.../it/resources/ReportTest/RAT_246/verify.groovy | 0
.../resources/ReportTest/RAT_259/commandLine.txt | 0
.../RAT_259/elements/ILoggerFactory.java | 0
.../ReportTest/RAT_259/elements/Image.png | Bin
.../resources/ReportTest/RAT_259/elements/LICENSE | 0
.../resources/ReportTest/RAT_259/elements/NOTICE | 0
.../ReportTest/RAT_259/elements/Source.java | 0
.../resources/ReportTest/RAT_259/elements/Text.txt | 0
.../ReportTest/RAT_259/elements/TextHttps.txt | 0
.../resources/ReportTest/RAT_259/elements/Xml.xml | 0
.../ReportTest/RAT_259/elements/buildr.rb | 0
.../ReportTest/RAT_259/elements/dummy.jar | Bin
.../ReportTest/RAT_259/elements/generated.txt | 0
.../ReportTest/RAT_259/elements/plain.json | 0
.../ReportTest/RAT_259/elements/sub/Empty.txt | 0
.../resources/ReportTest/RAT_259/elements/tri.txt | 0
.../src/it/resources/ReportTest/RAT_259/list.txt | 0
.../it/resources/ReportTest/RAT_259/verify.groovy | 0
.../resources/ReportTest/RAT_335/commandLine.txt | 0
.../ReportTest/RAT_335/expected-message.txt | 0
.../src/it/resources/ReportTest/RAT_335/pom.xml | 0
.../it/resources/ReportTest/RAT_335/src/README.txt | 0
.../resources/ReportTest/RAT_335/src/dir1/dir1.md | 0
.../resources/ReportTest/RAT_335/src/dir2/dir2.txt | 0
.../ReportTest/RAT_335/src/dir3/file3.log | 0
.../it/resources/ReportTest/RAT_335/verify.groovy | 0
.../resources/ReportTest/RAT_362/commandLine.txt | 0
.../ReportTest/RAT_362/expected-message.txt | 0
.../it/resources/ReportTest/RAT_362/verify.groovy | 0
.../resources/ReportTest/RAT_406/commandLine.txt | 0
.../ReportTest/RAT_406/expected-message.txt | 0
.../ReportTest/RAT_406/src/dojo/dojo.java | 0
.../resources/ReportTest/RAT_408/commandLine.txt | 0
.../ReportTest/RAT_408/expected-message.txt | 0
.../src/karapace/anonymize_schemas/_init_.py | 0
.../resources/ReportTest/RAT_455/commandLine.txt | 0
.../src/it/resources/ReportTest/RAT_455/src/GPL.md | 0
.../it/resources/ReportTest/RAT_455/verify.groovy | 0
.../resources/ReportTest/RAT_457/commandLine.txt | 0
.../RAT_457/src/apache-rat-0.17-SNAPSHOT.jar | Bin
.../it/resources/ReportTest/RAT_457/verify.groovy | 0
.../resources/ReportTest/RAT_458/commandLine.txt | 0
.../it/resources/ReportTest/RAT_458/src/README.md | 0
.../it/resources/ReportTest/RAT_458/verify.groovy | 0
.../resources/ReportTest/RAT_469/commandLine.txt | 0
.../ReportTest/RAT_469/src/GPLTestClass.java | 0
.../it/resources/ReportTest/RAT_469/verify.groovy | 0
.../resources/ReportTest/RAT_500/commandLine.txt | 0
.../src/it/resources/ReportTest/RAT_500/output.txt | 0
.../it/resources/ReportTest/RAT_81/commandLine.txt | 0
.../it/resources/ReportTest/RAT_81/src/IBM037.txt | 0
.../it/resources/ReportTest/RAT_81/src/UTF8.txt | 0
.../it/resources/ReportTest/RAT_81/verify.groovy | 0
.../src/it/resources/ReportTest/readme.md | 0
.../main/java/org.apache.rat.cli}/CLIOption.java | 3 +-
.../src/main/java/org.apache.rat.cli}/Report.java | 51 +-
.../java/org/apache/rat/cli/ReportOptionsTest.java | 68 +
.../test/java/org/apache/rat/cli/ReportTest.java | 64 +
apache-rat-core/pom.xml | 107 +-
apache-rat-core/spotbugs-ignore.xml | 2 +-
.../src/it/java/org/apache/rat/ReportTest.java | 227 -
.../it/resources/ReportTest/RAT_335/src/.gitignore | 8 -
.../ReportTest/RAT_335/src/dir1/.gitignore | 4 -
.../resources/ReportTest/RAT_335/src/dir1/dir1.txt | 1 -
.../ReportTest/RAT_335/src/dir1/file1.log | 1 -
.../resources/ReportTest/RAT_335/src/dir2/dir2.md | 1 -
.../resources/ReportTest/RAT_335/src/dir3/dir3.log | 1 -
.../it/resources/ReportTest/RAT_335/src/root.md | 1 -
.../it/resources/ReportTest/RAT_362/src/.gitignore | 2 -
.../src/it/resources/ReportTest/RAT_362/src/foo.md | 0
.../src/it/resources/ReportTest/RAT_362/src/src.md | 0
.../src/main/java/org/apache/rat/Defaults.java | 1 -
.../main/java/org/apache/rat/OptionCollection.java | 68 +-
.../java/org/apache/rat/ReportConfiguration.java | 63 +-
.../src/main/java/org/apache/rat/Reporter.java | 213 +-
.../main/java/org/apache/rat/commandline/Arg.java | 4 +-
.../org/apache/rat/commandline/StyleSheets.java | 11 +-
.../java/org/apache/rat/document/DocumentName.java | 1 +
.../apache/rat/documentation/velocity/License.java | 92 +
.../apache/rat/documentation/velocity/Matcher.java | 302 ++
.../rat/documentation/velocity/MatcherTree.java | 136 +
.../apache/rat/documentation/velocity/RatTool.java | 278 +
.../rat/documentation/velocity}/package-info.java | 4 +-
.../java/org/apache/rat/report/AbstractReport.java | 50 -
.../rat/report/claim/ClaimValidatorReport.java | 21 +-
.../org/apache/rat/report/xml/XmlElements.java | 7 +-
.../org/apache/rat/report/xml/writer/XMLChar.java | 1064 ++++
.../apache/rat/report/xml/writer/XmlWriter.java | 492 +-
.../java/org/apache/rat/ui}/AbstractOption.java | 9 +-
.../java/org/apache/rat/ui/package-info.java} | 9 +-
.../main/resources/org/apache/rat/rat-report.xsd | 2 +
.../src/main/resources/org/apache/rat/xhtml5.xsl | 354 ++
.../java/org/apache/rat/OptionCollectionTest.java | 262 +-
.../org/apache/rat/ReportConfigurationTest.java | 61 +-
.../org/apache/rat/ReporterOptionsProvider.java | 1353 -----
.../java/org/apache/rat/ReporterOptionsTest.java | 52 +-
.../src/test/java/org/apache/rat/ReporterTest.java | 71 +-
.../apache/rat/analysis/AnalyserFactoryTest.java | 102 +-
.../org/apache/rat/analysis/TikaProcessorTest.java | 109 +-
.../apache/rat/annotation/TestLicenseAppender.java | 23 +-
.../config/parameters/DescriptionBuilderTest.java | 54 +-
.../configuration/XMLConfigurationReaderTest.java | 21 +-
.../test/java/org/apache/rat/help/HelpTest.java | 4 +-
.../report/xml/writer/impl/base/XmlWriterTest.java | 23 +-
.../test/AbstractConfigurationOptionsProvider.java | 1672 +++---
.../apache/rat/test/AbstractOptionsProvider.java | 434 +-
.../java/org/apache/rat/test/utils/Resources.java | 8 +-
.../java/org/apache/rat/testhelpers/FileUtils.java | 1 +
.../org/apache/rat/testhelpers/data/DataUtils.java | 107 +
.../testhelpers/data/OptionTestDataProvider.java | 833 +++
.../testhelpers/data/ReportTestDataProvider.java | 1240 +++++
.../org/apache/rat/testhelpers/data/TestData.java | 185 +
.../apache/rat/testhelpers/data/ValidatorData.java | 66 +
.../resources/GitIgnoreBuilderTest/commandLine.txt | 7 -
.../GitIgnoreBuilderTest/expected-message.txt | 1 -
.../GitIgnoreBuilderTest/global-gitignore | 3 -
.../resources/GitIgnoreBuilderTest/src/.gitignore | 10 -
.../GitIgnoreBuilderTest/src/dir1/.gitignore | 3 -
.../GitIgnoreBuilderTest/src/dir1/dir1.txt | 1 -
.../GitIgnoreBuilderTest/src/dir1/file1.log | 1 -
.../GitIgnoreBuilderTest/src/dir2/dir2.md | 1 -
.../GitIgnoreBuilderTest/src/dir3/dir3.log | 1 -
.../src/local-should-precede-global.md | 5 -
.../src/local-should-precede-global.xml | 5 -
.../resources/GitIgnoreBuilderTest/src/root.md | 1 -
.../resources/GitIgnoreBuilderTest/verify.groovy | 125 -
.../test/resources/XmlOutputExamples/elements.xml | 49 -
.../test/resources/appliedAL20/bad/aal20bad1.txt | 17 -
.../test/resources/appliedAL20/bad/aal20bad2.txt | 5553 --------------------
.../test/resources/appliedAL20/good/aal20good1.txt | 15 -
.../src/test/resources/artifacts/dummy.tar.gz | Bin 5342 -> 0 bytes
.../src/test/resources/binaries/Image-png.not | Bin 1098 -> 0 bytes
.../resources/binaries/UTF16_with_signature.xml | Bin 2402 -> 0 bytes
.../resources/binaries/UTF8_with_signature.xml | 29 -
.../test/resources/javadocs/ArchiveElement.html | 417 --
.../src/test/resources/javadocs/index.html | 37 -
.../src/test/resources/javadocs/notjavadoc.html | 26 -
.../resources/jira/RAT147/unix-newlines.txt.bin | 8 -
.../resources/jira/RAT147/windows-newlines.txt.bin | 9 -
.../RAT211/leader-election-message-arrives.dia | Bin 5796 -> 0 bytes
.../src/test/resources/jira/RAT211/side_left.bmp | Bin 345238 -> 0 bytes
.../src/test/resources/oasis/bad/oasisbad1.txt | 6 -
.../src/test/resources/oasis/bad/oasisbad2.txt | 5553 --------------------
.../src/test/resources/oasis/good/oasisgood1.txt | 10 -
.../org/apache/rat/MatcherContainerResource.txt | 2 -
.../org/apache/rat/ReportConfigurationTestFile | 18 -
.../src/test/resources/report/LicenseOne.xml | 11 -
.../src/test/resources/report/LicenseTwo.xml | 11 -
.../src/test/resources/tikaFiles/README.md | 11 -
.../src/test/resources/tikaFiles/archive/dummy.jar | Bin 6615 -> 0 bytes
.../test/resources/tikaFiles/binary/Defaults.class | Bin 7280 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.gif | Bin 74 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.jpeg | Bin 4803 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.jpg | Bin 4803 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.png | Bin 489 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.psd | Bin 2499 -> 0 bytes
.../src/test/resources/tikaFiles/binary/Image.xcf | Bin 1565 -> 0 bytes
.../test/resources/tikaFiles/binary/KeyStore.jks | Bin 4914 -> 0 bytes
.../src/test/resources/tikaFiles/binary/file.json | 7 -
.../resources/tikaFiles/binary/maven_libjansi.so | Bin 98380 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.aif | Bin 3894 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.au | Bin 3868 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.exe | Bin 1024 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.flv | Bin 90580 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.iff | Bin 1060 -> 0 bytes
.../test/resources/tikaFiles/binary/test.keystore | Bin 4914 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.mid | Bin 322 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.mp3 | Bin 2668637 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.ogg | Bin 5418 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.swf | Bin 180 -> 0 bytes
.../resources/tikaFiles/binary/test.truststore | Bin 1302 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.wav | Bin 3884 -> 0 bytes
.../src/test/resources/tikaFiles/binary/test.wma | Bin 27747 -> 0 bytes
.../resources/tikaFiles/binary/testMP3i18n.mp3 | Bin 40832 -> 0 bytes
.../tikaFiles/binary/testMP3i18n_truncated.mp3 | Bin 40672 -> 0 bytes
.../resources/tikaFiles/binary/testMP3id3v1.mp3 | Bin 39416 -> 0 bytes
.../resources/tikaFiles/binary/testMP3id3v1_v2.mp3 | Bin 40960 -> 0 bytes
.../resources/tikaFiles/binary/testMP3id3v2.mp3 | Bin 39577 -> 0 bytes
.../resources/tikaFiles/binary/testMP3id3v24.mp3 | Bin 39471 -> 0 bytes
.../resources/tikaFiles/binary/testMP3lyrics.mp3 | Bin 34688 -> 0 bytes
.../resources/tikaFiles/binary/testMP3noid3.mp3 | Bin 39288 -> 0 bytes
.../tikaFiles/binary/testMP3truncated.mp3 | Bin 65536 -> 0 bytes
.../test/resources/tikaFiles/binary/testMP4.m4a | Bin 4770 -> 0 bytes
.../tikaFiles/binary/testMP4_truncated.m4a | Bin 74 -> 0 bytes
.../tikaFiles/binary/testNakedUTF16BOM.mp3 | Bin 2625 -> 0 bytes
.../test/resources/tikaFiles/binary/truststore.jks | Bin 1302 -> 0 bytes
.../src/test/resources/tikaFiles/ca-cert | 22 -
.../src/test/resources/tikaFiles/ca-key | 30 -
.../src/test/resources/tikaFiles/cert-file | 19 -
.../src/test/resources/tikaFiles/cert-signed | 21 -
.../src/test/resources/tikaFiles/notice/LICENSE | 202 -
.../src/test/resources/tikaFiles/notice/NOTICE | 7 -
.../tikaFiles/standard/ChineseCommentsJava.java | 42 -
.../resources/tikaFiles/standard/HelloWorld.groovy | 25 -
.../resources/tikaFiles/standard/HelloWorld.java | 24 -
.../test/resources/tikaFiles/standard/Image.pdf | Bin 2390 -> 0 bytes
.../tikaFiles/standard/UTF16_with_signature.xml | Bin 2402 -> 0 bytes
.../tikaFiles/standard/UTF8_with_signature.xml | 29 -
.../src/test/resources/tikaFiles/standard/file.C | 22 -
.../src/test/resources/tikaFiles/standard/file.CPP | 24 -
.../src/test/resources/tikaFiles/standard/file.c | 22 -
.../src/test/resources/tikaFiles/standard/file.cc | 24 -
.../src/test/resources/tikaFiles/standard/file.cp | 24 -
.../src/test/resources/tikaFiles/standard/file.cpp | 24 -
.../src/test/resources/tikaFiles/standard/file.csv | 1 -
.../src/test/resources/tikaFiles/standard/file.cxx | 24 -
.../test/resources/tikaFiles/standard/file.plain | 20 -
.../src/test/resources/tikaFiles/standard/file.tsv | 1 -
.../src/test/resources/violations/FilterTest.cs | 90 -
.../test/resources/violations/FilterTest.cs.new | 109 -
.../src/test/resources/violations/bad.txt | 1 -
.../impl}/pom.xml | 2 +-
.../src/it/CustomLicense/.rat/customConfig.xml | 0
.../impl/src/it/CustomLicense}/invoker.properties | 0
.../impl}/src/it/CustomLicense/pom.xml | 0
.../main/java/nl/basjes/something/Something.java | 0
.../impl}/src/it/RAT-107/.idea/dummy | 0
.../impl}/src/it/RAT-107/covertura.ser | 0
.../impl}/src/it/RAT-107/pom.xml | 0
.../impl}/src/it/RAT-107/release.properties | 0
.../impl}/src/it/RAT-107/submodule/.idea/dummy | 0
.../impl}/src/it/RAT-107/submodule/covertura.ser | 0
.../impl}/src/it/RAT-107/submodule/pom.xml | 0
.../src/it/RAT-107/submodule/release.properties | 0
.../impl}/src/it/RAT-168/invoker.properties | 0
.../impl}/src/it/RAT-168/pom.xml | 0
.../impl}/src/it/RAT-168/verify.groovy | 2 +-
.../impl/src/it/RAT-268}/invoker.properties | 0
.../impl}/src/it/RAT-268/module1/pom.xml | 0
.../impl}/src/it/RAT-268/module1/src.apt | 0
.../impl}/src/it/RAT-268/module2/module2.pom | 0
.../impl}/src/it/RAT-268/module2/src.apt | 0
.../impl}/src/it/RAT-268/module3/pom.xml | 0
.../impl}/src/it/RAT-268/pom.xml | 0
.../impl}/src/it/RAT-314/.mvn/maven.config | 0
.../impl}/src/it/RAT-314/.mvn/recursive/foo.xml | 0
.../impl}/src/it/RAT-314/invoker.properties | 0
.../impl}/src/it/RAT-314/pom.xml | 0
.../impl}/src/it/RAT-314/verify.groovy | 2 +-
.../src/it/RAT-469-default/invoker.properties | 0
.../impl}/src/it/RAT-469-default/pom.xml | 0
.../impl}/src/it/RAT-469-default/verify.groovy | 2 +-
.../impl}/src/it/RAT-469/invoker.properties | 0
.../impl}/src/it/RAT-469/pom.xml | 0
.../impl}/src/it/RAT-469/verify.groovy | 2 +-
.../impl/src/it/it1}/invoker.properties | 0
.../impl}/src/it/it1/pom.xml | 0
.../impl/src/it/it1}/src.apt | 0
.../impl}/src/it/it1/verify.groovy | 2 +-
.../impl}/src/it/settings.xml | 0
.../org/apache/rat/mp/rat-report.properties | 0
.../java/org/apache/rat/mp/AbstractRatMojo.java | 0
.../impl}/src/main/java/org/apache/rat/mp/All.java | 0
.../impl}/src/main/java/org/apache/rat/mp/Any.java | 0
.../src/main/java/org/apache/rat/mp/Copyright.java | 0
.../java/org/apache/rat/mp/EnclosingMatcher.java | 0
.../src/main/java/org/apache/rat/mp/Family.java | 0
.../apache/rat/mp/HeaderMatcherSpecification.java | 0
.../src/main/java/org/apache/rat/mp/License.java | 0
.../impl}/src/main/java/org/apache/rat/mp/Not.java | 0
.../java/org/apache/rat/mp/RatCheckException.java | 0
.../main/java/org/apache/rat/mp/RatCheckMojo.java | 0
.../main/java/org/apache/rat/mp/RatReportMojo.java | 2 +-
.../src/main/java/org/apache/rat/mp/Regex.java | 0
.../src/main/java/org/apache/rat/mp/Spdx.java | 0
.../src/main/java/org/apache/rat/mp/Text.java | 0
.../main/java/org/apache/rat/mp/package-info.java | 0
.../java/org/apache/rat/plugin/package-info.java | 0
.../META-INF/m2e/lifecycle-mapping-metadata.xml | 0
.../resources/org/apache/rat/mp/package-info.java | 0
.../src/site/apt/examples/custom-license.apt.vm | 0
.../impl}/src/site/apt/examples/index.apt | 0
.../impl}/src/site/apt/examples/site.apt.vm | 0
.../impl}/src/site/apt/examples/verify.apt.vm | 0
.../impl}/src/site/fml/faq.fml | 0
.../impl}/src/site/resources/css/site.css | 0
.../impl}/src/site/site.xml | 0
.../impl}/src/templates/apt/index.apt.vm.vm | 0
.../impl}/src/templates/apt/mvn_options.apt.vm | 0
.../src/test/filtered-resources/optionTest/pom.tpl | 0
.../apache/rat/mp/BetterAbstractMojoTestCase.java | 0
.../test/java/org/apache/rat/mp/MavenOption.java | 0
.../java/org/apache/rat/mp/OptionMojoTest.java | 0
.../java/org/apache/rat/mp/RatCheckMojoTest.java | 0
.../java/org/apache/rat/mp/RatTestHelpers.java | 0
.../impl}/src/test/resources/OptionTools/One.xml | 0
.../impl}/src/test/resources/OptionTools/Two.xml | 0
.../src/test/resources/unit/RAT-107/.idea/dummy | 0
.../src/test/resources/unit/RAT-107/cobertura.ser | 0
.../impl}/src/test/resources/unit/RAT-107/pom.xml | 0
.../test/resources/unit/RAT-107/release.properties | 0
.../resources/unit/RAT-107/submodule/.idea/dummy | 0
.../resources/unit/RAT-107/submodule/cobertura.ser | 0
.../test/resources/unit/RAT-107/submodule/pom.xml | 0
.../unit/RAT-107/submodule/release.properties | 0
.../src/test/resources/unit/RAT-335}/README.txt | 0
.../src/test/resources/unit/RAT-335}/dir1/dir1.md | 0
.../src/test/resources/unit/RAT-335}/dir2/dir2.txt | 0
.../test/resources/unit/RAT-335}/dir3/file3.log | 0
.../impl/src/test/resources/unit/RAT-335}/pom.xml | 0
.../impl}/src/test/resources/unit/RAT-343/pom.xml | 0
.../impl}/src/test/resources/unit/RAT-362/bar.md | 0
.../impl}/src/test/resources/unit/RAT-362/pom.xml | 0
.../impl}/src/test/resources/unit/it1/.bzrignore | 0
.../impl}/src/test/resources/unit/it1/pom.xml | 0
.../impl}/src/test/resources/unit/it2/pom.xml | 0
.../impl}/src/test/resources/unit/it2/src.txt | 0
.../impl}/src/test/resources/unit/it3/pom.xml | 0
.../impl}/src/test/resources/unit/it3/src.apt | 0
.../src/test/resources/unit/it4/iso-8859-1.html | 0
.../impl}/src/test/resources/unit/it4/pom.xml | 0
.../test/resources/unit/it5/.rat/customConfig.xml | 0
.../impl}/src/test/resources/unit/it5/pom.xml | 0
.../main/java/nl/basjes/something/Something.java | 0
.../RAT-268 => apache-rat-plugin-parent}/pom.xml | 46 +-
.../spotbugs-ignore.xml | 0
apache-rat-plugin-parent/tools/pom.xml | 148 +
.../java/org/apache/rat/maven/MavenGenerator.java | 191 +
.../java/org/apache/rat/maven}/MavenOption.java | 4 +-
apache-rat-plugin/.gitignore | 5 -
apache-rat-plugin/src/it/it1/invoker.properties | 16 -
apache-rat-plugin/src/it/it1/src.apt | 12 -
.../src/site/apt/examples/basic.apt.vm | 46 -
.../src/test/resources/OptionTools/One.xml | 27 -
.../src/test/resources/OptionTools/Two.xml | 27 -
.../src/test/resources/unit/RAT-107/.classpath | 1 -
.../src/test/resources/unit/RAT-107/.project | 1 -
.../test/resources/unit/RAT-107/.settings/dummy | 0
.../src/test/resources/unit/RAT-107/dummy.ipr | 1 -
.../resources/unit/RAT-107/submodule/.classpath | 1 -
.../test/resources/unit/RAT-107/submodule/.project | 1 -
.../unit/RAT-107/submodule/.settings/dummy | 0
.../resources/unit/RAT-107/submodule/dummy.iml | 1 -
.../resources/unit/RAT-107/submodule/dummy.ipr | 1 -
.../resources/unit/RAT-107/submodule/dummy.iws | 1 -
.../src/test/resources/unit/RAT-335/.gitignore | 7 -
.../src/test/resources/unit/RAT-335/README.txt | 12 -
.../test/resources/unit/RAT-335/dir1/.gitignore | 3 -
.../src/test/resources/unit/RAT-335/dir1/dir1.md | 1 -
.../src/test/resources/unit/RAT-335/dir1/dir1.txt | 1 -
.../src/test/resources/unit/RAT-335/dir1/file1.log | 1 -
.../src/test/resources/unit/RAT-335/dir2/dir2.md | 1 -
.../src/test/resources/unit/RAT-335/dir2/dir2.txt | 1 -
.../src/test/resources/unit/RAT-335/dir3/dir3.log | 1 -
.../src/test/resources/unit/RAT-335/dir3/file3.log | 1 -
.../src/test/resources/unit/RAT-335/pom.xml | 44 -
.../src/test/resources/unit/RAT-335/root.md | 1 -
.../src/test/resources/unit/RAT-362/.gitignore | 2 -
.../src/test/resources/unit/RAT-362/foo.md | 1 -
.../main/java/org/apache/rat/anttasks/Help.java | 2 +-
.../.hiddenDirectory/fileInHiddenDirectory | 1 -
.../examples/exampleData/ILoggerFactory.java | 57 -
.../main/resources/examples/exampleData/Image.png | Bin 489 -> 0 bytes
.../main/resources/examples/exampleData/LICENSE | 202 -
.../src/main/resources/examples/exampleData/NOTICE | 7 -
.../resources/examples/exampleData/Source.java | 9 -
.../main/resources/examples/exampleData/Text.txt | 20 -
.../resources/examples/exampleData/TextHttps.txt | 20 -
.../main/resources/examples/exampleData/Xml.xml | 20 -
.../main/resources/examples/exampleData/buildr.rb | 44 -
.../main/resources/examples/exampleData/dummy.jar | Bin 6615 -> 0 bytes
.../resources/examples/exampleData/generated.txt | 3 -
.../main/resources/examples/exampleData/plain.json | 3 -
.../resources/examples/exampleData/sub/Empty.txt | 1 -
.../main/resources/examples/exampleData/tri.txt | 6 -
.../rat/documentation/options/AntOption.java | 1 +
.../rat/documentation/options/MavenOption.java | 1 +
apache-rat/pom.xml | 8 +-
apache-rat/spotbugs-ignore.xml | 2 +-
pom.xml | 11 +-
src/conf/checkstyle-suppressions.xml | 5 +
src/conf/spotbugs-exclude.xml | 2 +-
src/site/markdown/development/ui/options.md | 2 +-
397 files changed, 6976 insertions(+), 17235 deletions(-)
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/Image-png.not b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/Image-png.not
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/Image-png.not
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/Image-png.not
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/NOTICE b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/NOTICE
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/NOTICE
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/NOTICE
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/UTF16_with_signature.xml b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/UTF16_with_signature.xml
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/UTF16_with_signature.xml
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/UTF16_with_signature.xml
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/UTF8_with_signature.xml b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/UTF8_with_signature.xml
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/UTF8_with_signature.xml
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/UTF8_with_signature.xml
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/dummy.tar.gz b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/dummy.tar.gz
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/dummy.tar.gz
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/dummy.tar.gz
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/file.cpp b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/file.cpp
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/file.cpp
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/file.cpp
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/generated.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/generated.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/generated.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/generated.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/leader-election-message-arrives.dia b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/leader-election-message-arrives.dia
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/leader-election-message-arrives.dia
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/leader-election-message-arrives.dia
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/side_left.bmp b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/side_left.bmp
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/side_left.bmp
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/side_left.bmp
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/unix-newlines.txt.bin b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/unix-newlines.txt.bin
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/unix-newlines.txt.bin
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/unix-newlines.txt.bin
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/src/windows-newlines.txt.bin b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/windows-newlines.txt.bin
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/src/windows-newlines.txt.bin
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/src/windows-newlines.txt.bin
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_14/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_14/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_14/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_14/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_147/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_147/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_147/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_147/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_147/src/unix-newlines.txt.bin b/apache-rat-cli/src/it/resources/ReportTest/RAT_147/src/unix-newlines.txt.bin
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_147/src/unix-newlines.txt.bin
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_147/src/unix-newlines.txt.bin
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_147/src/windows-newlines.txt.bin b/apache-rat-cli/src/it/resources/ReportTest/RAT_147/src/windows-newlines.txt.bin
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_147/src/windows-newlines.txt.bin
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_147/src/windows-newlines.txt.bin
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_147/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_147/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_147/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_147/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_211/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_211/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_211/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_211/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_211/src/leader-election-message-arrives.dia b/apache-rat-cli/src/it/resources/ReportTest/RAT_211/src/leader-election-message-arrives.dia
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_211/src/leader-election-message-arrives.dia
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_211/src/leader-election-message-arrives.dia
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_211/src/side_left.bmp b/apache-rat-cli/src/it/resources/ReportTest/RAT_211/src/side_left.bmp
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_211/src/side_left.bmp
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_211/src/side_left.bmp
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_211/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_211/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_211/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_211/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_246/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_246/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_246/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_246/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_246/notes.md b/apache-rat-cli/src/it/resources/ReportTest/RAT_246/notes.md
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_246/notes.md
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_246/notes.md
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_246/src/dir1/FileToProcess b/apache-rat-cli/src/it/resources/ReportTest/RAT_246/src/dir1/FileToProcess
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_246/src/dir1/FileToProcess
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_246/src/dir1/FileToProcess
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_246/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_246/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_246/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_246/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/ILoggerFactory.java b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/ILoggerFactory.java
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/ILoggerFactory.java
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/ILoggerFactory.java
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Image.png b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Image.png
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Image.png
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Image.png
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/LICENSE b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/LICENSE
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/LICENSE
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/LICENSE
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/NOTICE b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/NOTICE
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/NOTICE
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/NOTICE
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Source.java b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Source.java
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Source.java
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Source.java
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Text.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Text.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Text.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Text.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/TextHttps.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/TextHttps.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/TextHttps.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/TextHttps.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Xml.xml b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Xml.xml
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/Xml.xml
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/Xml.xml
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/buildr.rb b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/buildr.rb
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/buildr.rb
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/buildr.rb
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/dummy.jar b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/dummy.jar
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/dummy.jar
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/dummy.jar
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/generated.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/generated.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/generated.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/generated.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/plain.json b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/plain.json
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/plain.json
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/plain.json
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/sub/Empty.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/sub/Empty.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/sub/Empty.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/sub/Empty.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/tri.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/tri.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/elements/tri.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/elements/tri.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/list.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/list.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/list.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/list.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_259/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_259/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_259/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_259/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/expected-message.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/expected-message.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/expected-message.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/expected-message.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/pom.xml b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/pom.xml
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/pom.xml
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/pom.xml
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/README.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/README.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/src/README.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/README.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.md b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.md
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.md
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.md
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir3/file3.log b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir3/file3.log
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir3/file3.log
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/src/dir3/file3.log
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_335/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_335/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_335/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_362/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_362/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_362/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/expected-message.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_362/expected-message.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_362/expected-message.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_362/expected-message.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_362/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_362/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_362/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_406/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_406/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_406/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_406/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_406/expected-message.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_406/expected-message.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_406/expected-message.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_406/expected-message.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_406/src/dojo/dojo.java b/apache-rat-cli/src/it/resources/ReportTest/RAT_406/src/dojo/dojo.java
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_406/src/dojo/dojo.java
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_406/src/dojo/dojo.java
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_408/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_408/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_408/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_408/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_408/expected-message.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_408/expected-message.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_408/expected-message.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_408/expected-message.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_408/src/karapace/anonymize_schemas/_init_.py b/apache-rat-cli/src/it/resources/ReportTest/RAT_408/src/karapace/anonymize_schemas/_init_.py
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_408/src/karapace/anonymize_schemas/_init_.py
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_408/src/karapace/anonymize_schemas/_init_.py
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_455/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_455/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_455/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_455/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_455/src/GPL.md b/apache-rat-cli/src/it/resources/ReportTest/RAT_455/src/GPL.md
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_455/src/GPL.md
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_455/src/GPL.md
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_455/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_455/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_455/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_455/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_457/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_457/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_457/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_457/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_457/src/apache-rat-0.17-SNAPSHOT.jar b/apache-rat-cli/src/it/resources/ReportTest/RAT_457/src/apache-rat-0.17-SNAPSHOT.jar
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_457/src/apache-rat-0.17-SNAPSHOT.jar
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_457/src/apache-rat-0.17-SNAPSHOT.jar
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_457/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_457/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_457/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_457/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_458/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_458/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_458/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_458/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_458/src/README.md b/apache-rat-cli/src/it/resources/ReportTest/RAT_458/src/README.md
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_458/src/README.md
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_458/src/README.md
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_458/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_458/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_458/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_458/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_469/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_469/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_469/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_469/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_469/src/GPLTestClass.java b/apache-rat-cli/src/it/resources/ReportTest/RAT_469/src/GPLTestClass.java
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_469/src/GPLTestClass.java
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_469/src/GPLTestClass.java
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_469/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_469/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_469/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_500/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_500/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_500/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_500/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_500/output.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_500/output.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_500/output.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_500/output.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_81/commandLine.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_81/commandLine.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_81/commandLine.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_81/commandLine.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_81/src/IBM037.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_81/src/IBM037.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_81/src/IBM037.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_81/src/IBM037.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_81/src/UTF8.txt b/apache-rat-cli/src/it/resources/ReportTest/RAT_81/src/UTF8.txt
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_81/src/UTF8.txt
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_81/src/UTF8.txt
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy b/apache-rat-cli/src/it/resources/ReportTest/RAT_81/verify.groovy
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy
rename to apache-rat-cli/src/it/resources/ReportTest/RAT_81/verify.groovy
diff --git a/apache-rat-core/src/it/resources/ReportTest/readme.md b/apache-rat-cli/src/it/resources/ReportTest/readme.md
similarity index 100%
rename from apache-rat-core/src/it/resources/ReportTest/readme.md
rename to apache-rat-cli/src/it/resources/ReportTest/readme.md
diff --git a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/CLIOption.java b/apache-rat-cli/src/main/java/org.apache.rat.cli/CLIOption.java
similarity index 97%
rename from apache-rat-tools/src/main/java/org/apache/rat/documentation/options/CLIOption.java
rename to apache-rat-cli/src/main/java/org.apache.rat.cli/CLIOption.java
index fc00e5e1..5a644f5b 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/CLIOption.java
+++ b/apache-rat-cli/src/main/java/org.apache.rat.cli/CLIOption.java
@@ -16,10 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.rat.documentation.options;
+package org.apache.rat.cli;
import org.apache.commons.cli.Option;
import org.apache.commons.lang3.StringUtils;
+import org.apache.rat.ui.AbstractOption;
public class CLIOption extends AbstractOption {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/Report.java b/apache-rat-cli/src/main/java/org.apache.rat.cli/Report.java
similarity index 61%
rename from apache-rat-core/src/main/java/org/apache/rat/Report.java
rename to apache-rat-cli/src/main/java/org.apache.rat.cli/Report.java
index 5f5f4cb3..bff6e7e1 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Report.java
+++ b/apache-rat-cli/src/main/java/org.apache.rat.cli/Report.java
@@ -16,14 +16,20 @@
* specific language governing permissions and limitations *
* under the License. *
*/
-package org.apache.rat;
+package org.apache.rat.cli;
import java.io.File;
import org.apache.commons.cli.Options;
+import org.apache.rat.OptionCollection;
+import org.apache.rat.ReportConfiguration;
+import org.apache.rat.Reporter;
+import org.apache.rat.VersionInfo;
import org.apache.rat.document.RatDocumentAnalysisException;
import org.apache.rat.help.Help;
+import org.apache.rat.report.claim.ClaimStatistic;
import org.apache.rat.utils.DefaultLog;
+import org.w3c.dom.Document;
import static java.lang.String.format;
@@ -40,7 +46,8 @@ public final class Report {
* @throws Exception on error.
*/
public static void main(final String[] args) throws Exception {
- DefaultLog.getInstance().info(new VersionInfo().toString());
+ DefaultLog.getInstance().info(String.format("%s on %s",
+ new VersionInfo(Report.class), new VersionInfo(Reporter.class)));
if (args == null || args.length == 0) {
DefaultLog.getInstance().info("Please use the \"--help\" option to see a " +
@@ -48,19 +55,14 @@ public final class Report {
System.exit(0);
}
- ReportConfiguration configuration = OptionCollection.parseCommands(new File("."), args, Report::printUsage);
- if (configuration != null) {
- configuration.validate(DefaultLog.getInstance()::error);
- Reporter reporter = new Reporter(configuration);
- reporter.output();
- reporter.writeSummary(DefaultLog.getInstance().asWriter());
+ CLIOutput result = generateReport(new File("."), args);
+ result.output.writeSummary(DefaultLog.getInstance().asWriter());
- if (configuration.getClaimValidator().hasErrors()) {
- configuration.getClaimValidator().logIssues(reporter.getClaimsStatistic());
- throw new RatDocumentAnalysisException(format("Issues with %s",
- String.join(", ",
- configuration.getClaimValidator().listIssues(reporter.getClaimsStatistic()))));
- }
+ if (result.configuration.getClaimValidator().hasErrors()) {
+ result.configuration.getClaimValidator().logIssues(result.output.getStatistic());
+ throw new RatDocumentAnalysisException(format("Issues with %s",
+ String.join(", ",
+ result.configuration.getClaimValidator().listIssues(result.output.getStatistic()))));
}
}
@@ -72,7 +74,28 @@ public final class Report {
new Help(System.out).printUsage(opts);
}
+ static CLIOutput generateReport(File workingDirectory, String[] args) throws Exception {
+ Reporter.Output output = null;
+ ReportConfiguration configuration = OptionCollection.parseCommands(workingDirectory, args, Report::printUsage);
+ if (configuration != null) {
+ configuration.validate(DefaultLog.getInstance()::error);
+ Reporter reporter = new Reporter(configuration);
+ output = reporter.execute();
+ }
+ return new CLIOutput(configuration, output);
+ }
+
private Report() {
// do not instantiate
}
+
+ static class CLIOutput {
+ Reporter.Output output;
+ ReportConfiguration configuration;
+
+ CLIOutput(ReportConfiguration configuration, Reporter.Output output) {
+ this.output = output;
+ this.configuration = configuration;
+ }
+ }
}
diff --git a/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportOptionsTest.java b/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportOptionsTest.java
new file mode 100644
index 00000000..4b878e00
--- /dev/null
+++ b/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportOptionsTest.java
@@ -0,0 +1,68 @@
+package org.apache.rat.cli;
+
+import java.nio.file.Path;
+import java.util.stream.Stream;
+
+import org.apache.rat.api.RatException;
+import org.apache.rat.testhelpers.FileUtils;
+import org.apache.rat.testhelpers.data.OptionTestDataProvider;
+
+import org.apache.rat.testhelpers.data.TestData;
+import org.apache.rat.testhelpers.data.ValidatorData;
+import org.junit.jupiter.api.AfterEach;
+
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+
+public class ReportOptionsTest {
+ @TempDir
+ static Path testPath;
+
+ private static final OptionTestDataProvider optionTestDataProvider = new OptionTestDataProvider();
+
+ /**
+ * This method is a known workaround for
+ * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit 5 issue #2811</a> }.
+ */
+ @AfterEach
+ @EnabledOnOs(OS.WINDOWS)
+ void cleanUp() {
+ System.gc();
+ }
+
+
+ static Stream<Arguments> getTestData() {
+ return optionTestDataProvider.getUITestMap().values().stream().map(testData ->
+ Arguments.of(testData.getTestName(), testData));
+ // TODO add help test
+ }
+
+ /**
+ * A parameterized test for the options.
+ * @param name The name of the test.
+ */
+ @ParameterizedTest( name = "{index} {0}")
+ @MethodSource("getTestData")
+ void testOptionsUpdateConfig(String name, TestData test) throws Exception {
+ Path basePath = testPath.resolve(test.getTestName());
+ FileUtils.mkDir(basePath.toFile());
+ test.setupFiles(basePath);
+ if (test.getExpectedException() != null) {
+ assertThatThrownBy(() -> Report.generateReport(basePath.toFile(), test.getCommandLine(basePath.toString()))
+ ).hasMessageContaining(test.getExpectedException().getMessage());
+ } else {
+ Report.CLIOutput result = Report.generateReport(basePath.toFile(), test.getCommandLine(basePath.toString()));
+ ValidatorData data = new ValidatorData(
+ result.output, result.configuration, basePath.toString());
+ test.getValidator().accept(data);
+ }
+ }
+}
diff --git a/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportTest.java b/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportTest.java
new file mode 100644
index 00000000..2dcfea7d
--- /dev/null
+++ b/apache-rat-cli/src/test/java/org/apache/rat/cli/ReportTest.java
@@ -0,0 +1,64 @@
+package org.apache.rat.cli;
+
+import java.nio.file.Path;
+import java.util.stream.Stream;
+import org.apache.rat.testhelpers.FileUtils;
+import org.apache.rat.testhelpers.data.OptionTestDataProvider;
+import org.apache.rat.testhelpers.data.ReportTestDataProvider;
+import org.apache.rat.testhelpers.data.TestData;
+import org.apache.rat.testhelpers.data.ValidatorData;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.condition.EnabledOnOs;
+import org.junit.jupiter.api.condition.OS;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+
+public class ReportTest {
+ @TempDir
+ static Path testPath;
+
+ private static final ReportTestDataProvider reportTestDataProvider = new ReportTestDataProvider();
+
+ /**
+ * This method is a known workaround for
+ * {@link <a href="https://github.com/junit-team/junit5/issues/2811">junit 5 issue #2811</a> }.
+ */
+ @AfterEach
+ @EnabledOnOs(OS.WINDOWS)
+ void cleanUp() {
+ System.gc();
+ }
+
+
+ static Stream<Arguments> getTestData() {
+ return reportTestDataProvider.getOptionTestMap().values().stream().map(testData ->
+ Arguments.of(testData.getTestName(), testData));
+ // TODO add help test
+ }
+
+ /**
+ * A parameterized test for the options.
+ * @param name The name of the test.
+ */
+ @ParameterizedTest( name = "{index} {0}")
+ @MethodSource("getTestData")
+ void testOptionsUpdateConfig(String name, TestData test) throws Exception {
+ Path basePath = testPath.resolve(test.getTestName());
+ FileUtils.mkDir(basePath.toFile());
+ test.setupFiles(basePath);
+ if (test.getExpectedException() != null) {
+ assertThatThrownBy(() -> Report.generateReport(basePath.toFile(), test.getCommandLine(basePath.toString()))
+ ).hasMessageContaining(test.getExpectedException().getMessage());
+ } else {
+ Report.CLIOutput result = Report.generateReport(basePath.toFile(), test.getCommandLine(basePath.toString()));
+ ValidatorData data = new ValidatorData(
+ result.output, result.configuration, basePath.toString());
+ test.getValidator().accept(data);
+ }
+ }
+}
diff --git a/apache-rat-core/pom.xml b/apache-rat-core/pom.xml
index 8237d8eb..61bbfa49 100644
--- a/apache-rat-core/pom.xml
+++ b/apache-rat-core/pom.xml
@@ -50,9 +50,6 @@
<!-- exclude test generation files that contain unapproved license text -->
<exclude>**/ReporterOptionsProvider.java</exclude>
<exclude>**/GPLLicenseTest.java</exclude>
- <!-- These files have bad license headers because they are used to test bad license headers -->
- <exclude>src/test/resources/**</exclude>
- <exclude>src/it/resources/ReportTest/**</exclude>
</inputExcludes>
</configuration>
</plugin>
@@ -62,13 +59,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>test-jar</goal>
- </goals>
- </execution>
- </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -155,30 +145,55 @@
</resources>
</configuration>
</execution>
- <execution>
- <id>copy-example-data</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.testOutputDirectory}/examples</outputDirectory>
- <overwrite>true</overwrite>
- <resources>
- <resource>
- <directory>../apache-rat-testdata/src/main/resources/examples</directory>
- </resource>
- </resources>
- </configuration>
- </execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-testdata</artifactId>
+ <groupId>org.apache.velocity</groupId>
+ <artifactId>velocity-engine-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.reflections</groupId>
+ <artifactId>reflections</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- <dependency>-->
+ <!-- <groupId>org.junit.vintage</groupId>-->
+ <!-- <artifactId>junit-vintage-engine</artifactId>-->
+ <!-- <scope>compile</scope>-->
+
+ <!-- </dependency>-->
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-params</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- this dependency is actually used by integration testing code -->
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.jimfs</groupId>
+ <artifactId>jimfs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
@@ -208,35 +223,10 @@
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
</dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-params</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-core</artifactId>
@@ -245,16 +235,5 @@
<groupId>org.apache.tika</groupId>
<artifactId>tika-parser-text-module</artifactId>
</dependency>
- <dependency>
- <!-- this dependency is actually used by integration testing code -->
- <groupId>org.codehaus.groovy</groupId>
- <artifactId>groovy-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.jimfs</groupId>
- <artifactId>jimfs</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
diff --git a/apache-rat-core/spotbugs-ignore.xml b/apache-rat-core/spotbugs-ignore.xml
index fc94fe36..bf78a086 100644
--- a/apache-rat-core/spotbugs-ignore.xml
+++ b/apache-rat-core/spotbugs-ignore.xml
@@ -20,7 +20,7 @@
<!--
Convenience constructors that allow setting a charset are not available in Java8 for PrintStream.
-->
- <Class name="org.apache.rat.Report"/>
+ <Class name="org.apache.rat.cli.Report"/>
<Bug pattern="DM_DEFAULT_ENCODING"/>
</Match>
diff --git a/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java b/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
deleted file mode 100644
index d29f0781..00000000
--- a/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * 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;
-
-import groovy.lang.GroovyShell;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Stream;
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.io.IOCase;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.filefilter.AbstractFileFilter;
-import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.commons.io.filefilter.NameFileFilter;
-import org.apache.commons.io.filefilter.OrFileFilter;
-import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
-import org.apache.rat.commandline.Arg;
-import org.apache.rat.document.DocumentName;
-import org.apache.rat.document.DocumentNameMatcher;
-import org.apache.rat.document.FileDocument;
-import org.apache.rat.document.RatDocumentAnalysisException;
-import org.apache.rat.report.RatReport;
-import org.apache.rat.utils.DefaultLog;
-import org.apache.rat.utils.Log;
-import org.apache.rat.walker.DirectoryWalker;
-import org.codehaus.groovy.control.CompilerConfiguration;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.fail;
-
-/**
- * Integration tests for the {@link Report} class.
- * Integration tests must have a specific structure.
- * <ul>
- * <li>They are in directories under {@code src/it/resources/ReportText/X} where {@code X} is the name of the test. Usually
- * a reference to a reported bug.</li>
- * <li>Within the directory is a file named {@code commandLine.txt}. Each line in the file is a single command line
- * token. For example "--output-style XML" would be 2 lines in the file "--output-style" and "XML"</li>
- * <li>Within the directory there is a subdirectory named {@code src}. This is the root of the file system for RAT to scan.</li>
- * <li>There may be a {@code notes.md} describing the test</li>
- * <li>There is a {@code verify.groovy} script. When executed:
- * <ul>
- * <li>The first parameter will be then name of the file that captured the output.</li>
- * <li>The second parameter will be the name of the file that captured the log.</li>
- * <li>Any assert that fails within the Groovy script will fail the test.</li>
- * <li>Any value returned from the script execution will fail the test and the returned value will be
- * used as the failure message.</li>
- * </ul>
- * </li>
- * <li>If an exception is expected when Report is run with the command line a file named {@code expected-message.txt}
- * must be present in the directory. It must contain text that is expected to be found within the message
- * associated with the exception.</li>
- * </ul>
- */
-public class ReportTest {
-
- private String[] asArgs(final List<String> argsList) {
- return argsList.toArray(new String[0]);
- }
-
- @ParameterizedTest(name = "{index} {0}")
- @MethodSource("args")
- public void integrationTest(String testName, Document commandLineDoc) throws Exception {
- DefaultLog.getInstance().log(Log.Level.INFO, "Running test for " + testName);
- File baseDir = new File(commandLineDoc.getName().getName()).getParentFile();
-
- // get the arguments
- List<String> argsList = IOUtils.readLines(commandLineDoc.reader());
-
- CommandLine commandLine = DefaultParser.builder().setDeprecatedHandler(DeprecationReporter.getLogReporter())
- .setAllowPartialMatching(true).build().parse(Arg.getOptions(), asArgs(argsList));
-
- File outputFile = new File(baseDir,"output.txt");
- if (!commandLine.hasOption(Arg.OUTPUT_FILE.option())) {
- argsList.add(0, "--" + Arg.OUTPUT_FILE.option().getLongOpt());
- argsList.add(1, outputFile.getAbsolutePath());
- } else {
- outputFile = new File(baseDir, commandLine.getOptionValue(Arg.OUTPUT_FILE.option()));
- }
-
- File logFile = new File(baseDir,"log.txt");
- FileLog fileLog = new FileLog(logFile);
- Log oldLog = null;
- try {
- oldLog = DefaultLog.setInstance(fileLog);
-
- File src = new File(baseDir, "src");
- if (src.isDirectory()) {
- argsList.add(src.getAbsolutePath());
- }
-
- File expectedMsg = new File(baseDir, "expected-message.txt");
- if (expectedMsg.exists()) {
- String msg = IOUtils.readLines(new FileReader(expectedMsg)).get(0).trim();
- assertThrows(RatDocumentAnalysisException.class, () -> Report.main(asArgs(argsList)),
- msg);
- } else {
- Report.main(asArgs(argsList));
- }
- } finally {
- DefaultLog.setInstance(oldLog);
- fileLog.close();
- }
-
- File groovyScript = new File(baseDir, "verify.groovy");
- if (groovyScript.exists()) {
- // call groovy expressions from Java code
- CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
-
- GroovyShell shell = new GroovyShell(compilerConfiguration);
- for (String classPath : System.getProperty("java.class.path").split(File.pathSeparator)) {
- shell.getClassLoader().addClasspath(classPath);
- }
- try {
- Object value = shell.run(groovyScript, new String[]{outputFile.getAbsolutePath(), logFile.getAbsolutePath()});
- if (value != null) {
- fail(String.format("%s", value));
- }
- } catch (AssertionError e) {
- throw new AssertionError(String.format("%s: %s", testName, e.getMessage()), e);
- }
- }
- }
-
- static Stream<Arguments> args() throws RatException {
- List<Arguments> results = new ArrayList<>();
- URL url = ReportTest.class.getResource("/ReportTest");
-
- String urlAsFile;
- try {
- urlAsFile = Paths.get(url.toURI()).toString();
- } catch (URISyntaxException e) {
- throw new RatException("Unable to find root directory for " + url, e);
- }
-
- File baseDir = new File(urlAsFile);
- DocumentName docName = DocumentName.builder(baseDir).build();
- AbstractFileFilter fileFilter = new NameFileFilter("commandLine.txt", docName.isCaseSensitive() ? IOCase.SENSITIVE : IOCase.INSENSITIVE);
- fileFilter = new OrFileFilter(fileFilter, DirectoryFileFilter.INSTANCE);
-
- Document document = new FileDocument(docName, baseDir, new DocumentNameMatcher(fileFilter));
- DirectoryWalker walker = new DirectoryWalker(document);
- RatReport report = new RatReport() {
- @Override
- public void report(Document document) {
- if (!document.isIgnored()) {
- String[] tokens = DocumentName.FSInfo.getDefault().tokenize(document.getName().localized());
- results.add(Arguments.of(tokens[1], document));
- }
- }
- };
- walker.run(report);
- return results.stream();
- }
-
- /**
- * Log that captures output for later review.
- */
- public static class FileLog implements Log {
-
- private final PrintStream logFile;
-
- /**
- * The level at which we will write messages
- */
- private Level level;
-
- FileLog(File logFile) throws IOException {
- this.logFile = new PrintStream(logFile);
- level = Level.INFO;
- }
-
- /**
- * Sets the level.Log messages below the specified level will
- * not be written to the log.
- *
- * @param level the level to use when writing messages.
- */
- public void setLevel(final Level level) {
- this.level = level;
- }
-
- @Override
- public Level getLevel() {
- return level;
- }
-
- @Override
- public void log(Level level, String msg) {
- if (isEnabled(level)) {
- logFile.printf("%s: %s%n", level, msg);
- }
- }
-
- public void close() {
- logFile.close();
- }
- }
-}
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/.gitignore b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/.gitignore
deleted file mode 100644
index 83f3639d..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/.gitignore
+++ /dev/null
@@ -1,8 +0,0 @@
-*.md
-
-# This makes it ignore dir3/dir3.log and dir3/file3.log
-*.log
-
-# This makes it "unignore" dir3/file3.log but dir1/file1.log should still be ignored
-# because of the specific unignore int dir1.
-!file*.log
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/.gitignore b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/.gitignore
deleted file mode 100644
index e5072ead..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.txt
-!dir1.md
-# this should override the "dont ignore file*.log" in the root .gitignore
-file1.log
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.txt b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.txt
deleted file mode 100644
index a31cbc89..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/dir1.txt
+++ /dev/null
@@ -1 +0,0 @@
-File without a valid license
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/file1.log b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/file1.log
deleted file mode 100644
index a31cbc89..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir1/file1.log
+++ /dev/null
@@ -1 +0,0 @@
-File without a valid license
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.md b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.md
deleted file mode 100644
index a31cbc89..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir2/dir2.md
+++ /dev/null
@@ -1 +0,0 @@
-File without a valid license
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir3/dir3.log b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir3/dir3.log
deleted file mode 100644
index a31cbc89..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/dir3/dir3.log
+++ /dev/null
@@ -1 +0,0 @@
-File without a valid license
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/root.md b/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/root.md
deleted file mode 100644
index a31cbc89..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_335/src/root.md
+++ /dev/null
@@ -1 +0,0 @@
-File without a valid license
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/.gitignore b/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/.gitignore
deleted file mode 100644
index e994dfc1..00000000
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/foo.md
-/src.md
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/foo.md b/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/foo.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/src.md b/apache-rat-core/src/it/resources/ReportTest/RAT_362/src/src.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/apache-rat-core/src/main/java/org/apache/rat/Defaults.java b/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
index 87c7ed8d..7f4b2bcb 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
@@ -62,7 +62,6 @@ public final class Defaults {
/** The license set factory to build license sets based upon default options */
private final LicenseSetFactory setFactory;
- // TODO look at this static block with respect to the init() static method and figure out if we need both.
static {
URL url = Defaults.class.getResource(DEFAULT_CONFIG_PATH);
URI uri = null;
diff --git a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
index 7a993cb9..2e77a957 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
@@ -23,10 +23,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
-import java.util.Map;
-import java.util.TreeMap;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -71,26 +68,6 @@ public final class OptionCollection {
/** The Help option */
public static final Option HELP = new Option("?", "help", false, "Print help for the RAT command line interface and exit.");
- /** A mapping of {@code argName(value)} values to a description of those values. */
- @Deprecated
- private static final Map<String, Supplier<String>> ARGUMENT_TYPES;
- static {
- ARGUMENT_TYPES = new TreeMap<>();
- for (ArgumentType argType : ArgumentType.values()) {
- ARGUMENT_TYPES.put(argType.getDisplayName(), argType.description);
- }
- }
-
- /**
- * Gets the mapping of {@code argName(value)} values to a description of those values.
- * @return the mapping of {@code argName(value)} values to a description of those values.
- * @deprecated use {@link ArgumentType}
- */
- @Deprecated
- public static Map<String, Supplier<String>> getArgumentTypes() {
- return Collections.unmodifiableMap(ARGUMENT_TYPES);
- }
-
/**
* Join a collection of objects together as a comma separated list of their string values.
* @param args the objects to join together.
@@ -108,11 +85,32 @@ public final class OptionCollection {
* @param helpCmd the help command to run when necessary.
* @return a ReportConfiguration or {@code null} if Help was printed.
* @throws IOException on error.
+ * @throws ParseException on option parsing error.
*/
- public static ReportConfiguration parseCommands(final File workingDirectory, final String[] args, final Consumer<Options> helpCmd) throws IOException {
+ public static ReportConfiguration parseCommands(final File workingDirectory, final String[] args, final Consumer<Options> helpCmd)
+ throws IOException, ParseException {
return parseCommands(workingDirectory, args, helpCmd, false);
}
+ /**
+ * Parse the options into the command line.
+ * @param opts the option definitions.
+ * @param args the argument to apply the definitions to.
+ * @return the CommandLine
+ * @throws ParseException on option parsing error.
+ */
+ //@VisibleForTesting
+ static CommandLine parseCommandLine(final Options opts, final String[] args) throws ParseException {
+ try {
+ return DefaultParser.builder().setDeprecatedHandler(DeprecationReporter.getLogReporter())
+ .setAllowPartialMatching(true).build().parse(opts, args);
+ } catch (ParseException e) {
+ DefaultLog.getInstance().error(e.getMessage());
+ DefaultLog.getInstance().error("Please use the \"--help\" option to see a list of valid commands and options.", e);
+ throw e;
+ }
+ }
+
/**
* Parses the standard options to create a ReportConfiguration.
*
@@ -122,22 +120,13 @@ public final class OptionCollection {
* @param noArgs If {@code true} then the commands do not need extra arguments.
* @return a ReportConfiguration or {@code null} if Help was printed.
* @throws IOException on error.
+ * @throws ParseException on option parsing error.
*/
public static ReportConfiguration parseCommands(final File workingDirectory, final String[] args,
- final Consumer<Options> helpCmd, final boolean noArgs) throws IOException {
+ final Consumer<Options> helpCmd, final boolean noArgs) throws IOException, ParseException {
Options opts = buildOptions();
- CommandLine commandLine;
- try {
- commandLine = DefaultParser.builder().setDeprecatedHandler(DeprecationReporter.getLogReporter())
- .setAllowPartialMatching(true).build().parse(opts, args);
- } catch (ParseException e) {
- DefaultLog.getInstance().error(e.getMessage());
- DefaultLog.getInstance().error("Please use the \"--help\" option to see a list of valid commands and options.", e);
- System.exit(1);
- return null; // dummy return (won't be reached) to avoid Eclipse complaint about possible NPE
- // for "commandLine"
- }
+ CommandLine commandLine = parseCommandLine(buildOptions(), args);
Arg.processLogLevel(commandLine);
@@ -177,13 +166,6 @@ public final class OptionCollection {
argumentContext.processArgs();
final ReportConfiguration configuration = argumentContext.getConfiguration();
final CommandLine commandLine = argumentContext.getCommandLine();
- if (Arg.DIR.isSelected()) {
- try {
- configuration.addSource(getReportable(commandLine.getParsedOptionValue(Arg.DIR.getSelected()), configuration));
- } catch (ParseException e) {
- throw new ConfigurationException("Unable to set parse " + Arg.DIR.getSelected(), e);
- }
- }
for (String s : commandLine.getArgs()) {
IReportable reportable = getReportable(new File(s), configuration);
if (reportable != null) {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java b/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
index a927b7c0..0c439730 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
@@ -39,6 +39,7 @@ import java.util.SortedSet;
import java.util.function.Consumer;
import org.apache.commons.io.function.IOSupplier;
+import org.apache.commons.io.output.CloseShieldOutputStream;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.commandline.StyleSheets;
import org.apache.rat.config.AddLicenseHeaders;
@@ -495,7 +496,6 @@ public class ReportConfiguration {
* closed consider wrapping it in a {@code NoCloseOutputStream}
* @param out The OutputStream supplier that provides the output stream to write
* the report to. A null value will use System.out.
- * @see NoCloseOutputStream
*/
public void setOut(final IOSupplier<OutputStream> out) {
this.out = out;
@@ -530,7 +530,7 @@ public class ReportConfiguration {
* @return The supplier of the output stream to write the report to.
*/
public IOSupplier<OutputStream> getOutput() {
- return out == null ? () -> new NoCloseOutputStream(System.out) : out;
+ return out == null ? () -> CloseShieldOutputStream.wrap(System.out) : out;
}
/**
@@ -830,63 +830,4 @@ public class ReportConfiguration {
}
}
- /**
- * A wrapper around an output stream that does not close the output stream.
- */
- public static class NoCloseOutputStream extends OutputStream {
- /** the output stream this stream wraps */
- private final OutputStream delegate;
-
- /**
- * Constructor.
- * @param delegate the output stream to wrap.
- */
- public NoCloseOutputStream(final OutputStream delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public void write(final int arg0) throws IOException {
- delegate.write(arg0);
- }
-
- /**
- * Does not actually close the delegate. But does perform a flush.
- * @throws IOException on Error.
- */
- @Override
- public void close() throws IOException {
- this.delegate.flush();
- }
-
- @Override
- public boolean equals(final Object obj) {
- return delegate.equals(obj);
- }
-
- @Override
- public void flush() throws IOException {
- delegate.flush();
- }
-
- @Override
- public int hashCode() {
- return delegate.hashCode();
- }
-
- @Override
- public String toString() {
- return delegate.toString();
- }
-
- @Override
- public void write(final byte[] arg0, final int arg1, final int arg2) throws IOException {
- delegate.write(arg0, arg1, arg2);
- }
-
- @Override
- public void write(final byte[] b) throws IOException {
- delegate.write(b);
- }
- }
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/Reporter.java b/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
index ec32f340..98e35e34 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/Reporter.java
@@ -18,14 +18,12 @@
*/
package org.apache.rat;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.io.Writer;
+import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -46,6 +44,7 @@ import org.apache.rat.report.xml.XmlReportFactory;
import org.apache.rat.report.xml.writer.IXmlWriter;
import org.apache.rat.report.xml.writer.XmlWriter;
import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
/**
* Class that executes the report as defined in a {@link ReportConfiguration} and stores
@@ -56,15 +55,14 @@ public class Reporter {
/** Format used for listing licenses. */
private static final String LICENSE_FORMAT = "%s:\t%s%n\t\t%s%n";
- /** The XML output document */
- private Document document;
-
- /** Statistics generated as the report was built */
- private ClaimStatistic statistic;
-
/** The configuration for the report */
private final ReportConfiguration configuration;
+ /**
+ * The output from the execution.
+ */
+ private Output output;
+
/**
* Create the reporter.
*
@@ -76,84 +74,38 @@ public class Reporter {
/**
* Executes the report and builds the output.
- * This method will build the internal XML document if it does not already exist.
- * If this method or either of the {@link #output()} methods have already been called this method will return
- * the previous results.
- * @return the claim statistics.
+ * @return the Output object.
* @throws RatException on error.
*/
- public ClaimStatistic execute() throws RatException {
- if (document == null || statistic == null) {
- try {
- if (configuration.hasSource()) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- Writer outputWriter = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8);
- try (IXmlWriter writer = new XmlWriter(outputWriter)) {
- statistic = new ClaimStatistic();
- RatReport report = XmlReportFactory.createStandardReport(writer, statistic, configuration);
- report.startReport();
- configuration.getSources().build().run(report);
- report.endReport();
-
- InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
- document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
- }
- } else {
- document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- statistic = new ClaimStatistic();
+ public Output execute() throws RatException {
+ try {
+ if (configuration.hasSource()) {
+ StringBuilder sb = new StringBuilder();
+ try (IXmlWriter writer = new XmlWriter(sb)) {
+ writer.startDocument();
+ ClaimStatistic statistic = new ClaimStatistic();
+ RatReport report = XmlReportFactory.createStandardReport(writer, statistic, configuration);
+ report.startReport();
+ configuration.getSources().build().run(report);
+ report.endReport();
+ InputSource inputSource = new InputSource(new StringReader(sb.toString()));
+ output = new Output(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputSource), statistic);
}
- } catch (Exception e) {
- throw RatException.makeRatException(e);
+ } else {
+ output = new Output(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
}
+ } catch (Exception e) {
+ throw RatException.makeRatException(e);
}
- return statistic;
- }
-
- /**
- * Get the claim statistics from the run.
- *
- * @return the claim statistics.
- */
- public ClaimStatistic getClaimsStatistic() {
- return statistic;
+ return output;
}
/**
- * Outputs the report using the stylesheet and output specified in the configuration.
- * @return the Claim statistic from the run.
- * @throws RatException on error.
+ * Gets the output from the last {@link #execute} call or {@code null} if {@link #execute} has not been called.
+ * @return the output
*/
- public ClaimStatistic output() throws RatException {
- return output(configuration.getStyleSheet(), configuration.getOutput());
- }
-
- /**
- * Outputs the report to the specified output using the stylesheet. It is safe to call this method more than once
- * in order to generate multiple reports from the same run.
- *
- * @param stylesheet the style sheet to use for XSLT formatting.
- * @param output the output stream to write to.
- * @return the Claim statistic for the run.
- * @throws RatException on error.
- */
- public ClaimStatistic output(final IOSupplier<InputStream> stylesheet, final IOSupplier<OutputStream> output) throws RatException {
- ClaimStatistic result = execute();
- TransformerFactory tf = TransformerFactory.newInstance();
- Transformer transformer;
- try (OutputStream out = output.get();
- InputStream styleIn = stylesheet.get()) {
- transformer = tf.newTransformer(new StreamSource(styleIn));
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(document),
- new StreamResult(new OutputStreamWriter(out, StandardCharsets.UTF_8)));
- return result;
- } catch (TransformerException | IOException e) {
- throw new RatException(e);
- }
+ public Output getOutput() {
+ return output;
}
/**
@@ -172,25 +124,98 @@ public class Reporter {
}
}
+
/**
- * Writes a text summary of issues with the run.
- * @param appendable the appendable to write to.
- * @throws IOException on error.
+ * The output from a report run.
*/
- public void writeSummary(final Appendable appendable) throws IOException {
- appendable.append("RAT summary:").append(System.lineSeparator());
- for (ClaimStatistic.Counter counter : ClaimStatistic.Counter.values()) {
- appendable.append(" ").append(counter.displayName()).append(": ")
- .append(Integer.toString(getClaimsStatistic().getCounter(counter)))
- .append(System.lineSeparator());
+ public static class Output {
+ /** The XML output document */
+ private final Document document;
+ /**
+ * The claim staticsic from the execution that generated the document.
+ * May be empty if the Document was read from disk.
+ */
+ private final ClaimStatistic statistic;
+
+ /**
+ * Create an output with an empty statistics.
+ * @param document the Document from the output.
+ */
+ public Output(final Document document) {
+ this(document, new ClaimStatistic());
+ }
+
+ /**
+ * Create an output with statistics.
+ * @param document the Document from the execution.
+ * @param statistic the statistics from the execution.
+ */
+ public Output(final Document document, final ClaimStatistic statistic) {
+ this.document = document;
+ this.statistic = statistic;
+ }
+
+ /**
+ * Gets the document that was generated during execution.
+ * @return the document that was generated during execution.
+ */
+ public Document getDocument() {
+ return document;
+ }
+
+ public ClaimStatistic getStatistic() {
+ return statistic;
+ }
+
+ /**
+ * Formats the report to the output and using the stylesheet found in the report configuration.
+ *
+ * @param config s RAT report configuration.
+ * @throws RatException on error.
+ */
+ public void format(final ReportConfiguration config) throws RatException {
+ format(config.getStyleSheet(), config.getOutput());
+ }
+
+ /**
+ * Formats the report to the specified output using the stylesheet. It is safe to call this method more than once
+ * in order to generate multiple reports from the same run.
+ *
+ * @param stylesheet the style sheet to use for XSLT formatting.
+ * @param output the output stream to write to.
+ * @throws RatException on error.
+ */
+ public void format(final IOSupplier<InputStream> stylesheet, final IOSupplier<OutputStream> output) throws RatException {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ Transformer transformer;
+ try (OutputStream out = output.get();
+ InputStream styleIn = stylesheet.get()) {
+ transformer = tf.newTransformer(new StreamSource(styleIn));
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+ transformer.transform(new DOMSource(document),
+ new StreamResult(new OutputStreamWriter(out, StandardCharsets.UTF_8)));
+ } catch (TransformerException | IOException e) {
+ throw new RatException(e);
+ }
+ }
+
+ /**
+ * Writes a text summary of issues with the run.
+ * @param appendable the appendable to write to.
+ * @throws IOException on error.
+ */
+ public void writeSummary(final Appendable appendable) throws IOException {
+ appendable.append("RAT summary:").append(System.lineSeparator());
+ for (ClaimStatistic.Counter counter : ClaimStatistic.Counter.values()) {
+ appendable.append(" ").append(counter.displayName()).append(": ")
+ .append(Integer.toString(statistic.getCounter(counter)))
+ .append(System.lineSeparator());
+ }
}
- }
- /**
- * Gets the document that was generated during execution.
- * @return the document that was generated during execution.
- */
- public Document getDocument() {
- return document;
}
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/commandline/Arg.java b/apache-rat-core/src/main/java/org/apache/rat/commandline/Arg.java
index a9a2d5e7..e6eea38a 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/commandline/Arg.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/commandline/Arg.java
@@ -873,14 +873,14 @@ public enum Arg {
if ("x".equals(selected)) {
// display deprecated message.
context.getCommandLine().hasOption("x");
- context.getConfiguration().setStyleSheet(StyleSheets.getStyleSheet("xml"));
+ context.getConfiguration().setStyleSheet(StyleSheets.getStyleSheet("xml", context.getWorkingDirectory()));
} else {
String[] style = context.getCommandLine().getOptionValues(OUTPUT_STYLE.getSelected());
if (style.length != 1) {
DefaultLog.getInstance().error("Please specify a single stylesheet");
throw new ConfigurationException("Please specify a single stylesheet");
}
- context.getConfiguration().setStyleSheet(StyleSheets.getStyleSheet(style[0]));
+ context.getConfiguration().setStyleSheet(StyleSheets.getStyleSheet(style[0], context.getWorkingDirectory()));
}
}
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/commandline/StyleSheets.java b/apache-rat-core/src/main/java/org/apache/rat/commandline/StyleSheets.java
index c73a9e4e..8675f06e 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/commandline/StyleSheets.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/commandline/StyleSheets.java
@@ -21,12 +21,11 @@ package org.apache.rat.commandline;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
import java.util.Objects;
import org.apache.commons.io.function.IOSupplier;
import org.apache.rat.ConfigurationException;
+import org.apache.rat.document.DocumentName;
import static java.lang.String.format;
@@ -83,14 +82,14 @@ public enum StyleSheets {
* @param name the short name for or the path to a style sheet.
* @return the IOSupplier for the style sheet.
*/
- public static IOSupplier<InputStream> getStyleSheet(final String name) {
+ public static IOSupplier<InputStream> getStyleSheet(final String name, final DocumentName workingDirectory) {
URL url = StyleSheets.class.getClassLoader().getResource(format("org/apache/rat/%s.xsl", name));
if (url != null) {
return url::openStream;
}
- Path p = Paths.get(name);
- if (p.toFile().exists()) {
- return () -> Files.newInputStream(p);
+ DocumentName xslt = workingDirectory.resolve(name);
+ if (xslt.asFile().exists()) {
+ return () -> Files.newInputStream(xslt.asFile().toPath());
}
throw new ConfigurationException(format("Stylesheet file '%s' not found", name));
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
index dfe6d057..7f42cee5 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentName.java
@@ -133,6 +133,7 @@ public class DocumentName implements Comparable<DocumentName> {
/**
* Creates a path from the document name.
+ * Does not include the document root.
* @return a new Path object.
*/
public Path asPath() {
diff --git a/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/License.java b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/License.java
new file mode 100644
index 00000000..f059ea39
--- /dev/null
+++ b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/License.java
@@ -0,0 +1,92 @@
+/*
+ * 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.documentation.velocity;
+
+import java.util.UUID;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rat.license.ILicense;
+
+/**
+ * The License representation for documentation.
+ */
+public final class License {
+ /** The RAT internal license we are wrapping */
+ private final ILicense license;
+
+ /** Constructor */
+ License(final ILicense license) {
+ this.license = license;
+ }
+
+ /**
+ * Gets the name of this license.
+ * @return the name of this license.
+ */
+ public String name() {
+ return license.getName();
+ }
+
+ /**
+ * Gets the family name of this license.
+ * @return the family name of this license.
+ */
+ public String family() {
+ return license.getFamilyName();
+ }
+
+ /**
+ * Gets the space normalized note for the license.
+ * @return the space normalized note for the license. May be {@code null}.
+ * @see StringUtils
+ */
+ public String note() {
+ return StringUtils.normalizeSpace(license.getNote());
+ }
+
+ /**
+ * Gets the id for this license if it is not a system generated one.
+ * @return the id for this license. May be {@code null}.
+ */
+ public String id() {
+ String result = license.getId();
+ try {
+ UUID.fromString(result);
+ return null;
+ } catch (IllegalArgumentException e) {
+ // do nothing.
+ }
+ return result;
+ }
+
+ /**
+ * Gets the matcher associated with this license.
+ * @return the matcher associated with this license.
+ */
+ public Matcher getMatcher() {
+ return new Matcher(license.getMatcher());
+ }
+
+ /**
+ * Gets the matcher tree associated with this license.
+ * @return the matcher tree associated with this license.
+ */
+ public MatcherTree getMatcherTree() {
+ return new MatcherTree(license.getMatcher());
+ }
+}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/Matcher.java b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
new file mode 100644
index 00000000..ceeefbf9
--- /dev/null
+++ b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
@@ -0,0 +1,302 @@
+/*
+ * 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.documentation.velocity;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Objects;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rat.analysis.IHeaderMatcher;
+import org.apache.rat.analysis.matchers.AbstractMatcherContainer;
+import org.apache.rat.config.parameters.ComponentType;
+import org.apache.rat.config.parameters.Description;
+import org.apache.rat.config.parameters.DescriptionBuilder;
+import org.apache.rat.configuration.XMLConfig;
+
+/**
+ * The Matcher representation for documentation.
+ */
+public class Matcher {
+ /**
+ * The description for this matcher.
+ */
+ private final Description desc;
+
+ /**
+ * The header matcher we are wrapping. May be {@code null}.
+ */
+ private final IHeaderMatcher self;
+
+ /**
+ * The description of the enclosed attribute. May be null.
+ */
+ private final Enclosed enclosed;
+
+ /**
+ * The set of attributes for this matcher.
+ */
+ private final Set<Attribute> attributes;
+
+ /**
+ * Copy constructor.
+ * @param matcher the matcher to copy.
+ */
+ Matcher(final Matcher matcher) {
+ this.desc = matcher.desc;
+ this.self = matcher.self;
+ this.enclosed = matcher.enclosed;
+ this.attributes = matcher.attributes;
+ }
+
+ /**
+ * Creates from a system Matcher.
+ * @param self the IHeaderMatcher to wrap.
+ */
+ Matcher(final IHeaderMatcher self) {
+ this(DescriptionBuilder.buildMap(self.getClass()), self);
+ }
+
+ /**
+ * Creates from a description and a system matcher.
+ * @param desc the description of the matcher.
+ * @param self the matcher to wrap. May be {@code null}.
+ */
+ Matcher(final Description desc, final IHeaderMatcher self) {
+ Objects.requireNonNull(desc);
+ this.desc = desc;
+ this.self = self;
+ Enclosed enclosed = null;
+ attributes = new TreeSet<>(Comparator.comparing(Attribute::getName));
+ for (Description child : desc.childrenOfType(ComponentType.PARAMETER)) {
+ if (XMLConfig.isInlineNode(desc.getCommonName(), child.getCommonName())) {
+ enclosed = new Enclosed(child);
+ } else {
+ attributes.add(new Attribute(child));
+ }
+ }
+ this.enclosed = enclosed;
+ }
+
+ /**
+ * Get the name of the matcher type.
+ * @return the name of the matcher type.
+ */
+ public String getName() {
+ return desc.getCommonName();
+ }
+
+ /**
+ * Gets the description of the matcher type.
+ * @return The description of the matcher type or an empty string.
+ */
+ public String getDescription() {
+ return StringUtils.defaultIfEmpty(desc.getDescription(), "");
+ }
+
+ /**
+ * If the matcher encloses another matcher return the definition of that enclosure.
+ * @return the description of the enclose matcher. May be {@code null}.
+ */
+ public Enclosed getEnclosed() {
+ return enclosed;
+ }
+
+ /**
+ * Gets the attributes of this matcher.
+ * @return a collection of attributes for this matcher. May be empty but not {@code null}.
+ */
+ public Collection<Attribute> getAttributes() {
+ return attributes;
+ }
+
+ /**
+ * Gets the direct children of this matcher.
+ * @return A collection of the direct children of this matcher. May be empty but not {@code null}.
+ */
+ Collection<Matcher> getChildren() {
+ if (self != null && enclosed != null && IHeaderMatcher.class.equals(enclosed.desc.getChildType())) {
+ if (self instanceof AbstractMatcherContainer) {
+ AbstractMatcherContainer matcherContainer = (AbstractMatcherContainer) self;
+ return matcherContainer.getEnclosed().stream().map(Matcher::new).collect(Collectors.toList());
+ }
+ try {
+ IHeaderMatcher matcher = (IHeaderMatcher) enclosed.desc.getter(self.getClass()).invoke(self);
+ return Collections.singleton(new Matcher(matcher));
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * The description of an enclosed matcher.
+ */
+ public final class Enclosed {
+ /** The description for the enclosed item */
+ private final Description desc;
+
+ /**
+ * Constructor.
+ * @param desc the description of the enclosed matcher.
+ */
+ Enclosed(final Description desc) {
+ this.desc = desc;
+ }
+
+ /**
+ * Gets the required flag.
+ * @return the word "required" or "optional" depending on the state of the required flag.
+ */
+ public String getRequired() {
+ return desc.isRequired() ? "required" : "optional";
+ }
+
+ /**
+ * Gets the phrase "or more " if the enclosed matcher may be multiple.
+ * @return the phrase "or more " or an empty string.
+ */
+ public String getCollection() {
+ return desc.isCollection() ? "or more " : "";
+ }
+
+ /**
+ * Get the type of the enclosed matcher.
+ * @return the type of the enclosed matcher.
+ */
+ public String getType() {
+ return desc.getChildType().getSimpleName();
+ }
+
+ /**
+ * Gets the value of the enclosed matcher.
+ * <ul>
+ * <li>If the Matcher does not have an {@link IHeaderMatcher} defined this method returns {@code null}.</li>
+ * <li>If the value is a string it is normalized before being returned.</li>
+ * </ul>
+ * @return the value of the enclosed matcher in the provided {@link IHeaderMatcher}.
+ * @see StringUtils#normalizeSpace(String)
+ */
+ public Object getValue() {
+ if (self != null) {
+ try {
+ Object value = desc.getter(self.getClass()).invoke(self);
+ return value instanceof String ? StringUtils.normalizeSpace((String) value) : value;
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return null;
+ }
+ Class<?> getChildType() {
+ return desc.getChildType();
+ }
+ }
+
+ /**
+ * The definition of an attribute.
+ */
+ public final class Attribute {
+ /**
+ * The description for the attribute.
+ */
+ private final Description description;
+
+ /**
+ * Constructor
+ * @param description the description for this attribute.
+ */
+ Attribute(final Description description) {
+ this.description = description;
+ }
+
+ /**
+ * Gets the attribute name.
+ * @return the attribut name.
+ */
+ public String getName() {
+ return description.getCommonName();
+ }
+
+ /**
+ * Gets the required flag.
+ * @return the word "required" or "optional" depending on the state of the required flag.
+ */
+ public String getRequired() {
+ return description.isRequired() ? "required" : "optional";
+ }
+
+ /**
+ * Get the type of the attribute.
+ * @return the type of the enclosed matcher.
+ */
+ public String getType() {
+ return description.getChildType().getSimpleName();
+ }
+
+ /**
+ * Gets the description of the attribute or an empty string.
+ * @return the description of the attribute or an empty string.
+ */
+ public String getDescription() {
+ return StringUtils.defaultIfEmpty(description.getDescription(), "");
+ }
+
+ /**
+ * Gets the value of the enclosed matcher.
+ * <ul>
+ * <li>If the Matcher does not have an {@link IHeaderMatcher} defined this method returns {@code null}.</li>
+ * <li>If the value of the attribute (self) is {@code null}, this method returns {@code null}.</li>
+ * <li>If the value is a string, it is normalized before being returned.</li>
+ * <li>If the attribute is an "id" and the value is a UUID, {@code null} is returned.</li>
+ * <li>otherwise, the string value is returned.</li>
+ * </ul>
+ * @return the value of the enclosed matcher in the provided {@link IHeaderMatcher}.
+ * @see StringUtils#normalizeSpace(String)
+ */
+ public String getValue() {
+ if (self != null) {
+ try {
+ Object value = description.getter(self.getClass()).invoke(self);
+ if (value != null) {
+ String result = value.toString();
+ if (description.getCommonName().equals("id")) {
+ try {
+ UUID.fromString(result);
+ return null;
+ } catch (IllegalArgumentException e) {
+ // do nothing.
+ }
+ }
+ return result;
+ }
+ } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return null;
+ }
+ }
+}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/MatcherTree.java b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/MatcherTree.java
new file mode 100644
index 00000000..4e31f2e9
--- /dev/null
+++ b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/MatcherTree.java
@@ -0,0 +1,136 @@
+/*
+ * 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.documentation.velocity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.rat.analysis.IHeaderMatcher;
+import org.apache.rat.config.parameters.Description;
+
+/**
+ * The representation of the Matcher tree found in a License.
+ */
+public class MatcherTree {
+ /**
+ * The root of the tree.
+ */
+ private final IHeaderMatcher root;
+
+ /**
+ * Constructor.
+ * @param root the root of the tree. The matcher from a license.
+ */
+ public MatcherTree(final IHeaderMatcher root) {
+ this.root = root;
+ }
+
+ /**
+ * Gets the description of the root of the tree.
+ * @return the description of the root of the tree.
+ */
+ public Description getRoot() {
+ return root.getDescription();
+ }
+
+ /**
+ * Executes an in-order-traversal of the tree.
+ * @return A list of {@link Node}s from an in-order-traversal.
+ */
+ public List<Node> traverse() {
+ List<Node> result = new ArrayList<>();
+ result.add(new Node(0, root));
+ processNode(result, result.get(0));
+ return result;
+ }
+
+ /**
+ * Process a node and create all the children of it.
+ * @param result the result to add the children to.
+ * @param node the node to process.
+ */
+ private void processNode(final List<Node> result, final Node node) {
+ Collection<Matcher> children = node.getChildren();
+ if (children.isEmpty()) {
+ return;
+ }
+ for (Matcher child : children) {
+ Node childNode = new Node(node.level + 1, child);
+ result.add(childNode);
+ processNode(result, childNode);
+ }
+ }
+
+ /**
+ * The representation of a node in a License Matcher tree.
+ * A node is a Matcher that tracks the level of the tree in which it appears.
+ */
+ public static class Node extends Matcher {
+ /** The level of the tree that this node appears in. */
+ private final int level;
+
+ /**
+ * Constructor.
+ * @param level the level of the tree. (root = 0)
+ * @param matcher the matcher being processed.
+ */
+ Node(final int level, final Matcher matcher) {
+ super(matcher);
+ this.level = level;
+ }
+
+ /**
+ * Constructor.
+ * @param level the level of the tree. (root = 0)
+ * @param root the matcher to wrap.
+ */
+ Node(final int level, final IHeaderMatcher root) {
+ super(root);
+ this.level = level;
+ }
+
+ /**
+ * Gets the level in the tree of this node.
+ * @return the level in the tree of this node.
+ */
+ public int level() {
+ return level;
+ }
+
+ /**
+ * Gets the enclosed node only if it is another matcher.
+ * @return the enclosed node.
+ */
+ @Override
+ public Enclosed getEnclosed() {
+ Enclosed result = super.getEnclosed();
+ return result != null && IHeaderMatcher.class.equals(result.getChildType()) ? null : result;
+ }
+
+ /**
+ * Gets the attributes only if they have values.
+ * @return the collection of attributes that have values.
+ */
+ @Override
+ public Collection<Attribute> getAttributes() {
+ return super.getAttributes().stream().filter(attr -> attr.getValue() != null).collect(Collectors.toList());
+ }
+ }
+}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/RatTool.java b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/RatTool.java
new file mode 100644
index 00000000..0cbe3e27
--- /dev/null
+++ b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/RatTool.java
@@ -0,0 +1,278 @@
+/*
+ * 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.documentation.velocity;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+import org.apache.commons.cli.Option;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.rat.Defaults;
+import org.apache.rat.OptionCollection;
+import org.apache.rat.api.EnvVar;
+import org.apache.rat.commandline.StyleSheets;
+import org.apache.rat.config.exclusion.StandardCollection;
+import org.apache.rat.config.parameters.ComponentType;
+import org.apache.rat.config.parameters.Description;
+import org.apache.rat.config.parameters.DescriptionBuilder;
+import org.apache.rat.configuration.MatcherBuilderTracker;
+import org.apache.rat.help.AbstractHelp;
+import org.apache.rat.license.ILicense;
+import org.apache.rat.license.LicenseSetFactory;
+import org.apache.velocity.tools.config.DefaultKey;
+import org.apache.velocity.tools.config.ValidScope;
+
+/**
+ * The Velocity RAT plugin that provides access to the RAT data.
+ * <p>
+ * DEVHINT: Be careful when removing methods as this may invalidate contents and functionality of the velocity templates.
+ * </p>
+ */
+@SuppressWarnings("unused")
+@DefaultKey("rat")
+@ValidScope({"application"})
+public class RatTool {
+
+ private static String[] charParser(final String charText) {
+ char[] chars = charText.toCharArray();
+ String[] result = new String[chars.length];
+ for (int i = 0; i < chars.length; i++) {
+ result[i] = String.valueOf(chars[i]);
+ }
+ return result;
+ }
+
+ /**
+ * The characters to escape for markdown.
+ */
+ private static final String[] MARKDOWN_CHARS = charParser("\\`*_{}[]<>()#+-.!|");
+ /**
+ * The characters to escape for APT (Almost Plain Text).
+ */
+ private static final String[] APT_CHARS = charParser("\\~=-+*[]<>{}");
+
+ /** The license factory this tool uses. */
+ private final LicenseSetFactory licenseSetFactory;
+
+ /**
+ * Constructor.
+ */
+ public RatTool() {
+ Defaults defaults = Defaults.builder().build();
+ licenseSetFactory = defaults.getLicenseSetFactory();
+ }
+
+ /**
+ * Gets the list of command line options.
+ * @return the list of command line options.
+ */
+ public List<Option> options() {
+ List<Option> lst = new ArrayList<>(OptionCollection.buildOptions().getOptions());
+ lst.sort(Comparator.comparing(CLIOption::createName));
+ return lst;
+ }
+
+ /**
+ * Gets a map client option name to Ant Option.
+ * @return a map client option name to Ant Option.
+ */
+ public Map<String, AntOption> antOptions() {
+ Map<String, AntOption> result = new TreeMap<>();
+ for (AntOption antOption : AntOption.getAntOptions()) {
+ result.put(CLIOption.createName(antOption.getOption()), antOption);
+ }
+ return result;
+ }
+
+ /**
+ * Gets a map client option name to CLI Option.
+ * @return a map client option name to CLI Option.
+ */
+ public Map<String, CLIOption> cliOptions() {
+ Map<String, CLIOption> result = new TreeMap<>();
+ for (Option option : OptionCollection.buildOptions().getOptions()) {
+ CLIOption cliOption = new CLIOption(option);
+ result.put(cliOption.getName(), cliOption);
+ }
+ return result;
+ }
+
+ /**
+ * Gets a map client option name to Maven Option.
+ * @return a map client option name to Maven Option.
+ */
+ public Map<String, MavenOption> mvnOptions() {
+ Map<String, MavenOption> result = new TreeMap<>();
+ for (MavenOption mavenOption : MavenOption.getMavenOptions()) {
+ result.put(CLIOption.createName(mavenOption.getOption()), mavenOption);
+ }
+ return result;
+ }
+
+ /**
+ * Escapes a text string.
+ * @param text the text to escape.
+ * @param chars the characters to escape.
+ * @return the escaped string.
+ */
+ private String escape(final String text, final String[] chars) {
+ if (text == null) {
+ return "";
+ }
+ String result = text;
+ for (String c : chars) {
+ result = result.replace(c, "\\" + c);
+ }
+ return result;
+ }
+
+ /**
+ * Escapes a string for markdown.
+ * @param text the text to escape.
+ * @return the text with the markdown specific characters escaped.
+ */
+ public String markdownEscape(final String text) {
+ return escape(text, MARKDOWN_CHARS);
+ }
+
+ /**
+ * Escapes a string for APT (almost plain text).
+ * @param text the text to escape.
+ * @return the text with the APT specific characters escaped.
+ */
+ public String aptEscape(final String text) {
+ return escape(text, APT_CHARS);
+ }
+
+ /**
+ * Gets the list of argument types.
+ * @return a list of argument types.
+ */
+ public List<OptionCollection.ArgumentType> argumentTypes() {
+ return Arrays.stream(OptionCollection.ArgumentType.values()).filter(t -> t != OptionCollection.ArgumentType.NONE)
+ .sorted(Comparator.comparing(OptionCollection.ArgumentType::getDisplayName))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets the list of environment variables.
+ * @return a list of environment variables.
+ */
+ public List<EnvVar> environmentVariables() {
+ return Arrays.stream(EnvVar.values())
+ .sorted(Comparator.comparing(EnvVar::name))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets the set of Matchers.
+ * @return the set of Matchers.
+ */
+ public Set<Matcher> matchers() {
+ MatcherBuilderTracker tracker = MatcherBuilderTracker.instance();
+ Set<Matcher> documentationSet = new TreeSet<>(Comparator.comparing(Matcher::getName));
+ for (Class<?> clazz : tracker.getClasses()) {
+ Description desc = DescriptionBuilder.buildMap(clazz);
+ documentationSet.add(new Matcher(desc, null));
+ }
+ return documentationSet;
+ }
+
+ /**
+ * Gets the list of standard collections.
+ * @return the list of standard collections.
+ */
+ public List<StandardCollection> standardCollections() {
+ return Arrays.stream(StandardCollection.values())
+ .sorted(Comparator.comparing(Enum::name))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets the list of stylesheets.
+ * @return the list of stylesheets.
+ */
+ public List<StyleSheets> styleSheets() {
+ return Arrays.stream(StyleSheets.values())
+ .sorted(Comparator.comparing(StyleSheets::arg))
+ .collect(Collectors.toList());
+ }
+
+ /**
+ * Gets the {@link StringUtils} object in order to work with it in Velocity templates.
+ * @return the org.apache.commons.lang3 StringUtils object.
+ * @see StringUtils
+ */
+ public StringUtils stringUtils() {
+ return new StringUtils();
+ }
+
+ /**
+ * Gets a tab character.
+ * @return the tab character.
+ */
+ public String tab() {
+ return "\t";
+ }
+
+ /**
+ * Gets two new lines.
+ * @return a string containing two new lines.
+ */
+ public String doubleLine() {
+ return "\n\n";
+ }
+
+ /**
+ * Gets a list of license property descriptions.
+ * @return a list of license property descriptions.
+ */
+ public List<Description> licenseProperties() {
+ SortedSet<ILicense> licenses = licenseSetFactory.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
+ Description licenseDescription = DescriptionBuilder.build(licenses.first());
+ List<Description> descriptions = new ArrayList<>(licenseDescription.filterChildren(d -> d.getType() == ComponentType.PARAMETER));
+ descriptions.sort(Comparator.comparing(Description::getCommonName));
+ return descriptions;
+ }
+
+ /**
+ * Gets the list of defined licenses.
+ * @return the list of defined licenses.
+ */
+ public List<License> licenses() {
+ Set<ILicense> licenses = licenseSetFactory.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
+ return licenses.stream().map(License::new).collect(Collectors.toList());
+ }
+
+ /**
+ * Creates a string of spaces of the specified length.
+ * @param length the length of the string.
+ * @return a string of spaces of the specified length.
+ */
+ public String pad(final int length) {
+ return AbstractHelp.createPadding(length);
+ }
+}
diff --git a/apache-rat-plugin/src/main/resources/org/apache/rat/mp/package-info.java b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/package-info.java
similarity index 86%
copy from apache-rat-plugin/src/main/resources/org/apache/rat/mp/package-info.java
copy to apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/package-info.java
index 0cb70eb6..7e9cb0b5 100644
--- a/apache-rat-plugin/src/main/resources/org/apache/rat/mp/package-info.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/documentation/velocity/package-info.java
@@ -16,6 +16,6 @@
*/
/**
-* This package contains the RAT plugins for {@link <a href="https://maven.apache.org">Maven</a>}.
+* Contains velocity based tools and accessories.
*/
-package org.apache.rat.mp;
+package org.apache.rat.documentation.velocity;
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java b/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
deleted file mode 100644
index 7268b1d7..00000000
--- a/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.report;
-
-import org.apache.rat.api.Document;
-
-/**
- * Abstract base class for deriving implementations of {@link RatReport}.
- * @deprecated use {@link RatReport} directly.
- */
-@Deprecated
-public abstract class AbstractReport implements RatReport {
- /**
- * Empty default implementation.
- */
- public void startReport() {
- // Does nothing
- }
-
- /**
- * Empty default implementation.
- * @param document the actual document
- */
- public void report(final Document document) {
- // Does nothing
- }
-
- /**
- * Empty default implementation.
- */
- public void endReport() {
- // Does nothing
- }
-}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimValidatorReport.java b/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimValidatorReport.java
index ad955a61..e06f81a8 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimValidatorReport.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/claim/ClaimValidatorReport.java
@@ -18,10 +18,16 @@
*/
package org.apache.rat.report.claim;
+import java.util.Set;
+import java.util.stream.Collectors;
+
import org.apache.rat.ReportConfiguration;
import org.apache.rat.api.Document;
import org.apache.rat.api.RatException;
import org.apache.rat.config.results.ClaimValidator;
+import org.apache.rat.license.ILicense;
+import org.apache.rat.license.ILicenseFamily;
+import org.apache.rat.license.LicenseSetFactory;
import org.apache.rat.report.RatReport;
import org.apache.rat.report.xml.XmlElements;
import org.apache.rat.report.xml.writer.IXmlWriter;
@@ -43,6 +49,10 @@ public class ClaimValidatorReport implements RatReport {
*/
private final ClaimValidator validator;
+ /**
+ * The report configuration.
+ */
+ private final ReportConfiguration configuration;
/**
* Constructor.
* @param writer the XMLWriter to write with.
@@ -53,6 +63,7 @@ public class ClaimValidatorReport implements RatReport {
this.elements = new XmlElements(writer);
this.statistic = statistic;
this.validator = configuration.getClaimValidator();
+ this.configuration = configuration;
}
@Override
@@ -62,11 +73,15 @@ public class ClaimValidatorReport implements RatReport {
int count = statistic.getCounter(counter);
elements.statistic(counter.displayName(), count, counter.getDescription(), validator.isValid(counter, count));
}
+ Set<String> families = configuration.getLicenseFamilies(LicenseSetFactory.LicenseFilter.APPROVED)
+ .stream().map(ILicenseFamily::getFamilyCategory).collect(Collectors.toSet());
for (String category : statistic.getLicenseFamilyCategories()) {
- elements.licenseCategory(category, statistic.getLicenseCategoryCount(category));
+ elements.licenseCategory(category, statistic.getLicenseCategoryCount(category), families.contains(category));
}
- for (String category : statistic.getLicenseNames()) {
- elements.licenseName(category, statistic.getLicenseNameCount(category));
+ Set<String> licenses = configuration.getLicenses(LicenseSetFactory.LicenseFilter.APPROVED)
+ .stream().map(ILicense::getName).collect(Collectors.toSet());
+ for (String license : statistic.getLicenseNames()) {
+ elements.licenseName(license, statistic.getLicenseNameCount(license), licenses.contains(license));
}
for (Document.Type type : statistic.getDocumentTypes()) {
elements.documentType(type.name(), statistic.getCounter(type));
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlElements.java b/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlElements.java
index e8301aa8..d80ce49c 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlElements.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlElements.java
@@ -250,13 +250,15 @@ public class XmlElements {
* Creates a statistic element. Closes the element before returning.
* @param name the name of the statistics element.
* @param count the count for the element.
+ * @param approved true if the licenseCategory is approved.
* @return this
* @throws RatException on error.
*/
- public XmlElements licenseCategory(final String name, final int count) throws RatException {
+ public XmlElements licenseCategory(final String name, final int count, final boolean approved) throws RatException {
return write(Elements.LICENSE_CATEGORY)
.write(Attributes.NAME, name)
.write(Attributes.COUNT, Integer.toString(count))
+ .write(Attributes.APPROVAL, Boolean.toString(approved))
.closeElement();
}
@@ -267,10 +269,11 @@ public class XmlElements {
* @return this
* @throws RatException on error.
*/
- public XmlElements licenseName(final String name, final int count) throws RatException {
+ public XmlElements licenseName(final String name, final int count, final boolean approved) throws RatException {
return write(Elements.LICENSE_NAME)
.write(Attributes.NAME, name)
.write(Attributes.COUNT, Integer.toString(count))
+ .write(Attributes.APPROVAL, Boolean.toString(approved))
.closeElement();
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XMLChar.java b/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XMLChar.java
new file mode 100644
index 00000000..22946ed7
--- /dev/null
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XMLChar.java
@@ -0,0 +1,1064 @@
+package org.apache.rat.report.xml.writer;
+
+/*
+ * 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.
+ */
+
+// this code is lifted from https://github.com/apache/xerces2-j/blob/trunk/src/org/apache/xerces/util/XMLChar.java
+
+import java.util.Arrays;
+
+/**
+ * This class defines the basic XML character properties. The data
+ * in this class can be used to verify that a character is a valid
+ * XML character or if the character is a space, name start, or name
+ * character.
+ * <p>
+ * A series of convenience methods are supplied to ease the burden
+ * of the developer. Because inlining the checks can improve per
+ * character performance, the tables of character properties are
+ * public. Using the character as an index into the <code>CHARS</code>
+ * array and applying the appropriate mask flag (e.g.
+ * <code>MASK_VALID</code>), yields the same results as calling the
+ * convenience methods. There is one exception: check the comments
+ * for the <code>isValid</code> method for details.
+ *
+ * @author Glenn Marcy, IBM
+ * @author Andy Clark, IBM
+ * @author Eric Ye, IBM
+ * @author Arnaud Le Hors, IBM
+ * @author Michael Glavassevich, IBM
+ * @author Rahul Srivastava, Sun Microsystems Inc.
+ *
+ * @version $Id$
+ */
+public class XMLChar {
+
+ //
+ // Constants
+ //
+
+ /** Character flags. */
+ private static final byte[] CHARS = new byte[1 << 16];
+
+ /** Valid character mask. */
+ public static final int MASK_VALID = 0x01;
+
+ /** Space character mask. */
+ public static final int MASK_SPACE = 0x02;
+
+ /** Name start character mask. */
+ public static final int MASK_NAME_START = 0x04;
+
+ /** Name character mask. */
+ public static final int MASK_NAME = 0x08;
+
+ /** Pubid character mask. */
+ public static final int MASK_PUBID = 0x10;
+
+ /**
+ * Content character mask. Special characters are those that can
+ * be considered the start of markup, such as '<' and '&'.
+ * The various newline characters are considered special as well.
+ * All other valid XML characters can be considered content.
+ * <p>
+ * This is an optimization for the inner loop of character scanning.
+ */
+ public static final int MASK_CONTENT = 0x20;
+
+ /** NCName start character mask. */
+ public static final int MASK_NCNAME_START = 0x40;
+
+ /** NCName character mask. */
+ public static final int MASK_NCNAME = 0x80;
+
+ //
+ // Static initialization
+ //
+
+ static {
+
+ // Initializing the Character Flag Array
+ // Code generated by: XMLCharGenerator.
+
+ CHARS[9] = 35;
+ CHARS[10] = 19;
+ CHARS[13] = 19;
+ CHARS[32] = 51;
+ CHARS[33] = 49;
+ CHARS[34] = 33;
+ Arrays.fill(CHARS, 35, 38, (byte) 49 ); // Fill 3 of value (byte) 49
+ CHARS[38] = 1;
+ Arrays.fill(CHARS, 39, 45, (byte) 49 ); // Fill 6 of value (byte) 49
+ Arrays.fill(CHARS, 45, 47, (byte) -71 ); // Fill 2 of value (byte) -71
+ CHARS[47] = 49;
+ Arrays.fill(CHARS, 48, 58, (byte) -71 ); // Fill 10 of value (byte) -71
+ CHARS[58] = 61;
+ CHARS[59] = 49;
+ CHARS[60] = 1;
+ CHARS[61] = 49;
+ CHARS[62] = 33;
+ Arrays.fill(CHARS, 63, 65, (byte) 49 ); // Fill 2 of value (byte) 49
+ Arrays.fill(CHARS, 65, 91, (byte) -3 ); // Fill 26 of value (byte) -3
+ Arrays.fill(CHARS, 91, 93, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[93] = 1;
+ CHARS[94] = 33;
+ CHARS[95] = -3;
+ CHARS[96] = 33;
+ Arrays.fill(CHARS, 97, 123, (byte) -3 ); // Fill 26 of value (byte) -3
+ Arrays.fill(CHARS, 123, 183, (byte) 33 ); // Fill 60 of value (byte) 33
+ CHARS[183] = -87;
+ Arrays.fill(CHARS, 184, 192, (byte) 33 ); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 192, 215, (byte) -19 ); // Fill 23 of value (byte) -19
+ CHARS[215] = 33;
+ Arrays.fill(CHARS, 216, 247, (byte) -19 ); // Fill 31 of value (byte) -19
+ CHARS[247] = 33;
+ Arrays.fill(CHARS, 248, 306, (byte) -19 ); // Fill 58 of value (byte) -19
+ Arrays.fill(CHARS, 306, 308, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 308, 319, (byte) -19 ); // Fill 11 of value (byte) -19
+ Arrays.fill(CHARS, 319, 321, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 321, 329, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[329] = 33;
+ Arrays.fill(CHARS, 330, 383, (byte) -19 ); // Fill 53 of value (byte) -19
+ CHARS[383] = 33;
+ Arrays.fill(CHARS, 384, 452, (byte) -19 ); // Fill 68 of value (byte) -19
+ Arrays.fill(CHARS, 452, 461, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 461, 497, (byte) -19 ); // Fill 36 of value (byte) -19
+ Arrays.fill(CHARS, 497, 500, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 500, 502, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 502, 506, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 506, 536, (byte) -19 ); // Fill 30 of value (byte) -19
+ Arrays.fill(CHARS, 536, 592, (byte) 33 ); // Fill 56 of value (byte) 33
+ Arrays.fill(CHARS, 592, 681, (byte) -19 ); // Fill 89 of value (byte) -19
+ Arrays.fill(CHARS, 681, 699, (byte) 33 ); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 699, 706, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 706, 720, (byte) 33 ); // Fill 14 of value (byte) 33
+ Arrays.fill(CHARS, 720, 722, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 722, 768, (byte) 33 ); // Fill 46 of value (byte) 33
+ Arrays.fill(CHARS, 768, 838, (byte) -87 ); // Fill 70 of value (byte) -87
+ Arrays.fill(CHARS, 838, 864, (byte) 33 ); // Fill 26 of value (byte) 33
+ Arrays.fill(CHARS, 864, 866, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 866, 902, (byte) 33 ); // Fill 36 of value (byte) 33
+ CHARS[902] = -19;
+ CHARS[903] = -87;
+ Arrays.fill(CHARS, 904, 907, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[907] = 33;
+ CHARS[908] = -19;
+ CHARS[909] = 33;
+ Arrays.fill(CHARS, 910, 930, (byte) -19 ); // Fill 20 of value (byte) -19
+ CHARS[930] = 33;
+ Arrays.fill(CHARS, 931, 975, (byte) -19 ); // Fill 44 of value (byte) -19
+ CHARS[975] = 33;
+ Arrays.fill(CHARS, 976, 983, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 983, 986, (byte) 33 ); // Fill 3 of value (byte) 33
+ CHARS[986] = -19;
+ CHARS[987] = 33;
+ CHARS[988] = -19;
+ CHARS[989] = 33;
+ CHARS[990] = -19;
+ CHARS[991] = 33;
+ CHARS[992] = -19;
+ CHARS[993] = 33;
+ Arrays.fill(CHARS, 994, 1012, (byte) -19 ); // Fill 18 of value (byte) -19
+ Arrays.fill(CHARS, 1012, 1025, (byte) 33 ); // Fill 13 of value (byte) 33
+ Arrays.fill(CHARS, 1025, 1037, (byte) -19 ); // Fill 12 of value (byte) -19
+ CHARS[1037] = 33;
+ Arrays.fill(CHARS, 1038, 1104, (byte) -19 ); // Fill 66 of value (byte) -19
+ CHARS[1104] = 33;
+ Arrays.fill(CHARS, 1105, 1117, (byte) -19 ); // Fill 12 of value (byte) -19
+ CHARS[1117] = 33;
+ Arrays.fill(CHARS, 1118, 1154, (byte) -19 ); // Fill 36 of value (byte) -19
+ CHARS[1154] = 33;
+ Arrays.fill(CHARS, 1155, 1159, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 1159, 1168, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 1168, 1221, (byte) -19 ); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 1221, 1223, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1223, 1225, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1225, 1227, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1227, 1229, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1229, 1232, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 1232, 1260, (byte) -19 ); // Fill 28 of value (byte) -19
+ Arrays.fill(CHARS, 1260, 1262, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1262, 1270, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 1270, 1272, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1272, 1274, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1274, 1329, (byte) 33 ); // Fill 55 of value (byte) 33
+ Arrays.fill(CHARS, 1329, 1367, (byte) -19 ); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 1367, 1369, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[1369] = -19;
+ Arrays.fill(CHARS, 1370, 1377, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 1377, 1415, (byte) -19 ); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 1415, 1425, (byte) 33 ); // Fill 10 of value (byte) 33
+ Arrays.fill(CHARS, 1425, 1442, (byte) -87 ); // Fill 17 of value (byte) -87
+ CHARS[1442] = 33;
+ Arrays.fill(CHARS, 1443, 1466, (byte) -87 ); // Fill 23 of value (byte) -87
+ CHARS[1466] = 33;
+ Arrays.fill(CHARS, 1467, 1470, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[1470] = 33;
+ CHARS[1471] = -87;
+ CHARS[1472] = 33;
+ Arrays.fill(CHARS, 1473, 1475, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[1475] = 33;
+ CHARS[1476] = -87;
+ Arrays.fill(CHARS, 1477, 1488, (byte) 33 ); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 1488, 1515, (byte) -19 ); // Fill 27 of value (byte) -19
+ Arrays.fill(CHARS, 1515, 1520, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 1520, 1523, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 1523, 1569, (byte) 33 ); // Fill 46 of value (byte) 33
+ Arrays.fill(CHARS, 1569, 1595, (byte) -19 ); // Fill 26 of value (byte) -19
+ Arrays.fill(CHARS, 1595, 1600, (byte) 33 ); // Fill 5 of value (byte) 33
+ CHARS[1600] = -87;
+ Arrays.fill(CHARS, 1601, 1611, (byte) -19 ); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 1611, 1619, (byte) -87 ); // Fill 8 of value (byte) -87
+ Arrays.fill(CHARS, 1619, 1632, (byte) 33 ); // Fill 13 of value (byte) 33
+ Arrays.fill(CHARS, 1632, 1642, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 1642, 1648, (byte) 33 ); // Fill 6 of value (byte) 33
+ CHARS[1648] = -87;
+ Arrays.fill(CHARS, 1649, 1720, (byte) -19 ); // Fill 71 of value (byte) -19
+ Arrays.fill(CHARS, 1720, 1722, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1722, 1727, (byte) -19 ); // Fill 5 of value (byte) -19
+ CHARS[1727] = 33;
+ Arrays.fill(CHARS, 1728, 1743, (byte) -19 ); // Fill 15 of value (byte) -19
+ CHARS[1743] = 33;
+ Arrays.fill(CHARS, 1744, 1748, (byte) -19 ); // Fill 4 of value (byte) -19
+ CHARS[1748] = 33;
+ CHARS[1749] = -19;
+ Arrays.fill(CHARS, 1750, 1765, (byte) -87 ); // Fill 15 of value (byte) -87
+ Arrays.fill(CHARS, 1765, 1767, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 1767, 1769, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[1769] = 33;
+ Arrays.fill(CHARS, 1770, 1774, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 1774, 1776, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 1776, 1786, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 1786, 2305, (byte) 33 ); // Fill 519 of value (byte) 33
+ Arrays.fill(CHARS, 2305, 2308, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[2308] = 33;
+ Arrays.fill(CHARS, 2309, 2362, (byte) -19 ); // Fill 53 of value (byte) -19
+ Arrays.fill(CHARS, 2362, 2364, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[2364] = -87;
+ CHARS[2365] = -19;
+ Arrays.fill(CHARS, 2366, 2382, (byte) -87 ); // Fill 16 of value (byte) -87
+ Arrays.fill(CHARS, 2382, 2385, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2385, 2389, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 2389, 2392, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2392, 2402, (byte) -19 ); // Fill 10 of value (byte) -19
+ Arrays.fill(CHARS, 2402, 2404, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2404, 2406, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2406, 2416, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2416, 2433, (byte) 33 ); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 2433, 2436, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[2436] = 33;
+ Arrays.fill(CHARS, 2437, 2445, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 2445, 2447, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2447, 2449, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2449, 2451, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2451, 2473, (byte) -19 ); // Fill 22 of value (byte) -19
+ CHARS[2473] = 33;
+ Arrays.fill(CHARS, 2474, 2481, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[2481] = 33;
+ CHARS[2482] = -19;
+ Arrays.fill(CHARS, 2483, 2486, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2486, 2490, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2490, 2492, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[2492] = -87;
+ CHARS[2493] = 33;
+ Arrays.fill(CHARS, 2494, 2501, (byte) -87 ); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 2501, 2503, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2503, 2505, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2505, 2507, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2507, 2510, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2510, 2519, (byte) 33 ); // Fill 9 of value (byte) 33
+ CHARS[2519] = -87;
+ Arrays.fill(CHARS, 2520, 2524, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2524, 2526, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2526] = 33;
+ Arrays.fill(CHARS, 2527, 2530, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2530, 2532, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2532, 2534, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2534, 2544, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2544, 2546, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2546, 2562, (byte) 33 ); // Fill 16 of value (byte) 33
+ CHARS[2562] = -87;
+ Arrays.fill(CHARS, 2563, 2565, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2565, 2571, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 2571, 2575, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2575, 2577, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2577, 2579, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2579, 2601, (byte) -19 ); // Fill 22 of value (byte) -19
+ CHARS[2601] = 33;
+ Arrays.fill(CHARS, 2602, 2609, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[2609] = 33;
+ Arrays.fill(CHARS, 2610, 2612, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2612] = 33;
+ Arrays.fill(CHARS, 2613, 2615, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2615] = 33;
+ Arrays.fill(CHARS, 2616, 2618, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2618, 2620, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[2620] = -87;
+ CHARS[2621] = 33;
+ Arrays.fill(CHARS, 2622, 2627, (byte) -87 ); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 2627, 2631, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2631, 2633, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2633, 2635, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2635, 2638, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2638, 2649, (byte) 33 ); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 2649, 2653, (byte) -19 ); // Fill 4 of value (byte) -19
+ CHARS[2653] = 33;
+ CHARS[2654] = -19;
+ Arrays.fill(CHARS, 2655, 2662, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 2662, 2674, (byte) -87 ); // Fill 12 of value (byte) -87
+ Arrays.fill(CHARS, 2674, 2677, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2677, 2689, (byte) 33 ); // Fill 12 of value (byte) 33
+ Arrays.fill(CHARS, 2689, 2692, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[2692] = 33;
+ Arrays.fill(CHARS, 2693, 2700, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[2700] = 33;
+ CHARS[2701] = -19;
+ CHARS[2702] = 33;
+ Arrays.fill(CHARS, 2703, 2706, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[2706] = 33;
+ Arrays.fill(CHARS, 2707, 2729, (byte) -19 ); // Fill 22 of value (byte) -19
+ CHARS[2729] = 33;
+ Arrays.fill(CHARS, 2730, 2737, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[2737] = 33;
+ Arrays.fill(CHARS, 2738, 2740, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2740] = 33;
+ Arrays.fill(CHARS, 2741, 2746, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 2746, 2748, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[2748] = -87;
+ CHARS[2749] = -19;
+ Arrays.fill(CHARS, 2750, 2758, (byte) -87 ); // Fill 8 of value (byte) -87
+ CHARS[2758] = 33;
+ Arrays.fill(CHARS, 2759, 2762, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[2762] = 33;
+ Arrays.fill(CHARS, 2763, 2766, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2766, 2784, (byte) 33 ); // Fill 18 of value (byte) 33
+ CHARS[2784] = -19;
+ Arrays.fill(CHARS, 2785, 2790, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 2790, 2800, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2800, 2817, (byte) 33 ); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 2817, 2820, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[2820] = 33;
+ Arrays.fill(CHARS, 2821, 2829, (byte) -19 ); // Fill 8 of value (byte) -19
+ Arrays.fill(CHARS, 2829, 2831, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2831, 2833, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2833, 2835, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2835, 2857, (byte) -19 ); // Fill 22 of value (byte) -19
+ CHARS[2857] = 33;
+ Arrays.fill(CHARS, 2858, 2865, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[2865] = 33;
+ Arrays.fill(CHARS, 2866, 2868, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2868, 2870, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2870, 2874, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2874, 2876, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[2876] = -87;
+ CHARS[2877] = -19;
+ Arrays.fill(CHARS, 2878, 2884, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 2884, 2887, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2887, 2889, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2889, 2891, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 2891, 2894, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 2894, 2902, (byte) 33 ); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 2902, 2904, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 2904, 2908, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2908, 2910, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2910] = 33;
+ Arrays.fill(CHARS, 2911, 2914, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2914, 2918, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 2918, 2928, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 2928, 2946, (byte) 33 ); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 2946, 2948, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[2948] = 33;
+ Arrays.fill(CHARS, 2949, 2955, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 2955, 2958, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2958, 2961, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[2961] = 33;
+ Arrays.fill(CHARS, 2962, 2966, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 2966, 2969, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2969, 2971, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[2971] = 33;
+ CHARS[2972] = -19;
+ CHARS[2973] = 33;
+ Arrays.fill(CHARS, 2974, 2976, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2976, 2979, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2979, 2981, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 2981, 2984, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2984, 2987, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 2987, 2990, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 2990, 2998, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[2998] = 33;
+ Arrays.fill(CHARS, 2999, 3002, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 3002, 3006, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3006, 3011, (byte) -87 ); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 3011, 3014, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 3014, 3017, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[3017] = 33;
+ Arrays.fill(CHARS, 3018, 3022, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3022, 3031, (byte) 33 ); // Fill 9 of value (byte) 33
+ CHARS[3031] = -87;
+ Arrays.fill(CHARS, 3032, 3047, (byte) 33 ); // Fill 15 of value (byte) 33
+ Arrays.fill(CHARS, 3047, 3056, (byte) -87 ); // Fill 9 of value (byte) -87
+ Arrays.fill(CHARS, 3056, 3073, (byte) 33 ); // Fill 17 of value (byte) 33
+ Arrays.fill(CHARS, 3073, 3076, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[3076] = 33;
+ Arrays.fill(CHARS, 3077, 3085, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[3085] = 33;
+ Arrays.fill(CHARS, 3086, 3089, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[3089] = 33;
+ Arrays.fill(CHARS, 3090, 3113, (byte) -19 ); // Fill 23 of value (byte) -19
+ CHARS[3113] = 33;
+ Arrays.fill(CHARS, 3114, 3124, (byte) -19 ); // Fill 10 of value (byte) -19
+ CHARS[3124] = 33;
+ Arrays.fill(CHARS, 3125, 3130, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 3130, 3134, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3134, 3141, (byte) -87 ); // Fill 7 of value (byte) -87
+ CHARS[3141] = 33;
+ Arrays.fill(CHARS, 3142, 3145, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[3145] = 33;
+ Arrays.fill(CHARS, 3146, 3150, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3150, 3157, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3157, 3159, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3159, 3168, (byte) 33 ); // Fill 9 of value (byte) 33
+ Arrays.fill(CHARS, 3168, 3170, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3170, 3174, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3174, 3184, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3184, 3202, (byte) 33 ); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 3202, 3204, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[3204] = 33;
+ Arrays.fill(CHARS, 3205, 3213, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[3213] = 33;
+ Arrays.fill(CHARS, 3214, 3217, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[3217] = 33;
+ Arrays.fill(CHARS, 3218, 3241, (byte) -19 ); // Fill 23 of value (byte) -19
+ CHARS[3241] = 33;
+ Arrays.fill(CHARS, 3242, 3252, (byte) -19 ); // Fill 10 of value (byte) -19
+ CHARS[3252] = 33;
+ Arrays.fill(CHARS, 3253, 3258, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 3258, 3262, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3262, 3269, (byte) -87 ); // Fill 7 of value (byte) -87
+ CHARS[3269] = 33;
+ Arrays.fill(CHARS, 3270, 3273, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[3273] = 33;
+ Arrays.fill(CHARS, 3274, 3278, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3278, 3285, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3285, 3287, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3287, 3294, (byte) 33 ); // Fill 7 of value (byte) 33
+ CHARS[3294] = -19;
+ CHARS[3295] = 33;
+ Arrays.fill(CHARS, 3296, 3298, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3298, 3302, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3302, 3312, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3312, 3330, (byte) 33 ); // Fill 18 of value (byte) 33
+ Arrays.fill(CHARS, 3330, 3332, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[3332] = 33;
+ Arrays.fill(CHARS, 3333, 3341, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[3341] = 33;
+ Arrays.fill(CHARS, 3342, 3345, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[3345] = 33;
+ Arrays.fill(CHARS, 3346, 3369, (byte) -19 ); // Fill 23 of value (byte) -19
+ CHARS[3369] = 33;
+ Arrays.fill(CHARS, 3370, 3386, (byte) -19 ); // Fill 16 of value (byte) -19
+ Arrays.fill(CHARS, 3386, 3390, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3390, 3396, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3396, 3398, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3398, 3401, (byte) -87 ); // Fill 3 of value (byte) -87
+ CHARS[3401] = 33;
+ Arrays.fill(CHARS, 3402, 3406, (byte) -87 ); // Fill 4 of value (byte) -87
+ Arrays.fill(CHARS, 3406, 3415, (byte) 33 ); // Fill 9 of value (byte) 33
+ CHARS[3415] = -87;
+ Arrays.fill(CHARS, 3416, 3424, (byte) 33 ); // Fill 8 of value (byte) 33
+ Arrays.fill(CHARS, 3424, 3426, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3426, 3430, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3430, 3440, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3440, 3585, (byte) 33 ); // Fill 145 of value (byte) 33
+ Arrays.fill(CHARS, 3585, 3631, (byte) -19 ); // Fill 46 of value (byte) -19
+ CHARS[3631] = 33;
+ CHARS[3632] = -19;
+ CHARS[3633] = -87;
+ Arrays.fill(CHARS, 3634, 3636, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3636, 3643, (byte) -87 ); // Fill 7 of value (byte) -87
+ Arrays.fill(CHARS, 3643, 3648, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 3648, 3654, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 3654, 3663, (byte) -87 ); // Fill 9 of value (byte) -87
+ CHARS[3663] = 33;
+ Arrays.fill(CHARS, 3664, 3674, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3674, 3713, (byte) 33 ); // Fill 39 of value (byte) 33
+ Arrays.fill(CHARS, 3713, 3715, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[3715] = 33;
+ CHARS[3716] = -19;
+ Arrays.fill(CHARS, 3717, 3719, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3719, 3721, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[3721] = 33;
+ CHARS[3722] = -19;
+ Arrays.fill(CHARS, 3723, 3725, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[3725] = -19;
+ Arrays.fill(CHARS, 3726, 3732, (byte) 33 ); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 3732, 3736, (byte) -19 ); // Fill 4 of value (byte) -19
+ CHARS[3736] = 33;
+ Arrays.fill(CHARS, 3737, 3744, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[3744] = 33;
+ Arrays.fill(CHARS, 3745, 3748, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[3748] = 33;
+ CHARS[3749] = -19;
+ CHARS[3750] = 33;
+ CHARS[3751] = -19;
+ Arrays.fill(CHARS, 3752, 3754, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3754, 3756, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[3756] = 33;
+ Arrays.fill(CHARS, 3757, 3759, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[3759] = 33;
+ CHARS[3760] = -19;
+ CHARS[3761] = -87;
+ Arrays.fill(CHARS, 3762, 3764, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 3764, 3770, (byte) -87 ); // Fill 6 of value (byte) -87
+ CHARS[3770] = 33;
+ Arrays.fill(CHARS, 3771, 3773, (byte) -87 ); // Fill 2 of value (byte) -87
+ CHARS[3773] = -19;
+ Arrays.fill(CHARS, 3774, 3776, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3776, 3781, (byte) -19 ); // Fill 5 of value (byte) -19
+ CHARS[3781] = 33;
+ CHARS[3782] = -87;
+ CHARS[3783] = 33;
+ Arrays.fill(CHARS, 3784, 3790, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3790, 3792, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 3792, 3802, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3802, 3864, (byte) 33 ); // Fill 62 of value (byte) 33
+ Arrays.fill(CHARS, 3864, 3866, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3866, 3872, (byte) 33 ); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 3872, 3882, (byte) -87 ); // Fill 10 of value (byte) -87
+ Arrays.fill(CHARS, 3882, 3893, (byte) 33 ); // Fill 11 of value (byte) 33
+ CHARS[3893] = -87;
+ CHARS[3894] = 33;
+ CHARS[3895] = -87;
+ CHARS[3896] = 33;
+ CHARS[3897] = -87;
+ Arrays.fill(CHARS, 3898, 3902, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3902, 3904, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 3904, 3912, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[3912] = 33;
+ Arrays.fill(CHARS, 3913, 3946, (byte) -19 ); // Fill 33 of value (byte) -19
+ Arrays.fill(CHARS, 3946, 3953, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 3953, 3973, (byte) -87 ); // Fill 20 of value (byte) -87
+ CHARS[3973] = 33;
+ Arrays.fill(CHARS, 3974, 3980, (byte) -87 ); // Fill 6 of value (byte) -87
+ Arrays.fill(CHARS, 3980, 3984, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 3984, 3990, (byte) -87 ); // Fill 6 of value (byte) -87
+ CHARS[3990] = 33;
+ CHARS[3991] = -87;
+ CHARS[3992] = 33;
+ Arrays.fill(CHARS, 3993, 4014, (byte) -87 ); // Fill 21 of value (byte) -87
+ Arrays.fill(CHARS, 4014, 4017, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4017, 4024, (byte) -87 ); // Fill 7 of value (byte) -87
+ CHARS[4024] = 33;
+ CHARS[4025] = -87;
+ Arrays.fill(CHARS, 4026, 4256, (byte) 33 ); // Fill 230 of value (byte) 33
+ Arrays.fill(CHARS, 4256, 4294, (byte) -19 ); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 4294, 4304, (byte) 33 ); // Fill 10 of value (byte) 33
+ Arrays.fill(CHARS, 4304, 4343, (byte) -19 ); // Fill 39 of value (byte) -19
+ Arrays.fill(CHARS, 4343, 4352, (byte) 33 ); // Fill 9 of value (byte) 33
+ CHARS[4352] = -19;
+ CHARS[4353] = 33;
+ Arrays.fill(CHARS, 4354, 4356, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[4356] = 33;
+ Arrays.fill(CHARS, 4357, 4360, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[4360] = 33;
+ CHARS[4361] = -19;
+ CHARS[4362] = 33;
+ Arrays.fill(CHARS, 4363, 4365, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[4365] = 33;
+ Arrays.fill(CHARS, 4366, 4371, (byte) -19 ); // Fill 5 of value (byte) -19
+ Arrays.fill(CHARS, 4371, 4412, (byte) 33 ); // Fill 41 of value (byte) 33
+ CHARS[4412] = -19;
+ CHARS[4413] = 33;
+ CHARS[4414] = -19;
+ CHARS[4415] = 33;
+ CHARS[4416] = -19;
+ Arrays.fill(CHARS, 4417, 4428, (byte) 33 ); // Fill 11 of value (byte) 33
+ CHARS[4428] = -19;
+ CHARS[4429] = 33;
+ CHARS[4430] = -19;
+ CHARS[4431] = 33;
+ CHARS[4432] = -19;
+ Arrays.fill(CHARS, 4433, 4436, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4436, 4438, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4438, 4441, (byte) 33 ); // Fill 3 of value (byte) 33
+ CHARS[4441] = -19;
+ Arrays.fill(CHARS, 4442, 4447, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 4447, 4450, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[4450] = 33;
+ CHARS[4451] = -19;
+ CHARS[4452] = 33;
+ CHARS[4453] = -19;
+ CHARS[4454] = 33;
+ CHARS[4455] = -19;
+ CHARS[4456] = 33;
+ CHARS[4457] = -19;
+ Arrays.fill(CHARS, 4458, 4461, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4461, 4463, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4463, 4466, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 4466, 4468, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[4468] = 33;
+ CHARS[4469] = -19;
+ Arrays.fill(CHARS, 4470, 4510, (byte) 33 ); // Fill 40 of value (byte) 33
+ CHARS[4510] = -19;
+ Arrays.fill(CHARS, 4511, 4520, (byte) 33 ); // Fill 9 of value (byte) 33
+ CHARS[4520] = -19;
+ Arrays.fill(CHARS, 4521, 4523, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[4523] = -19;
+ Arrays.fill(CHARS, 4524, 4526, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 4526, 4528, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 4528, 4535, (byte) 33 ); // Fill 7 of value (byte) 33
+ Arrays.fill(CHARS, 4535, 4537, (byte) -19 ); // Fill 2 of value (byte) -19
+ CHARS[4537] = 33;
+ CHARS[4538] = -19;
+ CHARS[4539] = 33;
+ Arrays.fill(CHARS, 4540, 4547, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 4547, 4587, (byte) 33 ); // Fill 40 of value (byte) 33
+ CHARS[4587] = -19;
+ Arrays.fill(CHARS, 4588, 4592, (byte) 33 ); // Fill 4 of value (byte) 33
+ CHARS[4592] = -19;
+ Arrays.fill(CHARS, 4593, 4601, (byte) 33 ); // Fill 8 of value (byte) 33
+ CHARS[4601] = -19;
+ Arrays.fill(CHARS, 4602, 7680, (byte) 33 ); // Fill 3078 of value (byte) 33
+ Arrays.fill(CHARS, 7680, 7836, (byte) -19 ); // Fill 156 of value (byte) -19
+ Arrays.fill(CHARS, 7836, 7840, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 7840, 7930, (byte) -19 ); // Fill 90 of value (byte) -19
+ Arrays.fill(CHARS, 7930, 7936, (byte) 33 ); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 7936, 7958, (byte) -19 ); // Fill 22 of value (byte) -19
+ Arrays.fill(CHARS, 7958, 7960, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 7960, 7966, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 7966, 7968, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 7968, 8006, (byte) -19 ); // Fill 38 of value (byte) -19
+ Arrays.fill(CHARS, 8006, 8008, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8008, 8014, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 8014, 8016, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8016, 8024, (byte) -19 ); // Fill 8 of value (byte) -19
+ CHARS[8024] = 33;
+ CHARS[8025] = -19;
+ CHARS[8026] = 33;
+ CHARS[8027] = -19;
+ CHARS[8028] = 33;
+ CHARS[8029] = -19;
+ CHARS[8030] = 33;
+ Arrays.fill(CHARS, 8031, 8062, (byte) -19 ); // Fill 31 of value (byte) -19
+ Arrays.fill(CHARS, 8062, 8064, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8064, 8117, (byte) -19 ); // Fill 53 of value (byte) -19
+ CHARS[8117] = 33;
+ Arrays.fill(CHARS, 8118, 8125, (byte) -19 ); // Fill 7 of value (byte) -19
+ CHARS[8125] = 33;
+ CHARS[8126] = -19;
+ Arrays.fill(CHARS, 8127, 8130, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8130, 8133, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[8133] = 33;
+ Arrays.fill(CHARS, 8134, 8141, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 8141, 8144, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8144, 8148, (byte) -19 ); // Fill 4 of value (byte) -19
+ Arrays.fill(CHARS, 8148, 8150, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 8150, 8156, (byte) -19 ); // Fill 6 of value (byte) -19
+ Arrays.fill(CHARS, 8156, 8160, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 8160, 8173, (byte) -19 ); // Fill 13 of value (byte) -19
+ Arrays.fill(CHARS, 8173, 8178, (byte) 33 ); // Fill 5 of value (byte) 33
+ Arrays.fill(CHARS, 8178, 8181, (byte) -19 ); // Fill 3 of value (byte) -19
+ CHARS[8181] = 33;
+ Arrays.fill(CHARS, 8182, 8189, (byte) -19 ); // Fill 7 of value (byte) -19
+ Arrays.fill(CHARS, 8189, 8400, (byte) 33 ); // Fill 211 of value (byte) 33
+ Arrays.fill(CHARS, 8400, 8413, (byte) -87 ); // Fill 13 of value (byte) -87
+ Arrays.fill(CHARS, 8413, 8417, (byte) 33 ); // Fill 4 of value (byte) 33
+ CHARS[8417] = -87;
+ Arrays.fill(CHARS, 8418, 8486, (byte) 33 ); // Fill 68 of value (byte) 33
+ CHARS[8486] = -19;
+ Arrays.fill(CHARS, 8487, 8490, (byte) 33 ); // Fill 3 of value (byte) 33
+ Arrays.fill(CHARS, 8490, 8492, (byte) -19 ); // Fill 2 of value (byte) -19
+ Arrays.fill(CHARS, 8492, 8494, (byte) 33 ); // Fill 2 of value (byte) 33
+ CHARS[8494] = -19;
+ Arrays.fill(CHARS, 8495, 8576, (byte) 33 ); // Fill 81 of value (byte) 33
+ Arrays.fill(CHARS, 8576, 8579, (byte) -19 ); // Fill 3 of value (byte) -19
+ Arrays.fill(CHARS, 8579, 12293, (byte) 33 ); // Fill 3714 of value (byte) 33
+ CHARS[12293] = -87;
+ CHARS[12294] = 33;
+ CHARS[12295] = -19;
+ Arrays.fill(CHARS, 12296, 12321, (byte) 33 ); // Fill 25 of value (byte) 33
+ Arrays.fill(CHARS, 12321, 12330, (byte) -19 ); // Fill 9 of value (byte) -19
+ Arrays.fill(CHARS, 12330, 12336, (byte) -87 ); // Fill 6 of value (byte) -87
+ CHARS[12336] = 33;
+ Arrays.fill(CHARS, 12337, 12342, (byte) -87 ); // Fill 5 of value (byte) -87
+ Arrays.fill(CHARS, 12342, 12353, (byte) 33 ); // Fill 11 of value (byte) 33
+ Arrays.fill(CHARS, 12353, 12437, (byte) -19 ); // Fill 84 of value (byte) -19
+ Arrays.fill(CHARS, 12437, 12441, (byte) 33 ); // Fill 4 of value (byte) 33
+ Arrays.fill(CHARS, 12441, 12443, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 12443, 12445, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 12445, 12447, (byte) -87 ); // Fill 2 of value (byte) -87
+ Arrays.fill(CHARS, 12447, 12449, (byte) 33 ); // Fill 2 of value (byte) 33
+ Arrays.fill(CHARS, 12449, 12539, (byte) -19 ); // Fill 90 of value (byte) -19
+ CHARS[12539] = 33;
+ Arrays.fill(CHARS, 12540, 12543, (byte) -87 ); // Fill 3 of value (byte) -87
+ Arrays.fill(CHARS, 12543, 12549, (byte) 33 ); // Fill 6 of value (byte) 33
+ Arrays.fill(CHARS, 12549, 12589, (byte) -19 ); // Fill 40 of value (byte) -19
+ Arrays.fill(CHARS, 12589, 19968, (byte) 33 ); // Fill 7379 of value (byte) 33
+ Arrays.fill(CHARS, 19968, 40870, (byte) -19 ); // Fill 20902 of value (byte) -19
+ Arrays.fill(CHARS, 40870, 44032, (byte) 33 ); // Fill 3162 of value (byte) 33
+ Arrays.fill(CHARS, 44032, 55204, (byte) -19 ); // Fill 11172 of value (byte) -19
+ Arrays.fill(CHARS, 55204, 55296, (byte) 33 ); // Fill 92 of value (byte) 33
+ Arrays.fill(CHARS, 57344, 65534, (byte) 33 ); // Fill 8190 of value (byte) 33
+
+ } // <clinit>()
+
+ //
+ // Public static methods
+ //
+
+ /**
+ * Returns true if the specified character is a supplemental character.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isSupplemental(int c) {
+ return (c >= 0x10000 && c <= 0x10FFFF);
+ }
+
+ /**
+ * Returns true the supplemental character corresponding to the given
+ * surrogates.
+ *
+ * @param h The high surrogate.
+ * @param l The low surrogate.
+ */
+ public static int supplemental(char h, char l) {
+ return (h - 0xD800) * 0x400 + (l - 0xDC00) + 0x10000;
+ }
+
+ /**
+ * Returns the high surrogate of a supplemental character
+ *
+ * @param c The supplemental character to "split".
+ */
+ public static char highSurrogate(int c) {
+ return (char) (((c - 0x00010000) >> 10) + 0xD800);
+ }
+
+ /**
+ * Returns the low surrogate of a supplemental character
+ *
+ * @param c The supplemental character to "split".
+ */
+ public static char lowSurrogate(int c) {
+ return (char) (((c - 0x00010000) & 0x3FF) + 0xDC00);
+ }
+
+ /**
+ * Returns whether the given character is a high surrogate
+ *
+ * @param c The character to check.
+ */
+ public static boolean isHighSurrogate(int c) {
+ return (0xD800 <= c && c <= 0xDBFF);
+ }
+
+ /**
+ * Returns whether the given character is a low surrogate
+ *
+ * @param c The character to check.
+ */
+ public static boolean isLowSurrogate(int c) {
+ return (0xDC00 <= c && c <= 0xDFFF);
+ }
+
+
+ /**
+ * Returns true if the specified character is valid. This method
+ * also checks the surrogate character range from 0x10000 to 0x10FFFF.
+ * <p>
+ * If the program chooses to apply the mask directly to the
+ * <code>CHARS</code> array, then they are responsible for checking
+ * the surrogate character range.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isValid(int c) {
+ return (c < 0x10000 && (CHARS[c] & MASK_VALID) != 0) ||
+ (0x10000 <= c && c <= 0x10FFFF);
+ } // isValid(int):boolean
+
+ /**
+ * Returns true if the specified character is invalid.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isInvalid(int c) {
+ return !isValid(c);
+ } // isInvalid(int):boolean
+
+ /**
+ * Returns true if the specified character can be considered content.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isContent(int c) {
+ return (c < 0x10000 && (CHARS[c] & MASK_CONTENT) != 0) ||
+ (0x10000 <= c && c <= 0x10FFFF);
+ } // isContent(int):boolean
+
+ /**
+ * Returns true if the specified character can be considered markup.
+ * Markup characters include '<', '&', and '%'.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isMarkup(int c) {
+ return c == '<' || c == '&' || c == '%';
+ } // isMarkup(int):boolean
+
+ /**
+ * Returns true if the specified character is a space character
+ * as defined by production [3] in the XML 1.0 specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isSpace(int c) {
+ return c <= 0x20 && (CHARS[c] & MASK_SPACE) != 0;
+ } // isSpace(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid name start
+ * character as defined by production [5] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNameStart(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NAME_START) != 0;
+ } // isNameStart(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid name
+ * character as defined by production [4] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isName(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NAME) != 0;
+ } // isName(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid NCName start
+ * character as defined by production [4] in Namespaces in XML
+ * recommendation.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNCNameStart(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NCNAME_START) != 0;
+ } // isNCNameStart(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid NCName
+ * character as defined by production [5] in Namespaces in XML
+ * recommendation.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isNCName(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_NCNAME) != 0;
+ } // isNCName(int):boolean
+
+ /**
+ * Returns true if the specified character is a valid Pubid
+ * character as defined by production [13] in the XML 1.0
+ * specification.
+ *
+ * @param c The character to check.
+ */
+ public static boolean isPubid(int c) {
+ return c < 0x10000 && (CHARS[c] & MASK_PUBID) != 0;
+ } // isPubid(int):boolean
+
+ /*
+ * [5] Name ::= (Letter | '_' | ':') (NameChar)*
+ */
+ /**
+ * Check to see if a string is a valid Name according to [5]
+ * in the XML 1.0 Recommendation
+ *
+ * @param name string to check
+ * @return true if name is a valid Name
+ */
+ public static boolean isValidName(String name) {
+ final int length = name.length();
+ if (length == 0) {
+ return false;
+ }
+ char ch = name.charAt(0);
+ if (!isNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < length; ++i) {
+ ch = name.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidName(String):boolean
+
+ /*
+ * from the namespace rec
+ * [4] NCName ::= (Letter | '_') (NCNameChar)*
+ */
+ /**
+ * Check to see if a string is a valid NCName according to [4]
+ * from the XML Namespaces 1.0 Recommendation
+ *
+ * @param ncName string to check
+ * @return true if name is a valid NCName
+ */
+ public static boolean isValidNCName(String ncName) {
+ final int length = ncName.length();
+ if (length == 0) {
+ return false;
+ }
+ char ch = ncName.charAt(0);
+ if (!isNCNameStart(ch)) {
+ return false;
+ }
+ for (int i = 1; i < length; ++i) {
+ ch = ncName.charAt(i);
+ if (!isNCName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidNCName(String):boolean
+
+ /*
+ * [7] Nmtoken ::= (NameChar)+
+ */
+ /**
+ * Check to see if a string is a valid Nmtoken according to [7]
+ * in the XML 1.0 Recommendation
+ *
+ * @param nmtoken string to check
+ * @return true if nmtoken is a valid Nmtoken
+ */
+ public static boolean isValidNmtoken(String nmtoken) {
+ final int length = nmtoken.length();
+ if (length == 0) {
+ return false;
+ }
+ for (int i = 0; i < length; ++i) {
+ char ch = nmtoken.charAt(i);
+ if (!isName(ch)) {
+ return false;
+ }
+ }
+ return true;
+ } // isValidName(String):boolean
+
+
+
+
+
+ // encodings
+
+ /**
+ * Returns true if the encoding name is a valid IANA encoding.
+ * This method does not verify that there is a decoder available
+ * for this encoding, only that the characters are valid for an
+ * IANA encoding name.
+ *
+ * @param ianaEncoding The IANA encoding name.
+ */
+ public static boolean isValidIANAEncoding(String ianaEncoding) {
+ if (ianaEncoding != null) {
+ int length = ianaEncoding.length();
+ if (length > 0) {
+ char c = ianaEncoding.charAt(0);
+ if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')) {
+ for (int i = 1; i < length; i++) {
+ c = ianaEncoding.charAt(i);
+ if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
+ (c < '0' || c > '9') && c != '.' && c != '_' &&
+ c != '-') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ }
+ return false;
+ } // isValidIANAEncoding(String):boolean
+
+ /**
+ * Returns true if the encoding name is a valid Java encoding.
+ * This method does not verify that there is a decoder available
+ * for this encoding, only that the characters are valid for an
+ * Java encoding name.
+ *
+ * @param javaEncoding The Java encoding name.
+ */
+ public static boolean isValidJavaEncoding(String javaEncoding) {
+ if (javaEncoding != null) {
+ int length = javaEncoding.length();
+ if (length > 0) {
+ for (int i = 1; i < length; i++) {
+ char c = javaEncoding.charAt(i);
+ if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z') &&
+ (c < '0' || c > '9') && c != '.' && c != '_' &&
+ c != '-') {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+ return false;
+ } // isValidIANAEncoding(String):boolean
+
+ // other methods
+
+ /**
+ * Trims space characters as defined by production [3] in
+ * the XML 1.0 specification from both ends of the given string.
+ *
+ * @param value the string to be trimmed
+ * @return the given string with the space characters trimmed
+ * from both ends
+ */
+ public static String trim(String value) {
+ int start;
+ int end;
+ final int lengthMinusOne = value.length() - 1;
+ for (start = 0; start <= lengthMinusOne; ++start) {
+ if (!isSpace(value.charAt(start))) {
+ break;
+ }
+ }
+ for (end = lengthMinusOne; end >= start; --end) {
+ if (!isSpace(value.charAt(end))) {
+ break;
+ }
+ }
+ if (start == 0 && end == lengthMinusOne) {
+ return value;
+ }
+ if (start > lengthMinusOne) {
+ return "";
+ }
+ return value.substring(start, end + 1);
+ } // trim(String):String
+
+} // class XMLChar
diff --git a/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java b/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java
index 128f32f6..a8541794 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/XmlWriter.java
@@ -18,10 +18,9 @@
*/
package org.apache.rat.report.xml.writer;
+import java.io.Closeable;
import java.io.IOException;
-import java.io.Writer;
import java.util.ArrayDeque;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@@ -40,368 +39,7 @@ import java.util.Set;
@SuppressWarnings({"checkstyle:MagicNumber", "checkstyle:JavadocVariable"})
public final class XmlWriter implements IXmlWriter {
- private static final byte NAME_START_MASK = 1 << 1;
- private static final byte NAME_MASK = 1 << 2;
- private static final byte NAME_BODY_CHAR = NAME_MASK;
- private static final byte NAME_START_OR_BODY_CHAR = NAME_MASK | NAME_START_MASK;
-
- private static final boolean[] ALLOWED_CHARACTERS = new boolean[1 << 16];
-
- static {
- Arrays.fill(ALLOWED_CHARACTERS, false);
- ALLOWED_CHARACTERS[0x9] = true;
- ALLOWED_CHARACTERS[0xA] = true;
- ALLOWED_CHARACTERS[0xD] = true;
- Arrays.fill(ALLOWED_CHARACTERS, 0x20, 0xD7FF, true);
- Arrays.fill(ALLOWED_CHARACTERS, 0xE000, 0xFFFD, true);
- }
-
- private static final byte[] CHARACTER_CODES = new byte[1 << 16];
-
- static {
- // Name ::= (Letter | '_' | ':') (NameChar)*
- CHARACTER_CODES['_'] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[':'] = NAME_START_OR_BODY_CHAR;
- // Letter ::= BaseChar | Ideographic
- // BaseChar
- Arrays.fill(CHARACTER_CODES, 0x0041, 0x005A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0061, 0x007A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x00C0, 0x00D6, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x00D8, 0x00F6, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x00F8, 0x00FF, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0100, 0x0131, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0134, 0x013E, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0141, 0x0148, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x014A, 0x017E, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0180, 0x01C3, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x01CD, 0x01F0, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x01F4, 0x01F5, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x01FA, 0x0217, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0250, 0x02A8, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x02BB, 0x02C1, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0386] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0388, 0x038A, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x038C] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x038E, 0x03A1, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x03A3, 0x03CE, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x03D0, 0x03D6, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x03DA] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x03DC] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x03DE] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x03E0] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x03E2, 0x03F3, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0401, 0x040C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x040E, 0x044F, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0451, 0x045C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x045E, 0x0481, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0490, 0x04C4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x04C7, 0x04C8, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x04CB, 0x04CC, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x04D0, 0x04EB, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x04EE, 0x04F5, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x04F8, 0x04F9, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0531, 0x0556, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0559] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0561, 0x0586, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x05D0, 0x05EA, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x05F0, 0x05F2, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0621, 0x063A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0641, 0x064A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0671, 0x06B7, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06BA, 0x06BE, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06C0, 0x06CE, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06D0, 0x06D3, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x06D5] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x06E5, 0x06E6, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0905, 0x0939, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x093D] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0958, 0x0961, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0985, 0x098C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x098F, 0x0990, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0993, 0x09A8, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09AA, 0x09B0, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x09B2] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x09B6, 0x09B9, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09DC, 0x09DD, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09DF, 0x09E1, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09F0, 0x09F1, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A05, 0x0A0A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A0F, 0x0A10, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A13, 0x0A28, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A2A, 0x0A30, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A32, 0x0A33, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A35, 0x0A36, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A38, 0x0A39, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A59, 0x0A5C, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0A5E] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0A72, 0x0A74, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A85, 0x0A8B, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0A8D] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0A8F, 0x0A91, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A93, 0x0AA8, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0AAA, 0x0AB0, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0AB2, 0x0AB3, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0AB5, 0x0AB9, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0ABD] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x0AE0] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0B05, 0x0B0C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B0F, 0x0B10, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B13, 0x0B28, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B2A, 0x0B30, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B32, 0x0B33, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B36, 0x0B39, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0B3D] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0B5C, 0x0B5D, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B5F, 0x0B61, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B85, 0x0B8A, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B8E, 0x0B90, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B92, 0x0B95, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B99, 0x0B9A, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0B9C] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0B9E, 0x0B9F, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BA3, 0x0BA4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BA8, 0x0BAA, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BAE, 0x0BB5, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BB7, 0x0BB9, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C05, 0x0C0C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C0E, 0x0C10, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C12, 0x0C28, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C2A, 0x0C33, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C35, 0x0C39, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C60, 0x0C61, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C85, 0x0C8C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C8E, 0x0C90, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C92, 0x0CA8, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CAA, 0x0CB3, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CB5, 0x0CB9, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0CDE] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0CE0, 0x0CE1, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D05, 0x0D0C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D0E, 0x0D10, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D12, 0x0D28, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D2A, 0x0D39, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D60, 0x0D61, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E01, 0x0E2E, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0E30] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0E32, 0x0E33, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E40, 0x0E45, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E81, 0x0E82, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0E84] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0E87, 0x0E88, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0E8A] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x0E8D] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0E94, 0x0E97, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E99, 0x0E9F, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0EA1, 0x0EA3, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0EA5] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x0EA7] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0EAA, 0x0EAB, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0EAD, 0x0EAE, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0EB0] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0EB2, 0x0EB3, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x0EBD] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0EC0, 0x0EC4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F40, 0x0F47, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F49, 0x0F69, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x10A0, 0x10C5, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x10D0, 0x10F6, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1100] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x1102, 0x1103, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1105, 0x1107, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1109] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x110B, 0x110C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x110E, 0x1112, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x113C] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x113E] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1140] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x114C] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x114E] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1150] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x1154, 0x1155, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1159] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x115F, 0x1161, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1163] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1165] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1167] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1169] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x116D, 0x116E, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1172, 0x1173, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1175] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x119E] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x11A8] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x11AB] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x11AE, 0x11AF, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x11B7, 0x11B8, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x11BA] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x11BC, 0x11C2, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x11EB] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x11F0] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x11F9] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x1E00, 0x1E9B, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1EA0, 0x1EF9, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F00, 0x1F15, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F18, 0x1F1D, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F20, 0x1F45, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F48, 0x1F4D, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F50, 0x1F57, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1F59] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1F5B] = NAME_START_OR_BODY_CHAR;
- CHARACTER_CODES[0x1F5D] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x1F5F, 0x1F7D, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1F80, 0x1FB4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FB6, 0x1FBC, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x1FBE] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x1FC2, 0x1FC4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FC6, 0x1FCC, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FD0, 0x1FD3, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FD6, 0x1FDB, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FE0, 0x1FEC, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FF2, 0x1FF4, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x1FF6, 0x1FFC, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x2126] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x212A, 0x212B, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x212E] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x2180, 0x2182, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x3041, 0x3094, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x30A1, 0x30FA, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x3105, 0x312C, NAME_START_OR_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0xAC00, 0xD7A3, NAME_START_OR_BODY_CHAR);
- // Ideographic
- Arrays.fill(CHARACTER_CODES, 0x4E00, 0x9FA5, NAME_START_OR_BODY_CHAR);
- CHARACTER_CODES[0x3007] = NAME_START_OR_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x3021, 0x3029, NAME_START_OR_BODY_CHAR);
- // NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar |
- // Extender
- CHARACTER_CODES['.'] = NAME_BODY_CHAR;
- CHARACTER_CODES['-'] = NAME_BODY_CHAR;
- // CombiningChar
- Arrays.fill(CHARACTER_CODES, 0x0300, 0x0345, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0360, 0x0361, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0483, 0x0486, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0591, 0x05A1, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x05A3, 0x05B9, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x05BB, 0x05BD, NAME_BODY_CHAR);
- CHARACTER_CODES[0x05BF] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x05C1, 0x05C2, NAME_BODY_CHAR);
- CHARACTER_CODES[0x05C4] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x064B, 0x0652, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0670] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x06D6, 0x06DC, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06DD, 0x06DF, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06E0, 0x06E4, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06E7, 0x06E8, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06EA, 0x06ED, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0901, 0x0903, NAME_BODY_CHAR);
- CHARACTER_CODES[0x093C] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x093E, 0x094C, NAME_BODY_CHAR);
- CHARACTER_CODES[0x094D] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0951, 0x0954, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0962, 0x0963, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0981, 0x0983, NAME_BODY_CHAR);
- CHARACTER_CODES[0x09BC] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x09BE] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x09BF] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x09C0, 0x09C4, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09C7, 0x09C8, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09CB, 0x09CD, NAME_BODY_CHAR);
- CHARACTER_CODES[0x09D7] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x09E2, 0x09E3, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0A02] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0A3C] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0A3E] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0A3F] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0A40, 0x0A42, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A47, 0x0A48, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A4B, 0x0A4D, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A70, 0x0A71, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A81, 0x0A83, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0ABC] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0ABE, 0x0AC5, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0AC7, 0x0AC9, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0ACB, 0x0ACD, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B01, 0x0B03, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0B3C] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0B3E, 0x0B43, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B47, 0x0B48, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B4B, 0x0B4D, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B56, 0x0B57, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B82, 0x0B83, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BBE, 0x0BC2, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BC6, 0x0BC8, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BCA, 0x0BCD, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0BD7] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0C01, 0x0C03, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C3E, 0x0C44, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C46, 0x0C48, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C4A, 0x0C4D, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C55, 0x0C56, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C82, 0x0C83, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CBE, 0x0CC4, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CC6, 0x0CC8, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CCA, 0x0CCD, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CD5, 0x0CD6, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D02, 0x0D03, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D3E, 0x0D43, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D46, 0x0D48, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D4A, 0x0D4D, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0D57] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0E31] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0E34, 0x0E3A, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E47, 0x0E4E, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0EB1] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0EB4, 0x0EB9, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0EBB, 0x0EBC, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0EC8, 0x0ECD, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F18, 0x0F19, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0F35] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0F37] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0F39] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0F3E] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0F3F] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0F71, 0x0F84, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F86, 0x0F8B, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F90, 0x0F95, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0F97] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x0F99, 0x0FAD, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0FB1, 0x0FB7, NAME_BODY_CHAR);
- CHARACTER_CODES[0x0FB9] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x20D0, 0x20DC, NAME_BODY_CHAR);
- CHARACTER_CODES[0x20E1] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x302A, 0x302F, NAME_BODY_CHAR);
- CHARACTER_CODES[0x3099] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x309A] = NAME_BODY_CHAR;
- // Digit
- Arrays.fill(CHARACTER_CODES, 0x0030, 0x0039, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0660, 0x0669, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x06F0, 0x06F9, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0966, 0x096F, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x09E6, 0x09EF, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0A66, 0x0A6F, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0AE6, 0x0AEF, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0B66, 0x0B6F, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0BE7, 0x0BEF, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0C66, 0x0C6F, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0CE6, 0x0CEF, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0D66, 0x0D6F, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0E50, 0x0E59, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0ED0, 0x0ED9, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x0F20, 0x0F29, NAME_BODY_CHAR);
- // Extender
- CHARACTER_CODES[0x00B7] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x02D0] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x02D1] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0387] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0640] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0E46] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x0EC6] = NAME_BODY_CHAR;
- CHARACTER_CODES[0x3005] = NAME_BODY_CHAR;
- Arrays.fill(CHARACTER_CODES, 0x3031, 0x3035, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x309D, 0x309E, NAME_BODY_CHAR);
- Arrays.fill(CHARACTER_CODES, 0x30FC, 0x30FE, NAME_BODY_CHAR);
-
- }
-
- private final Writer writer;
+ private final Appendable writer;
private final ArrayDeque<CharSequence> elementNames;
private final Set<CharSequence> currentAttributes = new HashSet<>();
@@ -413,7 +51,7 @@ public final class XmlWriter implements IXmlWriter {
* Constructs an XmlWriter with the specified writer for output.
* @param writer the writer to write to.
*/
- public XmlWriter(final Writer writer) {
+ public XmlWriter(final Appendable writer) {
this.writer = writer;
this.elementNames = new ArrayDeque<>();
}
@@ -434,7 +72,7 @@ public final class XmlWriter implements IXmlWriter {
if (prologWritten) {
throw new OperationNotAllowedException("Only one prolog allowed");
}
- writer.write("<?xml version='1.0'?>");
+ writer.append("<?xml version='1.0'?>");
prologWritten = true;
return this;
}
@@ -453,15 +91,15 @@ public final class XmlWriter implements IXmlWriter {
if (elementsWritten && elementNames.isEmpty()) {
throw new OperationNotAllowedException("Root element already closed. Cannot open new element.");
}
- if (isInvalidName(elementName)) {
+ if (!XMLChar.isValidName(elementName.toString())) {
throw new InvalidXmlException("'" + elementName + "' is not a valid element name");
}
elementsWritten = true;
if (inElement) {
- writer.write('>');
+ writer.append('>');
}
- writer.write('<');
- rawWrite(elementName);
+ writer.append('<');
+ writer.append(elementName);
inElement = true;
elementNames.push(elementName);
currentAttributes.clear();
@@ -471,12 +109,12 @@ public final class XmlWriter implements IXmlWriter {
@Override
public IXmlWriter comment(final CharSequence text) throws IOException {
if (inElement) {
- writer.write('>');
+ writer.append('>');
}
inElement = false;
- writer.write("<!-- ");
- content(text);
- writer.write(" -->");
+ writer.append("<!-- ");
+ writeEscaped(text, false);
+ writer.append(" -->");
return this;
}
@@ -501,7 +139,7 @@ public final class XmlWriter implements IXmlWriter {
}
throw new OperationNotAllowedException("Close called before an element has been opened.");
}
- if (isInvalidName(name)) {
+ if (!XMLChar.isValidName(name.toString())) {
throw new InvalidXmlException("'" + name + "' is not a valid attribute name.");
}
if (!inElement) {
@@ -510,12 +148,11 @@ public final class XmlWriter implements IXmlWriter {
if (currentAttributes.contains(name)) {
throw new InvalidXmlException("Each attribute can only be written once");
}
- writer.write(' ');
- rawWrite(name);
- writer.write('=');
- writer.write('\'');
+ writer.append(' ');
+ writer.append(name);
+ writer.append("='");
writeAttributeContent(value);
- writer.write('\'');
+ writer.append("'");
currentAttributes.add(name);
return this;
}
@@ -532,7 +169,7 @@ public final class XmlWriter implements IXmlWriter {
throw new OperationNotAllowedException("An element must be opened before content can be written.");
}
if (inElement) {
- writer.write('>');
+ writer.append('>');
}
}
@@ -553,16 +190,16 @@ public final class XmlWriter implements IXmlWriter {
sb.replace(found, found + 3, "{rat:CDATA close}");
}
- writer.write("<![CDATA[ ");
+ writer.append("<![CDATA[ ");
for (int i = 0; i < sb.length(); i++) {
char c = sb.charAt(i);
- if (isOutOfRange(c)) {
- writer.write(String.format("\\u%X", (int) c));
+ if (!XMLChar.isContent(c)) {
+ writer.append(String.format("\\u%X", (int) c));
} else {
- writer.write(c);
+ writer.append(c);
}
}
- writer.write(" ]]>");
+ writer.append(" ]]>");
inElement = false;
return this;
@@ -573,27 +210,23 @@ public final class XmlWriter implements IXmlWriter {
for (int i = 0; i < length; i++) {
char character = content.charAt(i);
if (character == '&') {
- writer.write("&");
+ writer.append("&");
} else if (character == '<') {
- writer.write("<");
+ writer.append("<");
} else if (character == '>') {
- writer.write(">");
+ writer.append(">");
} else if (isAttributeContent && character == '\'') {
- writer.write("'");
+ writer.append("'");
} else if (isAttributeContent && character == '\"') {
- writer.write(""");
- } else if (isOutOfRange(character)) {
- writer.write('?');
+ writer.append(""");
+ } else if (!(XMLChar.isContent(character) || XMLChar.isSpace(character))) {
+ writer.append(String.format("\\u%X", (int) character));
} else {
- writer.write(character);
+ writer.append(character);
}
}
}
- private boolean isOutOfRange(final char character) {
- return !ALLOWED_CHARACTERS[character];
- }
-
/**
* Closes the last element written.
*
@@ -611,15 +244,12 @@ public final class XmlWriter implements IXmlWriter {
}
final CharSequence elementName = elementNames.pop();
if (inElement) {
- writer.write('/');
- writer.write('>');
+ writer.append("/>");
} else {
- writer.write('<');
- writer.write('/');
- rawWrite(elementName);
- writer.write('>');
+ writer.append("</");
+ writer.append(elementName);
+ writer.append('>');
}
- writer.flush();
inElement = false;
return this;
}
@@ -644,17 +274,14 @@ public final class XmlWriter implements IXmlWriter {
while (!name.equals(elementName)) {
elementName = elementNames.pop();
if (inElement) {
- writer.write('/');
- writer.write('>');
+ writer.append("/>");
} else {
- writer.write('<');
- writer.write('/');
- rawWrite(elementName);
- writer.write('>');
+ writer.append("</");
+ writer.append(elementName);
+ writer.append('>');
}
inElement = false;
}
- writer.flush();
return this;
}
@@ -675,49 +302,14 @@ public final class XmlWriter implements IXmlWriter {
while (!elementNames.isEmpty()) {
closeElement();
}
- writer.flush();
return this;
}
- private void rawWrite(final CharSequence sequence) throws IOException {
- for (int i = 0; i < sequence.length(); i++) {
- final char charAt = sequence.charAt(i);
- writer.write(charAt);
- }
- }
-
- private boolean isInvalidName(final CharSequence sequence) {
- boolean result = true;
- final int length = sequence.length();
- for (int i = 0; i < length; i++) {
- char character = sequence.charAt(i);
- if (i == 0) {
- if (!isValidNameStart(character)) {
- result = false;
- break;
- }
- } else {
- if (!isValidNameBody(character)) {
- result = false;
- break;
- }
- }
- }
- return !result;
- }
-
- private boolean isValidNameStart(final char character) {
- final byte code = CHARACTER_CODES[character];
- return (code & NAME_START_MASK) > 0;
- }
-
- private boolean isValidNameBody(final char character) {
- final byte code = CHARACTER_CODES[character];
- return (code & NAME_MASK) > 0;
- }
-
@Override
public void close() throws IOException {
closeDocument();
+ if (writer instanceof Closeable) {
+ ((Closeable) writer).close();
+ }
}
}
diff --git a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AbstractOption.java b/apache-rat-core/src/main/java/org/apache/rat/ui/AbstractOption.java
similarity index 97%
rename from apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AbstractOption.java
rename to apache-rat-core/src/main/java/org/apache/rat/ui/AbstractOption.java
index 84335831..2d6516ac 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AbstractOption.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/ui/AbstractOption.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.rat.documentation.options;
+package org.apache.rat.ui;
import java.util.HashMap;
import java.util.Locale;
@@ -34,10 +34,7 @@ import static java.lang.String.format;
/**
* Abstract class that provides the framework for UI-specific RAT options.
- * In this context UI option means an option expressed in the specific UI, such as:
- * @see AntOption
- * @see MavenOption
- * @see CLIOption
+ * In this context UI option means an option expressed in the specific UI.
*/
public abstract class AbstractOption {
/** The pattern to match CLI options in text */
@@ -55,7 +52,7 @@ public abstract class AbstractOption {
* @param option The CLI option
* @param name the UI-specific name for the option.
*/
- AbstractOption(final Option option, final String name) {
+ protected AbstractOption(final Option option, final String name) {
this.option = option;
this.name = name;
argumentType = option.hasArg() ?
diff --git a/apache-rat-core/src/test/resources/tikaFiles/standard/file.c++ b/apache-rat-core/src/main/java/org/apache/rat/ui/package-info.java
similarity index 91%
rename from apache-rat-core/src/test/resources/tikaFiles/standard/file.c++
rename to apache-rat-core/src/main/java/org/apache/rat/ui/package-info.java
index 7a1eef16..765d92c1 100644
--- a/apache-rat-core/src/test/resources/tikaFiles/standard/file.c++
+++ b/apache-rat-core/src/main/java/org/apache/rat/ui/package-info.java
@@ -16,9 +16,8 @@
* specific language governing permissions and limitations *
* under the License. *
*/
-#include <iostream>
-int main() {
- std::cout << "Hello World!";
- return 0;
-}
+/**
+ * Classes that support UI generation and interoperability.
+ */
+package org.apache.rat.ui;
diff --git a/apache-rat-core/src/main/resources/org/apache/rat/rat-report.xsd b/apache-rat-core/src/main/resources/org/apache/rat/rat-report.xsd
index b2421e0f..91e4cac0 100644
--- a/apache-rat-core/src/main/resources/org/apache/rat/rat-report.xsd
+++ b/apache-rat-core/src/main/resources/org/apache/rat/rat-report.xsd
@@ -65,12 +65,14 @@
<xs:complexType mixed="true">
<xs:attribute type="xs:integer" name="count" use="required"/>
<xs:attribute type="xs:string" name="name" use="required"/>
+ <xs:attribute type="xs:boolean" name="approval" use="required" />
</xs:complexType>
</xs:element>
<xs:element name="licenseName" maxOccurs="unbounded" minOccurs="0">
<xs:complexType mixed="true">
<xs:attribute type="xs:integer" name="count" use="required"/>
<xs:attribute type="xs:string" name="name" use="required"/>
+ <xs:attribute type="xs:boolean" name="approval" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="documentType" maxOccurs="unbounded" minOccurs="0">
diff --git a/apache-rat-core/src/main/resources/org/apache/rat/xhtml5.xsl b/apache-rat-core/src/main/resources/org/apache/rat/xhtml5.xsl
new file mode 100644
index 00000000..b1522460
--- /dev/null
+++ b/apache-rat-core/src/main/resources/org/apache/rat/xhtml5.xsl
@@ -0,0 +1,354 @@
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
+
+ <!--***********************************************************
+ *
+ * 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.
+ *
+ ***********************************************************-->
+
+ <!-- This style sheet converts any rat-report.xml file. -->
+
+ <xsl:output method='xml'/>
+
+ <xsl:variable name='notapproved'>❗</xsl:variable>
+ <xsl:variable name="archive"><span style="font-size:x-large;">🗜</span></xsl:variable>
+ <xsl:variable name="binary"><span style="padding-left:4px;">🔠</span></xsl:variable>
+ <xsl:variable name="ignored"><span style="padding-left:4px;">🚫</span></xsl:variable>
+ <xsl:variable name="notice"><span style="font-size:x-large;padding-left:4px;">ℹ</span></xsl:variable>
+ <xsl:variable name="standard"><span style="padding-left:4px;">✅</span></xsl:variable>
+ <xsl:variable name="unknown">❓</xsl:variable>
+ <xsl:variable name="directory"><span style="padding-left:4px;background-color: #00000087;">📂</span></xsl:variable>
+
+ <xsl:template match="/">
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+ <style type="text/css">
+ <xsl:comment>
+ body {margin-top: 0px;background-color: #F9F7ED;}
+
+ h1 {color:red;}
+ h2 {color:blue;}
+ h3 {color:blueviolet;}
+ h4 {color:green;}
+ div.section {padding-left:5em;}
+ div.subsection {padding-left:5em;}
+
+ /* Table Design */
+ table,tr,td {font-weight:bold;border:1px solid #000;}
+ table {min-width: 50%;}
+ caption {color:blue;text-align:left;}
+
+ .document-name {font-size:larger;}
+ .document-mediatype {float: left;}
+ .document-encoding {padding-left: 2em;}
+ .license-entry {padding-left: 1em;}
+ .license-id {padding-left: 2em;}
+ .license-family {padding-left: 1em;}
+ </xsl:comment>
+ </style>
+ </head>
+ <body>
+ <xsl:apply-templates />
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="rat-report">
+
+ <h1>Rat Report</h1>
+
+ <xsl:call-template name="summary" />
+
+
+ <xsl:if test="descendant::resource[license/@approval='false']">
+ <xsl:call-template name="unapproved-files" />
+ </xsl:if>
+
+ <xsl:if test="descendant::resource[@type='ARCHIVE']">
+ <xsl:call-template name="archives" />
+ </xsl:if>
+
+ <h2>Detail</h2>
+
+ <p>
+ Documents with unapproved licenses will start with a <xsl:value-of select="$notapproved"/>
+ The first character on the next line identifies the document type.
+ </p>
+ <table id="rat-reports symbols" cellspacing="0"
+ summary="Symbols used in this RAT report">
+ <caption>
+ Symbols used in this RAT report
+ </caption>
+ <tr>
+ <th>Symbol</th>
+ <th>Type</th>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$archive"/></td>
+ <td>Archive file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$binary"/></td>
+ <td>Binary file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$ignored"/></td>
+ <td>Ignored file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$notice"/></td>
+ <td>Notice file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$standard"/></td>
+ <td>Standard file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$unknown"/></td>
+ <td>Unknown file</td>
+ </tr>
+ <tr>
+ <td><xsl:value-of select="$directory"/></td>
+ <td>Directory</td>
+ </tr>
+ </table>
+
+ <table id="rat-reports resources" cellspacing="0"
+ summary="Resources discovered in this RAT report">
+ <caption>
+ Resources discovered in this RAT report
+ </caption>
+ <xsl:for-each select='descendant::resource'>
+ <tr>
+ <td>
+ <xsl:if test="@isDirectory = 'true'"><xsl:value-of select="$directory"/></xsl:if>
+ <xsl:if test="license/@approval = 'false'"><xsl:value-of select="$notapproved"/></xsl:if>
+ <xsl:choose>
+ <xsl:when test="substring(@type, 1, 1) = 'A'"><xsl:value-of select="$archive"/></xsl:when>
+ <xsl:when test="substring(@type, 1, 1) = 'B'"><xsl:value-of select="$binary"/></xsl:when>
+ <xsl:when test="substring(@type, 1, 1) = 'I'"><xsl:value-of select="$ignored"/></xsl:when>
+ <xsl:when test="substring(@type, 1, 1) = 'N'"><xsl:value-of select="$notice"/></xsl:when>
+ <xsl:when test="substring(@type, 1, 1) = 'S'"><xsl:value-of select="$standard"/></xsl:when>
+ <xsl:when test="substring(@type, 1, 1) = 'U'"><xsl:value-of select="$unknown"/></xsl:when>
+ </xsl:choose>
+ </td>
+ <td>
+ <div class="document-entry">
+ <span class="document-name"><xsl:value-of select='@name'/></span>
+ <div class="document-meta">
+ <span class="document-mediatype"><xsl:value-of select="@mediaType"/></span>
+ <span class="document-encoding"><xsl:value-of select="@encoding"/></span>
+ </div>
+ </div>
+ <xsl:for-each select='descendant::license'>
+ <div class="license-entry">
+ <div>
+ <xsl:if test="@approval = 'false'">
+ <span class='approval-icon'><xsl:value-of select="$notapproved"/></span>
+ </xsl:if>
+ <span class="license-name"><xsl:value-of select="@name"/></span>
+ </div>
+ <span class="license-id">ID:
+ <xsl:choose>
+ <xsl:when test="@id = '?????'">UUID</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise>
+ </xsl:choose>
+ </span>
+ <span class="license-family">Family:
+ <xsl:choose>
+ <xsl:when test="@family = '?????'">Unknown</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@family"/></xsl:otherwise>
+ </xsl:choose>
+ </span>
+ </div>
+ </xsl:for-each>
+ </td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </xsl:template>
+
+ <xsl:template name="summary">
+ <h2>Summary</h2>
+
+ <div class="section">
+ <p>Generated at <xsl:value-of select='@timestamp' /> by
+ <xsl:value-of select='concat(version/@product, " ", rat-report/version/@version, " (", rat-report/version/@vendor, ")")'/>
+ </p>
+
+ <table id="rat-reports summary statistics" cellspacing="0"
+ summary="A summary of statistics from this RAT report">
+ <caption>
+ Table 1: A summary of statistics from this RAT report.
+ </caption>
+ <tr>
+ <th colspan="1">Name:</th>
+ <th colspan="1">Count:</th>
+ <th colspan="1">Description:</th>
+ </tr>
+ <xsl:for-each select='descendant::statistic'>
+ <tr>
+ <td>
+ <xsl:if test='@approval="false"'>
+ <span class='approval-icon'><xsl:value-of select="$notapproved"/></span>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@name = '?????'">Unknown</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td><xsl:value-of select='@count'/></td>
+ <td><xsl:value-of select='@description'/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+
+ <h3>License Statistics</h3>
+ <div class="subsection">
+ <h4>Categories</h4>
+ <div class="subsection">
+ <table id="rat-reports summary license-categories" cellspacing="0"
+ summary="A summary of license categories found in this RAT report">
+ <caption>
+ Table 2: License categories found in this RAT report.
+ </caption>
+ <tr>
+ <th colspan="1">Name:</th>
+ <th colspan="1">Count:</th>
+ </tr>
+
+ <xsl:for-each select='descendant::licenseCategory'>
+ <tr>
+ <td>
+ <xsl:if test='@approved="false"'>
+ <span class='approval-icon'><xsl:value-of select="$notapproved"/></span>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@name = '?????'">Unknown</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td><xsl:value-of select='@count'/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </div>
+
+ <h4>Licenses</h4>
+ <div class="subsection">
+ <table id="rat-reports summary licenses" cellspacing="0"
+ summary="Licenses found in this RAT report">
+ <caption>
+ Table 3: Licenses found in this RAT report.
+ </caption>
+ <tr>
+ <td colspan="1">Name:</td>
+ <td colspan="1">Count:</td>
+ </tr>
+
+ <xsl:for-each select='descendant::licenseName'>
+ <tr>
+ <td>
+ <xsl:if test='@approved="false"'>
+ <span class='approval-icon'><xsl:value-of select="$notapproved"/></span>
+ </xsl:if>
+ <xsl:choose>
+ <xsl:when test="@name = '?????'">Unknown</xsl:when>
+ <xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise>
+ </xsl:choose>
+ </td>
+ <td><xsl:value-of select='@count'/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </div>
+ </div>
+
+ <h3>Document types</h3>
+ <div class="subsection">
+ <table id="rat-reports summary document-types" cellspacing="0"
+ summary="Document types found in this RAT report">
+ <caption>
+ Table 4: Document types found in this RAT report.
+ </caption>
+ <tr>
+ <th colspan="1">Name:</th>
+ <th colspan="1">Count:</th>
+ </tr>
+
+ <xsl:for-each select='descendant::documentType'>
+ <tr>
+ <td><xsl:value-of select="@name"/></td>
+ <td><xsl:value-of select="@count"/></td>
+ </tr>
+ </xsl:for-each>
+ </table>
+ </div>
+ </div>
+ </xsl:template>
+
+ <xsl:template name="unapproved-files">
+ <h2>Files with unapproved licenses</h2>
+
+ <ul class="unapproved-licenses">
+ <xsl:for-each select='descendant::resource[license/@approval="false"]'>
+ <li class="document-name"><xsl:value-of select='@name'/></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:template>
+
+ <xsl:template name="archives">
+ <h2>Archives</h2>
+ <ul>
+ <xsl:for-each select='descendant::resource[@type="ARCHIVE"]'>
+ <li class="document-name"><xsl:value-of select='@name'/></li>
+ </xsl:for-each>
+ </ul>
+ </xsl:template>
+
+
+ <xsl:template name="license">
+ <xsl:param name="family"/>
+ <xsl:param name="id"/>
+ <xsl:param name="name"/>
+ <xsl:param name="approval"/>
+
+ <tr>
+ <td> </td>
+ <td>
+ <table>
+ <tr>
+ <xsl:if test="$approval = 'false'">
+ <xsl:value-of select="$notapproved"/>
+ </xsl:if>
+ </tr>
+ <tr>
+ <div class="document-license">
+ <span class="license-name"><xsl:value-of select="$name"/></span>
+ <div class="documment-license-meta">
+ <span class="id"><xsl:value-of select="$id"/></span>
+ <span class="family"><xsl:value-of select="$family"/></span>
+ </div>
+ </div>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </xsl:template>
+</xsl:transform>
diff --git a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
index 87f7cd96..d810a501 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/OptionCollectionTest.java
@@ -18,47 +18,31 @@
*/
package org.apache.rat;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
import java.nio.file.Path;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TreeMap;
+import java.util.stream.Stream;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.rat.commandline.ArgumentContext;
import org.apache.rat.document.DocumentName;
import org.apache.rat.license.LicenseSetFactory;
import org.apache.rat.report.IReportable;
-import org.apache.rat.test.AbstractConfigurationOptionsProvider;
-import org.apache.rat.test.utils.OptionFormatter;
+import org.apache.rat.testhelpers.data.OptionTestDataProvider;
+import org.apache.rat.testhelpers.data.TestData;
import org.apache.rat.testhelpers.TestingLog;
-import org.apache.rat.utils.CasedString;
import org.apache.rat.utils.DefaultLog;
-import org.apache.rat.utils.Log;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.lang.String.format;
@@ -70,101 +54,10 @@ public class OptionCollectionTest {
@TempDir
static Path testPath;
- @AfterAll
- static void preserveData() {
- AbstractConfigurationOptionsProvider.preserveData(testPath.toFile(), "optionTest");
- }
-
- /**
- * Defines the test method that is stored in a map.
- */
- @FunctionalInterface
- public interface OptionTest {
- /**
- * Executes the test and uses fail or asserts to generate failures.
- */
- void exec();
-
- /**
- * Execute the test and ensure any failures have the test name added.
- */
- default void test() {
- try {
- exec();
- } catch (AssertionError e) {
- throw new AssertionError(formatMsg(e.getMessage()), e);
- }
- }
-
- /**
- * Formats the messages by adding the test name.
- * @param msg the message to reformat.
- * @return the formatted message.
- */
- default String formatMsg(String msg) {
- return String.format("%s: %s", this, msg);
- }
-
- /**
- * Creates a named OptionTest.
- * @param name the name of the test.
- * @param test the test to execute.
- * @return a named option test.
- */
- static OptionTest namedTest(String name, OptionTest test) {
- return new OptionTest() {
- @Override
- public void exec() {
- test.exec();
- }
- @Override
- public String toString() {
- return name;
- }
- };
- }
- }
+ /** A flag to determine if help was called */
+ final AtomicBoolean helpCalled = new AtomicBoolean(false);
- /**
- * A test function. Used to annotate methods in test providers.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- public @interface TestFunction {
- }
-
- /**
- * Process methods in a test provider.
- * Tests are detected by looking for the {@link TestFunction} annotation.
- * @param testProvider the test provider
- * @return a map of named tests to a named OptionTest.
- */
- public static Map<String, OptionTest> processTestFunctionAnnotations(Object testProvider) {
- final int testLength = 4;
- final Class<?> clazz = testProvider.getClass();
- final Map<String, OptionTest> result = new TreeMap<>();
- for (Method method : clazz.getDeclaredMethods()) {
- if (method.isAnnotationPresent(TestFunction.class) && method.getParameterCount() == 0 && method.getReturnType() == void.class) {
- String name = method.getName();
- if (name.endsWith("Test")) {
- name = name.substring(0, name.length() - testLength);
- }
- if (name.startsWith("test")) {
- name = name.substring(testLength);
- }
- name = new CasedString(CasedString.StringCase.CAMEL, name).toCase(CasedString.StringCase.KEBAB).toLowerCase(Locale.ROOT);
- result.put(name, OptionTest.namedTest(name, () -> {
- try {
- method.invoke(testProvider);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new AssertionError(e);
- }
- }
- ));
- }
- }
- return result;
- }
+ private static final OptionTestDataProvider optionTestDataProvider = new OptionTestDataProvider();
/**
* This method is a known workaround for
@@ -176,23 +69,13 @@ public class OptionCollectionTest {
System.gc();
}
- @Test
- public void testDeprecatedUseLogged() throws IOException {
- TestingLog log = new TestingLog();
- try {
- DefaultLog.setInstance(log);
- String[] args = {"--dir", "target", "-a"};
- ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), args, o -> fail("Help printed"), true);
- assertThat(config).isNotNull();
- } finally {
- DefaultLog.setInstance(null);
- }
- log.assertContainsExactly(1, "WARN: Option [-d, --dir] used. Deprecated for removal since 0.17: Use the standard '--'");
- log.assertContainsExactly(1, "WARN: Option [-a] used. Deprecated for removal since 0.17: Use --edit-license");
+ static Stream<Arguments> getTestData() {
+ return optionTestDataProvider.getOptionTests().stream().map(testData ->
+ Arguments.of(testData.getTestName(), testData));
}
@Test
- public void testDirOptionCapturesDirectoryToScan() throws IOException {
+ public void testDirOptionCapturesDirectoryToScan() throws IOException, ParseException {
TestingLog log = new TestingLog();
ReportConfiguration config;
try {
@@ -204,11 +87,10 @@ public class OptionCollectionTest {
DefaultLog.setInstance(null);
}
assertThat(config).isNotNull();
- log.assertContainsExactly(1,"WARN: Option [-d, --dir] used. Deprecated for removal since 0.17: Use the standard '--'");
}
@Test
- public void testShortenedOptions() throws IOException {
+ public void testShortenedOptions() throws IOException, ParseException {
String[] args = {"--output-lic", "ALL"};
ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), args, (o) -> {
}, true);
@@ -227,7 +109,7 @@ public class OptionCollectionTest {
@ParameterizedTest
@ValueSource(strings = { ".", "./", "target", "./target" })
- public void getReportableTest(String fName) throws IOException {
+ public void getReportableTest(String fName) throws IOException, ParseException {
File base = new File(fName);
String expected = DocumentName.FSInfo.getDefault().normalize(base.getAbsolutePath());
ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), new String[]{fName}, o -> fail("Help called"), false);
@@ -242,61 +124,71 @@ public class OptionCollectionTest {
* @param test the option test to execute.
*/
@ParameterizedTest( name = "{index} {0}")
- @ArgumentsSource(CliOptionsProvider.class)
- public void testOptionsUpdateConfig(String name, OptionTest test) {
- DefaultLog.getInstance().log(Log.Level.INFO, "Running test for: " + name);
- test.test();
- }
+ @MethodSource("getTestData")
+ public void testOptionsUpdateConfig(String name, TestData test) {
+ test.setupFiles(testPath);
- /**
- * A class to provide the Options and tests to the testOptionsUpdateConfig.
- */
- static class CliOptionsProvider extends AbstractConfigurationOptionsProvider implements ArgumentsProvider {
-
- /** A flag to determine if help was called */
- final AtomicBoolean helpCalled = new AtomicBoolean(false);
-
- @Override
- public void helpTest() {
- String[] args = { OptionFormatter.longOpt(OptionCollection.HELP) };
- try {
- ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), args, o -> helpCalled.set(true), true);
- assertThat(config).as("Should not have config").isNull();
- assertThat(helpCalled.get()).as("Help was not called").isTrue();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
+ helpCalled.set(false);
+ assertThat(helpCalled.get()).as("Help was called").isFalse();
- /**
- * Constructor. Sets the baseDir and loads the testMap.
- */
- public CliOptionsProvider() {
- super(Collections.emptyList(), testPath.toFile());
- }
-
- /**
- * Generate a ReportConfiguration from a set of arguments.
- * Forces the {@code helpCalled} flag to be reset.
- * @param args the arguments.
- * @return A ReportConfiguration
- * @throws IOException on critical error.
- */
- protected final ReportConfiguration generateConfig(List<Pair<Option, String[]>> args) throws IOException {
- helpCalled.set(false);
- List<String> sArgs = new ArrayList<>();
- for (Pair<Option, String[]> pair : args) {
- if (pair.getKey() != null) {
- sArgs.add("--" + pair.getKey().getLongOpt());
- String[] oArgs = pair.getValue();
- if (oArgs != null) {
- Collections.addAll(sArgs, oArgs);
- }
- }
- }
- ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), sArgs.toArray(new String[0]), o -> helpCalled.set(true), true);
- assertThat(helpCalled.get()).as("Help was called").isFalse();
- return config;
+ try {
+ ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), test.getCommandLine(), o -> helpCalled.set(true), true);
+ } catch (IOException | ParseException e) {
+ fail(e.getMessage(), e);
}
}
+
+// /**
+// * A class to provide the Options and tests to the testOptionsUpdateConfig.
+// */
+// static class CliOptionsProvider extends AbstractConfigurationOptionsProvider implements ArgumentsProvider {
+//
+//
+// @Override
+// public void helpTest() {
+// String[] args = { OptionFormatter.longOpt(OptionCollection.HELP) };
+// try {
+// ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), args, o -> helpCalled.set(true), true);
+// assertThat(config).as("Should not have config").isNull();
+// assertThat(helpCalled.get()).as("Help was not called").isTrue();
+// } catch (IOException | ParseException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// /**
+// * Constructor. Sets the baseDir and loads the testMap.
+// */
+// public CliOptionsProvider() {
+// super(Collections.emptyList(), testPath.toFile());
+// }
+//
+// /**
+// * Generate a ReportConfiguration from a set of arguments.
+// * Forces the {@code helpCalled} flag to be reset.
+// * @param args the arguments.
+// * @return A ReportConfiguration
+// * @throws IOException on critical error.
+// */
+// protected final ReportConfiguration generateConfig(List<Pair<Option, String[]>> args) throws IOException {
+// helpCalled.set(false);
+// List<String> sArgs = new ArrayList<>();
+// for (Pair<Option, String[]> pair : args) {
+// if (pair.getKey() != null) {
+// sArgs.add("--" + pair.getKey().getLongOpt());
+// String[] oArgs = pair.getValue();
+// if (oArgs != null) {
+// Collections.addAll(sArgs, oArgs);
+// }
+// }
+// }
+// try {
+// ReportConfiguration config = OptionCollection.parseCommands(testPath.toFile(), sArgs.toArray(new String[0]), o -> helpCalled.set(true), true);
+// assertThat(helpCalled.get()).as("Help was called").isFalse();
+// return config;
+// } catch (ParseException e) {
+// throw new IOException(e);
+// }
+// }
+// }
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
index 8ff47a28..69889dc4 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReportConfigurationTest.java
@@ -39,9 +39,10 @@ import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.function.Function;
+import java.util.stream.Collectors;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
-import org.apache.rat.ReportConfiguration.NoCloseOutputStream;
+import org.apache.commons.io.output.CloseShieldOutputStream;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.config.AddLicenseHeaders;
import org.apache.rat.config.exclusion.StandardCollection;
@@ -452,7 +453,7 @@ public class ReportConfigurationTest {
@Test
public void outputTest() throws IOException {
- assertThat(underTest.getOutput().get()).isExactlyInstanceOf(NoCloseOutputStream.class);
+ assertThat(underTest.getOutput().get()).isExactlyInstanceOf(CloseShieldOutputStream.class);
assertThat(underTest.getWriter()).isNotNull();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -662,51 +663,52 @@ public class ReportConfigurationTest {
.isExactlyInstanceOf(IllegalArgumentException.class);
}
- /**
- * Validates that the configuration contains the default approved licenses.
- * @param config The configuration to test.
- */
- public static void validateDefaultApprovedLicenses(ReportConfiguration config) {
- validateDefaultApprovedLicenses(config, 0);
- }
/**
* Validates that the configuration contains the default approved licenses.
* @param config The configuration to test.
*/
- public static void validateDefaultApprovedLicenses(ReportConfiguration config, int additionalIdCount) {
- assertThat(config.getLicenseCategories(LicenseFilter.APPROVED)).hasSize(XMLConfigurationReaderTest.APPROVED_IDS.length + additionalIdCount);
- for (String s : XMLConfigurationReaderTest.APPROVED_IDS) {
- assertThat(config.getLicenseCategories(LicenseFilter.APPROVED)).contains(ILicenseFamily.makeCategory(s));
+ public static void validateDefaultApprovedLicenses(ReportConfiguration config, String... additionalIds) {
+ validateLicenses(config, Arrays.asList(additionalIds), LicenseFilter.APPROVED, XMLConfigurationReaderTest.APPROVED_LICENSES);
}
+
+ /**
+ * Validates that the configuration contains all the default licenses along with any addiitonal licenses
+ * @param config the configuration to test.
+ * @param additionalLicenses Additional licence IDs that are expected.
+ */
+ public static void validateDefaultLicenses(ReportConfiguration config, String...additionalLicenses) {
+ validateLicenses(config, Arrays.asList(additionalLicenses), LicenseFilter.ALL, XMLConfigurationReaderTest.EXPECTED_LICENSES);
}
+ private static void validateLicenses(ReportConfiguration config, List<String> additionalIds, LicenseFilter filter, String[] approvedIds) {
+ List<String> expected = new ArrayList<>(Arrays.asList(approvedIds));
+ expected.addAll(additionalIds);
+ assertThat(config.getLicenses(filter).stream().map(ILicense::getId).collect(Collectors.toSet())).containsExactlyInAnyOrderElementsOf(expected);
+ }
+
+
/**
* Validates that the configuration contains the default license families.
* @param config the configuration to test.
*/
public static void validateDefaultLicenseFamilies(ReportConfiguration config, String...additionalIds) {
- assertThat(config.getLicenseFamilies(LicenseFilter.ALL)).hasSize(XMLConfigurationReaderTest.EXPECTED_IDS.length + additionalIds.length);
- List<String> expected = new ArrayList<>();
- expected.addAll(Arrays.asList(XMLConfigurationReaderTest.EXPECTED_IDS));
- expected.addAll(Arrays.asList(additionalIds));
- for (ILicenseFamily family : config.getLicenseFamilies(LicenseFilter.ALL)) {
- assertThat(expected).contains(family.getFamilyCategory().trim());
- }
+ validateLicenseFamilies(config, Arrays.asList(additionalIds), LicenseFilter.ALL, XMLConfigurationReaderTest.EXPECTED_IDS);
}
/**
- * Validates that the configuration contains the default licenses.
+ * Validates that the configuration contains the default license families.
* @param config the configuration to test.
*/
- public static void validateDefaultLicenses(ReportConfiguration config, String...additionalLicenses) {
- assertThat(config.getLicenses(LicenseFilter.ALL)).hasSize(XMLConfigurationReaderTest.EXPECTED_LICENSES.length + additionalLicenses.length);
- List<String> expected = new ArrayList<>();
- expected.addAll(Arrays.asList(XMLConfigurationReaderTest.EXPECTED_LICENSES));
- expected.addAll(Arrays.asList(additionalLicenses));
- for (ILicense license : config.getLicenses(LicenseFilter.ALL)) {
- assertThat(expected).contains(license.getId());
+ public static void validateDefaultApprovedLicenseFamilies(ReportConfiguration config, String...additionalIds) {
+ validateLicenseFamilies(config, Arrays.asList(additionalIds), LicenseFilter.APPROVED, XMLConfigurationReaderTest.APPROVED_IDS);
}
+
+ private static void validateLicenseFamilies(ReportConfiguration config, List<String> additionalIds, LicenseFilter filter, String[] approvedIds) {
+ List<String> expected = new ArrayList<>(Arrays.asList(approvedIds));
+ expected.addAll(additionalIds);
+ assertThat(config.getLicenseFamilies(filter).stream().map(lf -> lf.getFamilyCategory().trim())
+ .collect(Collectors.toSet())).containsExactlyInAnyOrderElementsOf(expected);
}
/**
@@ -719,9 +721,10 @@ public class ReportConfigurationTest {
assertThat(config.getCopyrightMessage()).isNull();
assertThat(config.getStyleSheet()).withFailMessage("Stylesheet should not be null").isNotNull();
- validateDefaultApprovedLicenses(config);
validateDefaultLicenseFamilies(config);
+ validateDefaultApprovedLicenseFamilies(config);
validateDefaultLicenses(config);
+ validateDefaultApprovedLicenses(config);
}
/**
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
deleted file mode 100644
index 6cf7b458..00000000
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
+++ /dev/null
@@ -1,1353 +0,0 @@
-/*
- * 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;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.regex.Pattern;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-import org.apache.commons.cli.Option;
-import org.apache.commons.cli.Options;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.rat.api.RatException;
-import org.apache.rat.commandline.Arg;
-import org.apache.rat.commandline.StyleSheets;
-import org.apache.rat.config.exclusion.StandardCollection;
-import org.apache.rat.config.results.ClaimValidator;
-import org.apache.rat.configuration.builders.SpdxBuilder;
-import org.apache.rat.help.Help;
-import org.apache.rat.license.ILicense;
-import org.apache.rat.license.ILicenseFamily;
-import org.apache.rat.license.LicenseSetFactory;
-import org.apache.rat.report.claim.ClaimStatistic;
-import org.apache.rat.test.AbstractOptionsProvider;
-import org.apache.rat.test.utils.OptionFormatter;
-import org.apache.rat.test.utils.Resources;
-import org.apache.rat.testhelpers.FileUtils;
-import org.apache.rat.testhelpers.TestingLog;
-import org.apache.rat.testhelpers.TextUtils;
-import org.apache.rat.testhelpers.XmlUtils;
-import org.apache.rat.utils.DefaultLog;
-import org.apache.rat.utils.Log;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import static org.apache.rat.commandline.Arg.HELP_LICENSES;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Fail.fail;
-
-/**
- * A class to provide the Options and tests to the testOptionsUpdateConfig.
- */
-class ReporterOptionsProvider extends AbstractOptionsProvider implements ArgumentsProvider {
- static File sourceDir;
-
- /**
- * A flag to determine if help was called
- */
- final AtomicBoolean helpCalled = new AtomicBoolean(false);
-
- public ReporterOptionsProvider() {
- super(ReporterOptionsTest.testPath.toFile());
- processTestFunctionAnnotations();
- testMap.put("addLicense", this::addLicenseTest);
- testMap.remove("add-license");
- testMap.put("dir", () -> DefaultLog.getInstance().info("--dir has no valid test"));
- super.validate(Collections.emptyList());
- }
-
- /**
- * Generate a ReportConfiguration from a set of arguments.
- * Forces the {@code helpCalled} flag to be reset.
- *
- * @param args the arguments.
- * @return A ReportConfiguration
- * @throws IOException on critical error.
- */
- @Override
- protected final ReportConfiguration generateConfig(List<Pair<Option, String[]>> args) throws IOException {
- return generateConfig(args, false);
- }
-
- protected final ReportConfiguration generateConfig(List<Pair<Option, String[]>> args, boolean helpExpected) throws IOException {
- if (sourceDir == null) {
- throw new IOException("sourceDir not set");
- }
- helpCalled.set(false);
- ReportConfiguration config = OptionCollection.parseCommands(sourceDir, extractArgs(args), o -> helpCalled.set(true), true);
- assertThat(helpCalled.get()).as("Help was called").isEqualTo(helpExpected);
- if (config != null && !config.hasSource()) {
- config.addSource(OptionCollection.getReportable(sourceDir, config));
- }
- return config;
- }
-
- private void configureSourceDir(Option option) {
- sourceDir = new File(baseDir, OptionFormatter.getName(option));
- FileUtils.mkDir(sourceDir);
- }
-
- private void validateNoArgSetup() throws IOException, RatException {
- // verify that without args the report is ok.
- TestingLog log = new TestingLog();
- DefaultLog.setInstance(log);
- try {
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- ClaimValidator validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).isEmpty();
- } finally {
- DefaultLog.setInstance(null);
- }
-
- }
-
- @OptionCollectionTest.TestFunction
- protected void addLicenseTest() {
- editLicenseTest(Arg.EDIT_ADD.find("addLicense"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void editLicenseTest() {
- editLicenseTest(Arg.EDIT_ADD.find("edit-license"));
- }
-
- private void editLicenseTest(final Option option) {
- try {
- configureSourceDir(option);
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, null));
- File testFile = writeFile("NoLicense.java", "class NoLicense {}");
- File resultFile = new File(sourceDir, "NoLicense.java.new");
- FileUtils.delete(resultFile);
-
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic).isNotNull();
- String contents = String.join("\n", IOUtils.readLines(new FileReader(testFile)));
- assertThat(contents).isEqualTo("class NoLicense {}");
- assertThat(resultFile).exists();
- contents = String.join("\n", IOUtils.readLines(new FileReader(resultFile)));
- assertThat(contents).isEqualTo("/*\n" +
- " * Licensed to the Apache Software Foundation (ASF) under one\n" +
- " * or more contributor license agreements. See the NOTICE file\n" +
- " * distributed with this work for additional information\n" +
- " * regarding copyright ownership. The ASF licenses this file\n" +
- " * to you under the Apache License, Version 2.0 (the\n" +
- " * \"License\"); you may not use this file except in compliance\n" +
- " * with the License. You may obtain a copy of the License at\n" +
- " * \n" +
- " * http://www.apache.org/licenses/LICENSE-2.0\n" +
- " * \n" +
- " * Unless required by applicable law or agreed to in writing,\n" +
- " * software distributed under the License is distributed on an\n" +
- " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n" +
- " * KIND, either express or implied. See the License for the\n" +
- " * specific language governing permissions and limitations\n" +
- " * under the License.\n" +
- " */\n\n" +
- "class NoLicense {}");
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- protected File writeFile(String name) {
- return FileUtils.writeFile(sourceDir, name, Collections.singletonList(name));
- }
-
- protected File writeFile(String name, String content) {
- return FileUtils.writeFile(sourceDir, name, Collections.singletonList(content));
- }
-
- protected File writeFile(String name, Iterable<String> content) {
- return FileUtils.writeFile(sourceDir, name, content);
- }
-
- @OptionCollectionTest.TestFunction
- private void execLicensesDeniedTest(final Option option, final String[] args) {
- try {
- configureSourceDir(option);
- File illumosFile = writeFile("illumousFile.java", "The contents of this file are " +
- "subject to the terms of the Common Development and Distribution License (the \"License\") You " +
- "may not use this file except in compliance with the License.");
-
- validateNoArgSetup();
-
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- ClaimValidator validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).containsExactly("UNAPPROVED");
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void licensesDeniedTest() {
- execLicensesDeniedTest(Arg.LICENSES_DENIED.find("licenses-denied"), new String[]{"ILLUMOS"});
- }
-
- @OptionCollectionTest.TestFunction
- protected void licensesDeniedFileTest() {
- File outputFile = FileUtils.writeFile(baseDir, "licensesDenied.txt", Collections.singletonList("ILLUMOS"));
- execLicensesDeniedTest(Arg.LICENSES_DENIED_FILE.find("licenses-denied-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- private void noDefaultsTest(final Option option) {
- try {
- configureSourceDir(option);
- File testFile = writeFile("Test.java", Arrays.asList("/*\n", "SPDX-License-Identifier: Apache-2.0\n",
- "*/\n\n", "class Test {}\n"));
-
- validateNoArgSetup();
-
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, null));
- Reporter reporter = new Reporter(config);
- try {
- reporter.execute();
- fail("Should have thrown exception");
- } catch (RatException e) {
- ClaimStatistic claimStatistic = reporter.getClaimsStatistic();
- ClaimValidator validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).containsExactlyInAnyOrder("DOCUMENT_TYPES", "LICENSE_CATEGORIES", "LICENSE_NAMES", "STANDARDS");
- }
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void noDefaultLicensesTest() {
- noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("no-default-licenses"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void configurationNoDefaultsTest() {
- noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void counterMaxTest() {
- Option option = Arg.COUNTER_MAX.option();
- String[] arg = {null};
- try {
- configureSourceDir(option);
- File testFile = writeFile("Test.java", Arrays.asList("/*\n", "SPDX-License-Identifier: Unapproved\n",
- "*/\n\n", "class Test {}\n"));
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- ClaimValidator validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).containsExactly("UNAPPROVED");
-
- arg[0] = "Unapproved:1";
- config = generateConfig(ImmutablePair.of(option, arg));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).isEmpty();
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void counterMinTest() {
- Option option = Arg.COUNTER_MIN.option();
- String[] arg = {null};
-
- try {
- configureSourceDir(option);
- File testFile = writeFile("Test.java", Arrays.asList("/*\n", "SPDX-License-Identifier: Unapproved\n",
- "*/\n\n", "class Test {}\n"));
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- ClaimValidator validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).containsExactly("UNAPPROVED");
-
- arg[0] = "Unapproved:1";
- config = generateConfig(ImmutablePair.of(option, arg));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- validator = config.getClaimValidator();
- assertThat(validator.listIssues(claimStatistic)).isEmpty();
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- // exclude tests
- private void execExcludeTest(final Option option, final String[] args) {
- String[] notExcluded = {"notbaz", "well._afile"};
- String[] excluded = {"some.foo", "B.bar", "justbaz"};
- try {
- configureSourceDir(option);
- writeFile("notbaz");
- writeFile("well._afile");
- writeFile("some.foo");
- writeFile("B.bar");
- writeFile("justbaz");
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(5);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
-
- // filter out source
- config = generateConfig(ImmutablePair.of(option, args));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(3);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- private void excludeFileTest(final Option option) {
- configureSourceDir(option);
- File outputFile = FileUtils.writeFile(baseDir, "exclude.txt", Arrays.asList(EXCLUDE_ARGS));
- execExcludeTest(option, new String[]{outputFile.getAbsolutePath()});
- }
-
- @OptionCollectionTest.TestFunction
- protected void excludeFileTest() {
- excludeFileTest(Arg.EXCLUDE_FILE.find("exclude-file"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputExcludeFileTest() {
- excludeFileTest(Arg.EXCLUDE_FILE.find("input-exclude-file"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void excludeTest() {
- execExcludeTest(Arg.EXCLUDE.find("exclude"), EXCLUDE_ARGS);
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputExcludeTest() {
- execExcludeTest(Arg.EXCLUDE.find("input-exclude"), EXCLUDE_ARGS);
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputExcludeSizeTest() {
- Option option = Arg.EXCLUDE_SIZE.option();
- String[] args = {"5"};
-
- try {
- configureSourceDir(option);
- writeFile("Hi.txt", "Hi");
- writeFile("Hello.txt", "Hello");
- writeFile("HelloWorld.txt", "HelloWorld");
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(3);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
-
- // filter out source
- config = generateConfig(ImmutablePair.of(option, args));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputExcludeStdTest() {
- Option option = Arg.EXCLUDE_STD.find("input-exclude-std");
- String[] args = {StandardCollection.MAVEN.name()};
- // these files are excluded by default "afile~", ".#afile", "%afile%", "._afile"
- // these files are not excluded by default "afile~more", "what.#afile", "%afile%withMore", "well._afile", "build.log"
- // build.log is excluded by MAVEN.
- try {
- configureSourceDir(option);
- writeFile("afile~");
- writeFile(".#afile");
- writeFile("%afile%");
- writeFile("._afile");
- writeFile("afile~more");
- writeFile("what.#afile");
- writeFile("%afile%withMore");
- writeFile("well._afile");
- writeFile("build.log");
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(5);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(4);
-
- config = generateConfig(ImmutablePair.of(option, args));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(4);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(5);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputExcludeParsedScmTest() {
- Option option = Arg.EXCLUDE_PARSE_SCM.find("input-exclude-parsed-scm");
- String[] args = {"GIT"};
- String[] lines = {
- "# somethings",
- "!thingone", "thing*", System.lineSeparator(),
- "# some fish",
- "**/fish", "*_fish",
- "# some colorful directories",
- "red/", "blue/*/"};
-
- try {
- configureSourceDir(option);
-
- writeFile(".gitignore", Arrays.asList(lines));
- writeFile("thingone");
- writeFile("thingtwo");
-
- File dir = new File(sourceDir, "dir");
- FileUtils.mkDir(dir);
- FileUtils.writeFile(dir, "fish_two");
- FileUtils.writeFile(dir, "fish");
-
- dir = new File(sourceDir, "red");
- FileUtils.mkDir(dir);
- FileUtils.writeFile(dir, "fish");
-
- dir = new File(sourceDir, "blue/fish");
- FileUtils.mkDir(dir);
- FileUtils.writeFile(dir, "dory");
-
- dir = new File(sourceDir, "some");
- FileUtils.mkDir(dir);
- FileUtils.writeFile(dir, "fish");
- FileUtils.writeFile(dir, "things");
- FileUtils.writeFile(dir, "thingone");
-
- dir = new File(sourceDir, "another");
- FileUtils.mkDir(dir);
- FileUtils.writeFile(dir, "red_fish");
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(11);
- // .gitignore is ignored by default as it is hidden but not counted
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
-
- config = generateConfig(ImmutablePair.of(option, args));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(3);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(8);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- // include tests
- private void execIncludeTest(final Option option, final String[] args) {
- Option excludeOption = Arg.EXCLUDE.option();
- String[] notExcluded = {"B.bar", "justbaz", "notbaz"};
- String[] excluded = {"some.foo"};
- try {
- configureSourceDir(option);
- writeFile("notbaz");
- writeFile("some.foo");
- writeFile("B.bar");
- writeFile("justbaz");
-
- ReportConfiguration config = generateConfig(Collections.emptyList());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(4);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
-
- // verify exclude removes most files.
- config = generateConfig(ImmutablePair.of(excludeOption, EXCLUDE_ARGS));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- // .gitignore is ignored by default as it is hidden but not counted
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(3);
-
- // verify include pust them back
- config = generateConfig(ImmutablePair.of(option, args), ImmutablePair.of(excludeOption, EXCLUDE_ARGS));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(3);
- // .gitignore is ignored by default as it is hidden but not counted
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- private void includeFileTest(final Option option) {
- File outputFile = FileUtils.writeFile(baseDir, "include.txt", Arrays.asList(INCLUDE_ARGS));
- execIncludeTest(option, new String[]{outputFile.getAbsolutePath()});
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputIncludeFileTest() {
- includeFileTest(Arg.INCLUDE_FILE.find("input-include-file"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void includesFileTest() {
- includeFileTest(Arg.INCLUDE_FILE.find("includes-file"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void includeTest() {
- execIncludeTest(Arg.INCLUDE.find("include"), INCLUDE_ARGS);
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputIncludeTest() {
- execIncludeTest(Arg.INCLUDE.find("input-include"), INCLUDE_ARGS);
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputIncludeStdTest() {
- Option option = Arg.INCLUDE_STD.find("input-include-std");
- String[] args = {StandardCollection.MISC.name()};
- try {
- configureSourceDir(option);
-
- writeFile("afile~more");
- writeFile("afile~");
- writeFile(".#afile");
- writeFile("%afile%");
- writeFile("._afile");
- writeFile("what.#afile");
- writeFile("%afile%withMore");
- writeFile("well._afile");
-
- ImmutablePair<Option, String[]> excludes = ImmutablePair.of(Arg.EXCLUDE.find("input-exclude"),
- new String[]{"*~more", "*~"});
-
- ReportConfiguration config = generateConfig(Collections.singletonList(excludes));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(3);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(5);
-
- config = generateConfig(excludes, ImmutablePair.of(option, args));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(7);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void inputSourceTest() {
- Option option = Arg.SOURCE.find("input-source");
- try {
- configureSourceDir(option);
-
- writeFile("codefile");
- File inputFile = writeFile("intput.txt", "codefile");
- writeFile("notcodFile");
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(3);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
-
- config = generateConfig(ImmutablePair.of(option, new String[]{inputFile.getAbsolutePath()}));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- private ReportConfiguration addCatzLicense(ReportConfiguration config) {
- String catz = ILicenseFamily.makeCategory("catz");
- config.addFamily(ILicenseFamily.builder().setLicenseFamilyCategory(catz).setLicenseFamilyName("catz").build());
- config.addLicense(ILicense.builder().setFamily(catz)
- .setMatcher(new SpdxBuilder().setName("catz")));
- return config;
- }
-
- private void execLicenseFamiliesApprovedTest(final Option option, final String[] args) {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
- try {
- configureSourceDir(option);
- // write the catz licensed text file
- writeFile("catz.txt", "SPDX-License-Identifier: catz");
-
- ReportConfiguration config = addCatzLicense(generateConfig());
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
-
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- config = addCatzLicense(generateConfig(arg1));
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void licenseFamiliesApprovedFileTest() {
- Option option = Arg.FAMILIES_APPROVED_FILE.find("license-families-approved-file");
- File outputFile = FileUtils.writeFile(baseDir, "familiesApproved.txt", Collections.singletonList("catz"));
- execLicenseFamiliesApprovedTest(option, new String[]{outputFile.getAbsolutePath()});
- }
-
- @OptionCollectionTest.TestFunction
- protected void licenseFamiliesApprovedTest() {
- execLicenseFamiliesApprovedTest(Arg.FAMILIES_APPROVED.find("license-families-approved"),
- new String[]{"catz"});
- }
-
- private void execLicenseFamiliesDeniedTest(final Option option, final String[] args) {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
- String bsd = ILicenseFamily.makeCategory("BSD-3");
- try {
- configureSourceDir(option);
-
- // write the catz licensed text file
- writeFile("bsd.txt", "SPDX-License-Identifier: BSD-3-Clause");
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
-
- config = generateConfig(arg1);
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void licenseFamiliesDeniedFileTest() {
- File outputFile = FileUtils.writeFile(baseDir, "familiesDenied.txt", Collections.singletonList("BSD-3"));
- execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED_FILE.find("license-families-denied-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- @OptionCollectionTest.TestFunction
- protected void licenseFamiliesDeniedTest() {
- execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED.find("license-families-denied"),
- new String[]{"BSD-3"});
- }
-
-
- private void configTest(final Option option) {
- try {
- configureSourceDir(option);
- String[] args = {
- Resources.getResourceFile("OptionTools/One.xml").getAbsolutePath(),
- Resources.getResourceFile("OptionTools/Two.xml").getAbsolutePath()};
-
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
-
- writeFile("bsd.txt", "SPDX-License-Identifier: BSD-3-Clause");
- writeFile("one.txt", "one is the lonelest number");
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- config = generateConfig(arg1);
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
-
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"), null);
-
- config = generateConfig(arg1, arg2);
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void licensesTest() {
- configTest(Arg.CONFIGURATION.find("licenses"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void configTest() {
- configTest(Arg.CONFIGURATION.find("config"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void execLicensesApprovedTest(final Option option, String[] args) {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
-
- try {
- configureSourceDir(option);
-
- writeFile("gpl.txt", "SPDX-License-Identifier: GPL-1.0-only");
- writeFile("apl.txt", "SPDX-License-Identifier: Apache-2.0");
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- config = generateConfig(arg1);
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
-
-
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void licensesApprovedFileTest() {
- File outputFile = FileUtils.writeFile(baseDir, "licensesApproved.txt", Collections.singletonList("GPL1"));
- execLicensesApprovedTest(Arg.LICENSES_APPROVED_FILE.find("licenses-approved-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- @OptionCollectionTest.TestFunction
- protected void licensesApprovedTest() {
- execLicensesApprovedTest(Arg.LICENSES_APPROVED.find("licenses-approved"),
- new String[]{"GPL1"});
- }
-
- @OptionCollectionTest.TestFunction
- protected void scanHiddenDirectoriesTest() {
- Option option = Arg.INCLUDE_STD.find("scan-hidden-directories");
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, null);
-
- try {
- configureSourceDir(option);
-
- writeFile("apl.txt", "SPDX-License-Identifier: Apache-2.0");
-
- File hiddenDir = new File(sourceDir, ".hiddendir");
- FileUtils.mkDir(hiddenDir);
- FileUtils.writeFile(hiddenDir, "gpl.txt", Collections.singletonList("SPDX-License-Identifier: GPL-1.0-only"));
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
-
- config = generateConfig(arg1);
- reporter = new Reporter(config);
- claimStatistic = reporter.execute();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(2);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- private void outTest(final Option option) {
- try {
- configureSourceDir(option);
- writeFile("apl.txt", "SPDX-License-Identifier: Apache-2.0");
- File outFile = new File(sourceDir, "outexample");
- FileUtils.delete(outFile);
- String[] args = new String[]{outFile.getAbsolutePath()};
-
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.output();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
-
- String actualText = TextUtils.readFile(outFile);
- TextUtils.assertContainsExactly(1, "Apache License 2.0: 1 ", actualText);
- TextUtils.assertContainsExactly(1, "STANDARD: 1 ", actualText);
-
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void outTest() {
- outTest(Arg.OUTPUT_FILE.find("out"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputFileTest() {
- outTest(Arg.OUTPUT_FILE.find("output-file"));
- }
-
- private void styleSheetTest(final Option option) {
- PrintStream origin = System.out;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (PrintStream out = new PrintStream(baos)) {
- System.setOut(out);
- configureSourceDir(option);
- // create a dummy stylesheet so that we have a local file for users of the testing jar.
- File file = writeFile("stylesheet", "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n" +
- " <xsl:template match=\"@*|node()\">\n" +
- " Hello world\n" +
- " </xsl:template>\n" +
- "</xsl:stylesheet>");
-
- String[] args = {null};
- for (StyleSheets sheet : StyleSheets.values()) {
- args[0] = sheet.arg();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.output();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- String actualText = baos.toString(StandardCharsets.UTF_8.name());
- switch (sheet) {
- case MISSING_HEADERS:
- TextUtils.assertContainsExactly(1, "Files with missing headers:" + System.lineSeparator() +
- " /stylesheet", actualText);
- break;
- case PLAIN:
- TextUtils.assertContainsExactly(1, "Unknown license: 1 ", actualText);
- TextUtils.assertContainsExactly(1, "?????: 1 ", actualText);
- break;
- case XML:
- TextUtils.assertContainsExactly(1, "<resource encoding=\"ISO-8859-1\" mediaType=\"text/plain\" name=\"/stylesheet\" type=\"STANDARD\">", actualText);
- break;
- case UNAPPROVED_LICENSES:
- TextUtils.assertContainsExactly(1, "Files with unapproved licenses:" + System.lineSeparator() + " /stylesheet", actualText);
- break;
- default:
- fail("No test for stylesheet " + sheet);
- break;
- }
- baos.reset();
- }
- args[0] = file.getAbsolutePath();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.output();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- String actualText = baos.toString(StandardCharsets.UTF_8.name());
- TextUtils.assertContainsExactly(1, "Hello world", actualText);
-
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- } finally {
- System.setOut(origin);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void stylesheetTest() {
- styleSheetTest(Arg.OUTPUT_STYLE.find("stylesheet"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputStyleTest() {
- styleSheetTest(Arg.OUTPUT_STYLE.find("output-style"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void xmlTest() {
- PrintStream origin = System.out;
- Option option = Arg.OUTPUT_STYLE.find("xml");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (PrintStream out = new PrintStream(baos)) {
- System.setOut(out);
- configureSourceDir(option);
- // create a dummy stylesheet so that we match the stylesheet tests.
- File file = writeFile("stylesheet", "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n" +
- " <xsl:template match=\"@*|node()\">\n" +
- " Hello world\n" +
- " </xsl:template>\n" +
- "</xsl:stylesheet>");
-
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, null));
- Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.output();
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(1);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.APPROVED)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
-
- String actualText = baos.toString(StandardCharsets.UTF_8.name());
- TextUtils.assertContainsExactly(1, "<resource encoding=\"ISO-8859-1\" mediaType=\"text/plain\" name=\"/stylesheet\" type=\"STANDARD\">", actualText);
-
- try (InputStream expected = StyleSheets.getStyleSheet("xml").get();
- InputStream actual = config.getStyleSheet().get()) {
- assertThat(IOUtils.contentEquals(expected, actual)).as("'xml' does not match").isTrue();
- }
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- } finally {
- System.setOut(origin);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void logLevelTest() {
- PrintStream origin = System.out;
- Option option = Arg.LOG_LEVEL.find("log-level");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Log.Level oldLevel = DefaultLog.getInstance().getLevel();
- try (PrintStream out = new PrintStream(baos)) {
- System.setOut(out);
- configureSourceDir(option);
-
- ReportConfiguration config = generateConfig();
- Reporter reporter = new Reporter(config);
- reporter.output();
- TextUtils.assertNotContains("DEBUG", baos.toString(StandardCharsets.UTF_8.name()));
-
- config = generateConfig(ImmutablePair.of(option, new String[]{"debug"}));
- reporter = new Reporter(config);
- reporter.output();
- TextUtils.assertContains("DEBUG", baos.toString(StandardCharsets.UTF_8.name()));
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- } finally {
- System.setOut(origin);
- DefaultLog.getInstance().setLevel(oldLevel);
- }
- }
-
- private void listLicenses(final Option option) {
- XPath xPath = XPathFactory.newInstance().newXPath();
- String[] args = {null};
-
- try {
- configureSourceDir(option);
- File outFile = new File(sourceDir, "out.xml");
- FileUtils.delete(outFile);
- ImmutablePair<Option, String[]> outputFile = ImmutablePair.of(Arg.OUTPUT_FILE.option(), new String[]{outFile.getAbsolutePath()});
- ImmutablePair<Option, String[]> stylesheet = ImmutablePair.of(Arg.OUTPUT_STYLE.option(), new String[]{StyleSheets.XML.arg()});
- for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
- args[0] = filter.name();
- ReportConfiguration config = generateConfig(outputFile, stylesheet, ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- reporter.output();
- Document document = XmlUtils.toDom(new FileInputStream(outFile));
- switch (filter) {
- case ALL:
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='AL2.0']");
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='GPL1']");
- break;
- case APPROVED:
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='AL2.0']");
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='GPL1']");
- break;
- case NONE:
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='AL2.0']");
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/licenses/license[@id='GPL1']");
- break;
- default:
- throw new IllegalArgumentException("Unexpected filter: " + filter);
- }
- }
- } catch (IOException | RatException | SAXException | ParserConfigurationException |
- XPathExpressionException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void listLicensesTest() {
- listLicenses(Arg.OUTPUT_LICENSES.find("list-licenses"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputLicensesTest() {
- listLicenses(Arg.OUTPUT_LICENSES.find("output-licenses"));
- }
-
- private void listFamilies(final Option option) {
- XPath xPath = XPathFactory.newInstance().newXPath();
- String[] args = {null};
-
- try {
- configureSourceDir(option);
- File outFile = new File(sourceDir, "out.xml");
- FileUtils.delete(outFile);
- ImmutablePair<Option, String[]> outputFile = ImmutablePair.of(Arg.OUTPUT_FILE.option(), new String[]{outFile.getAbsolutePath()});
- ImmutablePair<Option, String[]> stylesheet = ImmutablePair.of(Arg.OUTPUT_STYLE.option(), new String[]{StyleSheets.XML.arg()});
- for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
- args[0] = filter.name();
- ReportConfiguration config = generateConfig(outputFile, stylesheet, ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- reporter.output();
- Document document = XmlUtils.toDom(Files.newInputStream(outFile.toPath()));
- switch (filter) {
- case ALL:
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='AL']");
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='GPL']");
- break;
- case APPROVED:
- XmlUtils.assertIsPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='AL']");
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='GPL']");
- break;
- case NONE:
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='AL']");
- XmlUtils.assertIsNotPresent(filter.name(), document, xPath, "/rat-report/rat-config/families/family[@id='GPL']");
- break;
- default:
- throw new IllegalArgumentException("Unexpected filter: " + filter);
- }
- }
- } catch (IOException | RatException | SAXException | ParserConfigurationException |
- XPathExpressionException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void listFamiliesTest() {
- listFamilies(Arg.OUTPUT_FAMILIES.find("list-families"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputFamiliesTest() {
- listFamilies(Arg.OUTPUT_FAMILIES.find("output-families"));
- }
-
- private void archiveTest(final Option option) {
- XPath xPath = XPathFactory.newInstance().newXPath();
- String[] args = {null};
-
- try {
- configureSourceDir(option);
- File outFile = new File(sourceDir, "out.xml");
- FileUtils.delete(outFile);
- ImmutablePair<Option, String[]> outputFile = ImmutablePair.of(Arg.OUTPUT_FILE.option(), new String[]{outFile.getAbsolutePath()});
- ImmutablePair<Option, String[]> stylesheet = ImmutablePair.of(Arg.OUTPUT_STYLE.option(), new String[]{StyleSheets.XML.arg()});
- File archive = Resources.getResourceFile("tikaFiles/archive/dummy.jar");
- File localArchive = new File(sourceDir, "dummy.jar");
- try (InputStream in = Files.newInputStream(archive.toPath());
- OutputStream out = Files.newOutputStream(localArchive.toPath())) {
- IOUtils.copy(in, out);
- }
-
- for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
- args[0] = proc.name();
- ReportConfiguration config = generateConfig(outputFile, stylesheet, ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- reporter.output();
-
- Document document = XmlUtils.toDom(Files.newInputStream(outFile.toPath()));
- XmlUtils.assertIsPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']");
- switch (proc) {
- case ABSENCE:
- XmlUtils.assertIsPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='AL ']");
- XmlUtils.assertIsPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='?????']");
- break;
- case PRESENCE:
- XmlUtils.assertIsPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='AL ']");
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='?????']");
- break;
- case NOTIFICATION:
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='AL ']");
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, "/rat-report/resource[@name='/dummy.jar']/license[@family='?????']");
- break;
- default:
- throw new IllegalArgumentException("Unexpected processing " + proc);
- }
- }
- } catch (IOException | RatException | SAXException | ParserConfigurationException |
- XPathExpressionException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputArchiveTest() {
- archiveTest(Arg.OUTPUT_ARCHIVE.find("output-archive"));
- }
-
- private void standardTest(final Option option) {
- XPath xPath = XPathFactory.newInstance().newXPath();
- String[] args = {null};
-
- try {
- configureSourceDir(option);
- File outFile = new File(sourceDir, "out.xml");
- ImmutablePair<Option, String[]> outputFile = ImmutablePair.of(Arg.OUTPUT_FILE.option(), new String[]{outFile.getAbsolutePath()});
- ImmutablePair<Option, String[]> stylesheet = ImmutablePair.of(Arg.OUTPUT_STYLE.option(), new String[]{StyleSheets.XML.arg()});
-
- writeFile("Test.java", Arrays.asList("/*\n", "SPDX-License-Identifier: Apache-2.0\n",
- "*/\n\n", "class Test {}\n"));
- writeFile("Missing.java", Arrays.asList("/* no license */\n\n", "class Test {}\n"));
-
- String testDoc = "/rat-report/resource[@name='/Test.java']";
- String missingDoc = "/rat-report/resource[@name='/Missing.java']";
-
- for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
- args[0] = proc.name();
- ReportConfiguration config = generateConfig(outputFile, stylesheet, ImmutablePair.of(option, args));
- Reporter reporter = new Reporter(config);
- reporter.output();
-
- Document document = XmlUtils.toDom(Files.newInputStream(outFile.toPath()));
- XmlUtils.assertIsPresent(proc.name(), document, xPath, testDoc);
- XmlUtils.assertIsPresent(proc.name(), document, xPath, missingDoc);
-
- switch (proc) {
- case ABSENCE:
- XmlUtils.assertIsPresent(proc.name(), document, xPath, testDoc + "/license[@family='AL ']");
- XmlUtils.assertIsPresent(proc.name(), document, xPath, missingDoc + "/license[@family='?????']");
- break;
- case PRESENCE:
- XmlUtils.assertIsPresent(proc.name(), document, xPath, testDoc + "/license[@family='AL ']");
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, missingDoc + "/license[@family='?????']");
- break;
- case NOTIFICATION:
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, testDoc + "/license[@family='AL ']");
- XmlUtils.assertIsNotPresent(proc.name(), document, xPath, missingDoc + "/license[@family='?????']");
- break;
- default:
- throw new IllegalArgumentException("Unexpected processing " + proc);
- }
- }
- } catch (IOException | RatException | SAXException | ParserConfigurationException |
- XPathExpressionException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void outputStandardTest() {
- standardTest(Arg.OUTPUT_STANDARD.find("output-standard"));
- }
-
- private void editCopyrightTest(final Option option, final Option extraOption) {
- final String myCopyright = "MyCopyright";
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, new String[]{myCopyright});
- final boolean forced = Arg.EDIT_OVERWRITE.option().equals(extraOption);
- final boolean dryRun = Arg.DRY_RUN.option().equals(extraOption);
- Pair<Option, String[]> extraArg = null;
- if (forced || dryRun) {
- extraArg = ImmutablePair.of(extraOption, null);
- }
-
- try {
- configureSourceDir(option);
- File javaFile = writeFile("Missing.java", Arrays.asList("/* no license */\n\n", "class Test {}\n"));
- File newJavaFile = new File(sourceDir, "Missing.java.new");
- FileUtils.delete(newJavaFile);
-
- ReportConfiguration config = extraArg != null ? generateConfig(arg1, extraArg) : generateConfig(arg1);
- Reporter reporter = new Reporter(config);
- reporter.execute();
-
- String actualText = TextUtils.readFile(javaFile);
- TextUtils.assertNotContains(myCopyright, actualText);
-
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.EDIT_ADD.find("edit-license"), null);
- config = extraArg != null ? generateConfig(arg1, arg2, extraArg) : generateConfig(arg1, arg2);
- reporter = new Reporter(config);
- reporter.execute();
-
- actualText = TextUtils.readFile(javaFile);
- if (forced) {
- TextUtils.assertContains(myCopyright, actualText);
- assertThat(newJavaFile).doesNotExist();
- } else if (dryRun) {
- TextUtils.assertNotContains(myCopyright, actualText);
- assertThat(newJavaFile).doesNotExist();
- } else {
- TextUtils.assertNotContains(myCopyright, actualText);
- assertThat(newJavaFile).exists();
- }
- } catch (IOException | RatException e) {
- fail(e.getMessage(), e);
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void copyrightTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("copyright"), null);
- }
-
- @OptionCollectionTest.TestFunction
- protected void editCopyrightTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"), null);
- }
-
- @OptionCollectionTest.TestFunction
- protected void forceTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"), Arg.EDIT_OVERWRITE.find("force"));
- }
-
- @OptionCollectionTest.TestFunction
- protected void editOverwriteTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"), Arg.EDIT_OVERWRITE.find("edit-overwrite"));
- }
-
- @OptionCollectionTest.TestFunction
- @Override
- public void helpTest() {
- PrintStream origin = System.out;
- Options options = OptionCollection.buildOptions();
- Pair<Option, String[]> arg1 = ImmutablePair.of(OptionCollection.HELP, null);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- String actualText = null;
- try (PrintStream out = new PrintStream(baos)) {
- System.setOut(out);
- configureSourceDir(OptionCollection.HELP);
-
- ReportConfiguration config = generateConfig(Arrays.asList(arg1), true);
- assertThat(helpCalled.get()).as("Help was not called").isTrue();
- new Help(System.out).printUsage(options);
- actualText = baos.toString(StandardCharsets.UTF_8.name());
- } catch (IOException e) {
- fail(e.getMessage(), e);
- } finally {
- System.setOut(origin);
- }
-
- // verify all the options
- assertThat(actualText).contains("====== Available Options ======");
- for (Option option : options.getOptions()) {
- StringBuilder regex = new StringBuilder();
- if (option.getOpt() != null) {
- regex.append("-").append(option.getOpt());
- if (option.hasLongOpt()) {
- regex.append(",");
- }
- }
- if (option.hasLongOpt()) {
- regex.append("--").append(option.getLongOpt());
- }
- if (option.hasArg()) {
- String name = option.getArgName() == null ? "arg" : option.getArgName();
- regex.append(".+\\<").append(name).append("\\>");
- }
- if (option.isDeprecated()) {
- regex.append(".+\\[Deprecated ");
- }
- assertThat(Pattern.compile(regex.toString()).matcher(actualText).find()).as("missing '" + regex + "'").isTrue();
- }
-
- assertThat(actualText).contains("====== Argument Types ======");
- assertThat(actualText).contains("====== Standard Collections ======");
- for (StandardCollection collection : StandardCollection.values()) {
- assertThat(actualText).contains("<" + collection.name() + ">");
- }
- }
-
- @OptionCollectionTest.TestFunction
- protected void helpLicensesTest() {
- PrintStream origin = System.out;
- Option option = HELP_LICENSES.option();
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, null);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- String actualText = null;
- try (PrintStream out = new PrintStream(baos)) {
- System.setOut(out);
- configureSourceDir(option);
- ReportConfiguration config = generateConfig(arg1);
- actualText = baos.toString(StandardCharsets.UTF_8.name());
- } catch (IOException e) {
- fail(e.getMessage(), e);
- } finally {
- System.setOut(origin);
- }
-
- assertThat(actualText).isNotNull();
- TextUtils.assertContains("====== Licenses ======", actualText);
- TextUtils.assertContains("====== Defined Matchers ======", actualText);
- TextUtils.assertContains("====== Defined Families ======", actualText);
- }
-
- @OptionCollectionTest.TestFunction
- protected void dryRunTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"), Arg.DRY_RUN.find("dry-run"));
- }
-}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
index 9c7a389c..b44b2e51 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsTest.java
@@ -21,25 +21,26 @@ package org.apache.rat;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
+import java.util.stream.Stream;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+import org.apache.commons.cli.ParseException;
import org.apache.rat.api.RatException;
import org.apache.rat.report.claim.ClaimStatistic;
-import org.apache.rat.test.AbstractConfigurationOptionsProvider;
import org.apache.rat.testhelpers.FileUtils;
+import org.apache.rat.testhelpers.data.OptionTestDataProvider;
+import org.apache.rat.testhelpers.data.TestData;
+import org.apache.rat.testhelpers.data.ValidatorData;
import org.apache.rat.testhelpers.XmlUtils;
-import org.apache.rat.utils.DefaultLog;
-import org.apache.rat.utils.Log;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Fail.fail;
@@ -49,10 +50,7 @@ public final class ReporterOptionsTest {
@TempDir
static Path testPath;
- @AfterAll
- static void preserveData() {
- AbstractConfigurationOptionsProvider.preserveData(testPath.toFile(), "reporterOptionsTest");
- }
+ private static final OptionTestDataProvider optionTestDataProvider = new OptionTestDataProvider();
/**
* This method is a known workaround for
@@ -64,9 +62,10 @@ public final class ReporterOptionsTest {
System.gc();
}
- @BeforeEach
- void setup() {
- ReporterOptionsProvider.sourceDir = null;
+
+ static Stream<Arguments> getTestData() {
+ return optionTestDataProvider.getOptionTests().stream().map(testData ->
+ Arguments.of(testData.getTestName(), testData));
}
/**
@@ -74,10 +73,15 @@ public final class ReporterOptionsTest {
* @param name The name of the test.
*/
@ParameterizedTest( name = "{index} {0}")
- @ArgumentsSource(ReporterOptionsProvider.class)
- void testOptionsUpdateConfig(String name, OptionCollectionTest.OptionTest test) {
- DefaultLog.getInstance().log(Log.Level.INFO, "Running test for: " + name);
- test.test();
+ @MethodSource("getTestData")
+ void testOptionsUpdateConfig(String name, TestData test) throws Exception {
+ Path basePath = testPath.resolve(test.getTestName());
+ test.setupFiles(basePath);
+ ReportConfiguration config = OptionCollection.parseCommands(basePath.toFile(), test.getCommandLine(), o -> fail("Help called"), true);
+ Reporter.Output output = config != null ? new Reporter(config).execute() : null;
+ ValidatorData data = new ValidatorData(
+ output, config, basePath.toString());
+ test.getValidator().accept(data);
}
@Test
@@ -90,15 +94,15 @@ public final class ReporterOptionsTest {
FileUtils.writeFile(testDir, "foo.md");
ReportConfiguration config = OptionCollection.parseCommands(testDir, args, o -> fail("Help called"), true);
Reporter reporter = new Reporter(config);
- ClaimStatistic claimStatistic = reporter.execute();
- XmlUtils.printDocument(System.out, reporter.getDocument());
+ Reporter.Output output = reporter.execute();
+ XmlUtils.printDocument(System.out, output.getDocument());
XPath xpath = XPathFactory.newInstance().newXPath();
- XmlUtils.assertIsPresent(reporter.getDocument(), xpath, "/rat-report/resource[@name='/foo.md']");
- XmlUtils.assertAttributes(reporter.getDocument(), xpath, "/rat-report/resource[@name='/foo.md']",
+ XmlUtils.assertIsPresent(output.getDocument(), xpath, "/rat-report/resource[@name='/foo.md']");
+ XmlUtils.assertAttributes(output.getDocument(), xpath, "/rat-report/resource[@name='/foo.md']",
XmlUtils.mapOf("type", "IGNORED"));
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(0);
- assertThat(claimStatistic.getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(2);
- } catch (IOException | RatException | XPathExpressionException e) {
+ assertThat(output.getStatistic().getCounter(ClaimStatistic.Counter.STANDARDS)).isEqualTo(0);
+ assertThat(output.getStatistic().getCounter(ClaimStatistic.Counter.IGNORED)).isEqualTo(2);
+ } catch (IOException | ParseException | RatException | XPathExpressionException e) {
fail(e);
}
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
index 3de3e23e..76cffbea 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
@@ -19,21 +19,23 @@
package org.apache.rat;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Fail.fail;
-import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import java.util.stream.Stream;
import javax.xml.XMLConstants;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
@@ -52,7 +54,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.rat.api.Document.Type;
import org.apache.rat.api.RatException;
import org.apache.rat.commandline.ArgumentContext;
-import org.apache.rat.commandline.StyleSheets;
import org.apache.rat.document.FileDocument;
import org.apache.rat.document.DocumentName;
import org.apache.rat.license.ILicenseFamily;
@@ -60,9 +61,15 @@ import org.apache.rat.report.claim.ClaimStatistic;
import org.apache.rat.test.utils.Resources;
import org.apache.rat.testhelpers.TextUtils;
import org.apache.rat.testhelpers.XmlUtils;
+import org.apache.rat.testhelpers.data.ReportTestDataProvider;
+import org.apache.rat.testhelpers.data.TestData;
+import org.apache.rat.testhelpers.data.ValidatorData;
import org.apache.rat.walker.DirectoryWalker;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@@ -86,7 +93,7 @@ public class ReporterTest {
CommandLine cl = new DefaultParser().parse(OptionCollection.buildOptions(), new String[]{"--output-style", "xml", "--output-file", output.getPath(), basedir});
ArgumentContext ctxt = new ArgumentContext(new File("."), cl);
ReportConfiguration config = OptionCollection.createConfiguration(ctxt);
- ClaimStatistic statistic = new Reporter(config).execute();
+ ClaimStatistic statistic = new Reporter(config).execute().getStatistic();
assertThat(statistic.getCounter(Type.ARCHIVE)).isEqualTo(1);
assertThat(statistic.getCounter(Type.BINARY)).isEqualTo(2);
@@ -137,11 +144,11 @@ public class ReporterTest {
@Test
public void testOutputOption() throws Exception {
File output = new File(tempDirectory, "test");
- CommandLine commandLine = new DefaultParser().parse(OptionCollection.buildOptions(), new String[]{"-o", output.getCanonicalPath(), basedir});
+ CommandLine commandLine = new DefaultParser().parse(OptionCollection.buildOptions(), new String[]{"--output-file", output.getCanonicalPath(), basedir});
ArgumentContext ctxt = new ArgumentContext(new File("."), commandLine);
ReportConfiguration config = OptionCollection.createConfiguration(ctxt);
- new Reporter(config).output();
+ new Reporter(config).execute().format(config);
assertThat(output.exists()).isTrue();
String content = FileUtils.readFileToString(output, StandardCharsets.UTF_8);
TextUtils.assertPatternInTarget("^! Unapproved:\\s*2 ", content);
@@ -160,7 +167,7 @@ public class ReporterTest {
ArgumentContext ctxt = new ArgumentContext(new File("."), commandLine);
ReportConfiguration config = OptionCollection.createConfiguration(ctxt);
- new Reporter(config).output();
+ new Reporter(config).execute().format(config);
} finally {
System.setOut(origin);
}
@@ -213,7 +220,7 @@ public class ReporterTest {
ArgumentContext ctxt = new ArgumentContext(new File("."), commandLine);
ReportConfiguration config = OptionCollection.createConfiguration(ctxt);
- new Reporter(config).output();
+ new Reporter(config).execute().format(config);
assertThat(output).exists();
Document doc = XmlUtils.toDom(java.nio.file.Files.newInputStream(output.toPath()));
@@ -403,13 +410,8 @@ public class ReporterTest {
@Test
public void xmlReportTest() throws Exception {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
ReportConfiguration configuration = initializeConfiguration();
- configuration.setStyleSheet(StyleSheets.XML.getStyleSheet());
- configuration.setOut(() -> out);
- new Reporter(configuration).output();
- Document doc = XmlUtils.toDom(new ByteArrayInputStream(out.toByteArray()));
+ Document doc = new Reporter(configuration).execute().getDocument();
XPath xPath = XPathFactory.newInstance().newXPath();
@@ -456,9 +458,8 @@ public class ReporterTest {
ByteArrayOutputStream out = new ByteArrayOutputStream();
ReportConfiguration configuration = initializeConfiguration();
configuration.setOut(() -> out);
- new Reporter(configuration).output();
+ new Reporter(configuration).execute().format(configuration);
- out.flush();
String document = out.toString();
TextUtils.assertNotContains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", document);
@@ -473,9 +474,8 @@ public class ReporterTest {
ReportConfiguration configuration = initializeConfiguration();
configuration.setOut(() -> out);
configuration.setStyleSheet(this.getClass().getResource("/org/apache/rat/unapproved-licenses.xsl"));
- new Reporter(configuration).output();
+ new Reporter(configuration).execute().format(configuration);
- out.flush();
String document = out.toString();
TextUtils.assertContains("Generated at: ", document );
@@ -486,21 +486,46 @@ public class ReporterTest {
@Test
public void counterMaxTest() throws Exception {
ReportConfiguration config = initializeConfiguration();
- Reporter reporter = new Reporter(config);
- reporter.output();
+ Reporter.Output output = new Reporter(config).execute();
assertThat(config.getClaimValidator().hasErrors()).isTrue();
- assertThat(config.getClaimValidator().isValid(ClaimStatistic.Counter.UNAPPROVED, reporter.getClaimsStatistic().getCounter(ClaimStatistic.Counter.UNAPPROVED)))
+ assertThat(config.getClaimValidator().isValid(ClaimStatistic.Counter.UNAPPROVED, output.getStatistic().getCounter(ClaimStatistic.Counter.UNAPPROVED)))
.isFalse();
config = initializeConfiguration();
config.getClaimValidator().setMax(ClaimStatistic.Counter.UNAPPROVED, 2);
- reporter = new Reporter(config);
- reporter.output();
+ output = new Reporter(config).execute();
assertThat(config.getClaimValidator().hasErrors()).isFalse();
- assertThat(config.getClaimValidator().isValid(ClaimStatistic.Counter.UNAPPROVED, reporter.getClaimsStatistic().getCounter(ClaimStatistic.Counter.UNAPPROVED)))
+ assertThat(config.getClaimValidator().isValid(ClaimStatistic.Counter.UNAPPROVED, output.getStatistic().getCounter(ClaimStatistic.Counter.UNAPPROVED)))
.isTrue();
}
+ static Stream<Arguments> getTestData() {
+ return new ReportTestDataProvider().getOptionTests().stream().map(testData ->
+ Arguments.of(testData.getTestName(), testData));
+ }
+
+ @ParameterizedTest( name = "{index} {0}")
+ @MethodSource("getTestData")
+ void testReportData(String name, TestData test) throws Exception {
+ Path tempPath = tempDirectory.toPath();
+ Path basePath = tempPath.resolve(test.getTestName());
+ test.setupFiles(basePath);
+ ReportConfiguration config = OptionCollection.parseCommands(basePath.toFile(),
+ test.getCommandLine(basePath.toString()), o -> fail("Help called"), true);
+ if (test.expectingException()) {
+ assertThatThrownBy(() -> new Reporter(config).execute()).as("Expected throws from " + name)
+ .hasMessageContaining(test.getExpectedException().getMessage());
+ ValidatorData data = new ValidatorData(
+ null, config, basePath.toString());
+ test.getValidator().accept(data);
+ } else {
+ Reporter.Output output = config != null ? new Reporter(config).execute() : null;
+ ValidatorData data = new ValidatorData(
+ output, config, basePath.toString());
+ test.getValidator().accept(data);
+ }
+ }
+
private static class LicenseInfo {
final String id;
final String family;
diff --git a/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java b/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
index 13319f35..6f91c415 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
@@ -22,12 +22,20 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.StringWriter;
import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
+import org.apache.commons.io.IOUtils;
import org.apache.rat.Defaults;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.api.Document;
@@ -39,18 +47,22 @@ import org.apache.rat.document.RatDocumentAnalysisException;
import org.apache.rat.report.claim.SimpleXmlClaimReporter;
import org.apache.rat.report.xml.writer.XmlWriter;
import org.apache.rat.test.utils.Resources;
+import org.apache.rat.testhelpers.FileUtils;
import org.apache.rat.testhelpers.TestingDocument;
import org.apache.rat.testhelpers.TestingDocumentAnalyser;
import org.apache.rat.testhelpers.TextUtils;
-import org.assertj.core.util.Files;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class AnalyserFactoryTest {
+ @TempDir
+ private static Path tempDir;
+
private final DocumentName basedir;
private StringWriter out;
@@ -58,7 +70,7 @@ public class AnalyserFactoryTest {
private DocumentAnalyser analyser;
AnalyserFactoryTest() {
- basedir = DocumentName.builder(new File(Files.currentFolder(), Resources.SRC_TEST_RESOURCES)).build();
+ basedir = DocumentName.builder(tempDir.toFile()).build();
}
@BeforeEach
@@ -70,10 +82,23 @@ public class AnalyserFactoryTest {
analyser = AnalyserFactory.createConfiguredAnalyser(config);
}
+ private File copyResource(final String resourceName) throws IOException {
+ final DocumentName outputName = DocumentName.builder(basedir).setName(resourceName).build();
+ final File outputFile = outputName.asFile();
+ FileUtils.mkDir(outputFile.getParentFile());
+ try (InputStream input = AnalyserFactoryTest.class.getResourceAsStream(resourceName);
+ OutputStream output = new FileOutputStream(outputFile)) {
+ assertThat(input).isNotNull();
+ IOUtils.copy(input, output);
+ }
+ return outputFile;
+ }
+
@Test
public void standardTypeAnalyser() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/Text.txt"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/Text.txt");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.STANDARD);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("text/plain");
@@ -83,8 +108,9 @@ public class AnalyserFactoryTest {
@Test
public void noteTypeAnalyser() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/LICENSE"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/LICENSE");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.NOTICE);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("text/plain");
@@ -92,8 +118,9 @@ public class AnalyserFactoryTest {
@Test
public void binaryTypeAnalyser() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/Image.png"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/Image.png");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.BINARY);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("image/png");
@@ -101,8 +128,9 @@ public class AnalyserFactoryTest {
@Test
public void archiveTypeAnalyserTest() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/dummy.jar"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/dummy.jar");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
Defaults defaults = Defaults.builder().build();
ReportConfiguration config = new ReportConfiguration();
config.setFrom(defaults);
@@ -123,8 +151,9 @@ public class AnalyserFactoryTest {
@ParameterizedTest
@MethodSource("archiveProcessingTestData")
public void archiveProcessingTest(ReportConfiguration.Processing archiveProcessing, int expectedLicenseCount) throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/dummy.jar"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/dummy.jar");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
Defaults defaults = Defaults.builder().build();
ReportConfiguration config = new ReportConfiguration();
config.setFrom(defaults);
@@ -150,8 +179,9 @@ public class AnalyserFactoryTest {
@Test
public void archiveTypeAnalyser() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/dummy.jar"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/exampleData/dummy.jar");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.ARCHIVE);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("application/java-archive");
@@ -159,8 +189,9 @@ public class AnalyserFactoryTest {
@Test
public void RAT211_bmp_Test() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getResourceFile("/jira/RAT211/side_left.bmp"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/jira/RAT211/side_left.bmp");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.BINARY);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("image/bmp");
@@ -168,8 +199,9 @@ public class AnalyserFactoryTest {
@Test
public void RAT211_dia_Test() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getResourceFile("/jira/RAT211/leader-election-message-arrives.dia"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/jira/RAT211/leader-election-message-arrives.dia");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
assertThat(document.getMetaData().getDocumentType()).isEqualTo(Document.Type.ARCHIVE);
assertThat(document.getMetaData().getMediaType().toString()).isEqualTo("application/gzip");
@@ -177,8 +209,9 @@ public class AnalyserFactoryTest {
@Test
public void RAT147_unix_Test() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getResourceFile("/jira/RAT147/unix-newlines.txt.bin"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/jira/RAT147/unix-newlines.txt.bin");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
reporter.report(document);
String result = out.toString();
@@ -189,8 +222,9 @@ public class AnalyserFactoryTest {
@Test
public void RAT147_windows_Test() throws Exception {
- final Document document = new FileDocument(basedir,
- Resources.getResourceFile("/jira/RAT147/windows-newlines.txt.bin"), DocumentNameMatcher.MATCHES_ALL);
+ final File outputFile = copyResource("/jira/RAT147/windows-newlines.txt.bin");
+ final Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
+
analyser.analyse(document);
reporter.report(document);
String result = out.toString();
@@ -207,13 +241,13 @@ public class AnalyserFactoryTest {
config.setStandardProcessing(ReportConfiguration.Processing.NOTIFICATION);
analyser = AnalyserFactory.createConfiguredAnalyser(config);
- Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/Text.txt"), DocumentNameMatcher.MATCHES_ALL);
+ File outputFile = copyResource("/exampleData/Text.txt");
+ Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isFalse();
- document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/sub/Empty.txt"), DocumentNameMatcher.MATCHES_ALL);
+ outputFile = copyResource("/exampleData/sub/Empty.txt");
+ document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isFalse();
}
@@ -226,13 +260,13 @@ public class AnalyserFactoryTest {
config.setStandardProcessing(ReportConfiguration.Processing.ABSENCE);
analyser = AnalyserFactory.createConfiguredAnalyser(config);
- Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/Text.txt"), DocumentNameMatcher.MATCHES_ALL);
+ File outputFile = copyResource("/exampleData/Text.txt");
+ Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isTrue();
- document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/sub/Empty.txt"), DocumentNameMatcher.MATCHES_ALL);
+ outputFile = copyResource("/exampleData/sub/Empty.txt");
+ document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isTrue();
}
@@ -245,13 +279,13 @@ public class AnalyserFactoryTest {
config.setStandardProcessing(ReportConfiguration.Processing.PRESENCE);
analyser = AnalyserFactory.createConfiguredAnalyser(config);
- Document document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/Text.txt"), DocumentNameMatcher.MATCHES_ALL);
+ File outputFile = copyResource("/exampleData/Text.txt");
+ Document document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isTrue();
- document = new FileDocument(basedir,
- Resources.getExampleResource("exampleData/sub/Empty.txt"), DocumentNameMatcher.MATCHES_ALL);
+ outputFile = copyResource("/exampleData/sub/Empty.txt");
+ document = new FileDocument(basedir, outputFile, DocumentNameMatcher.MATCHES_ALL);
analyser.analyse(document);
assertThat(document.getMetaData().detectedLicense()).isFalse();
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/analysis/TikaProcessorTest.java b/apache-rat-core/src/test/java/org/apache/rat/analysis/TikaProcessorTest.java
index 1e1ee7f9..7f1e8f3b 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/analysis/TikaProcessorTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/analysis/TikaProcessorTest.java
@@ -18,13 +18,22 @@
*/
package org.apache.rat.analysis;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.io.IOUtils;
import org.apache.rat.api.Document;
import org.apache.rat.document.RatDocumentAnalysisException;
import org.apache.rat.document.DocumentNameMatcher;
import org.apache.rat.document.FileDocument;
import org.apache.rat.report.claim.ClaimStatistic;
-import org.apache.rat.test.utils.Resources;
import org.apache.rat.document.DocumentName;
+import org.apache.rat.testhelpers.FileUtils;
+import org.apache.rat.utils.DefaultLog;
import org.junit.jupiter.api.Test;
import java.io.File;
@@ -37,13 +46,35 @@ import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
-import java.util.Objects;
import java.util.SortedSet;
+import org.junit.jupiter.api.io.TempDir;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class TikaProcessorTest {
+
+ @TempDir
+ private static Path tempDir;
+
+ private final DocumentName basedir;
+
+ TikaProcessorTest() {
+ basedir = DocumentName.builder(tempDir.toFile()).build();
+ }
+
+ private static File copyResource(DocumentName basedir, final String resourceName) throws IOException {
+ final DocumentName outputName = DocumentName.builder(basedir).setName(resourceName).build();
+ final File outputFile = outputName.asFile();
+ FileUtils.mkDir(outputFile.getParentFile());
+ try (InputStream input = TikaProcessorTest.class.getResourceAsStream(resourceName);
+ OutputStream output = new FileOutputStream(outputFile)) {
+ assertThat(input).isNotNull();
+ IOUtils.copy(input, output);
+ }
+ return outputFile;
+ }
/**
* Used to swallow a MalformedInputException and return false
* because the encoding of the stream was different from the
@@ -65,18 +96,14 @@ public class TikaProcessorTest {
@Test
public void UTF16_input() throws Exception {
- Document doc = mkDocument(Resources.getResourceStream("/binaries/UTF16_with_signature.xml"),
- DocumentNameMatcher.MATCHES_ALL);
+ Document doc = mkDocument("/binaries/UTF16_with_signature.xml");
TikaProcessor.process(doc);
assertEquals(Document.Type.STANDARD, doc.getMetaData().getDocumentType());
}
- private FileDocument mkDocument(File f) {
- return new FileDocument(DocumentName.builder(f).build(), f, DocumentNameMatcher.MATCHES_ALL);
- }
private FileDocument mkDocument(String fileName) throws IOException {
- return mkDocument(Resources.getResourceFile(fileName));
+ return new FileDocument(basedir, copyResource(basedir, fileName), DocumentNameMatcher.MATCHES_ALL);
}
@Test
@@ -101,14 +128,14 @@ public class TikaProcessorTest {
@Test
public void plainTextTest() throws Exception {
- FileDocument doc = mkDocument(Resources.getExampleResource("exampleData/Text.txt"));
+ FileDocument doc = mkDocument("/exampleData/Text.txt");
TikaProcessor.process(doc);
assertEquals(Document.Type.STANDARD, doc.getMetaData().getDocumentType());
}
@Test
public void emptyFileTest() throws Exception {
- FileDocument doc = mkDocument(Resources.getExampleResource("exampleData/sub/Empty.txt"));
+ FileDocument doc = mkDocument("/exampleData/sub/Empty.txt");
TikaProcessor.process(doc);
assertEquals(Document.Type.STANDARD, doc.getMetaData().getDocumentType());
}
@@ -120,27 +147,59 @@ public class TikaProcessorTest {
assertEquals(Document.Type.STANDARD, doc.getMetaData().getDocumentType());
}
+ public static List<FileDocument> getTikaTestFiles(final DocumentName basedir) throws IOException {
+ final List<FileDocument> result = new ArrayList<>();
+ final List<String> dirNames = new ArrayList<>();
+ for (Document.Type docType : Document.Type.values()) {
+ dirNames.add(docType.name().toLowerCase(Locale.ROOT));
+ }
+ final List<String> lines = IOUtils.readLines(TikaProcessorTest.class.getResource("/tikaFiles").openStream(),
+ StandardCharsets.UTF_8);
+ for (String line : lines) {
+ if (dirNames.contains(line)) {
+ final String path = "/tikaFiles/" + line;
+ List<String> files = IOUtils.readLines(TikaProcessorTest.class.getResource(path).openStream(),
+ StandardCharsets.UTF_8);
+ for (String file : files) {
+ result.add(new FileDocument(basedir, copyResource(basedir, path+"/"+file), DocumentNameMatcher.MATCHES_ALL));
+ }
+ } else {
+ result.add(new FileDocument(basedir, copyResource(basedir, "/tikaFiles/"+line), DocumentNameMatcher.MATCHES_ALL));
+ }
+ }
+ return result;
+ }
+
@Test
- public void testTikaFiles() throws RatDocumentAnalysisException {
- File dir = new File("src/test/resources/tikaFiles");
+ public void testTikaFiles() throws RatDocumentAnalysisException, IOException {
+ Pattern docTypeMatch = Pattern.compile("/tikaFiles/([^/]+)/.*");
+ List<FileDocument> tikaFiles = getTikaTestFiles(basedir);
Map<String, Document.Type> unseenMime = TikaProcessor.getDocumentTypeMap();
ClaimStatistic statistic = new ClaimStatistic();
- for (Document.Type docType : Document.Type.values()) {
- File typeDir = new File(dir, docType.name().toLowerCase(Locale.ROOT));
- if (typeDir.isDirectory()) {
- for (File file : Objects.requireNonNull(typeDir.listFiles())) {
- Document doc = mkDocument(file);
- String mimeType = TikaProcessor.process(doc);
- statistic.incCounter(doc.getMetaData().getDocumentType(), 1);
- assertEquals(docType, doc.getMetaData().getDocumentType(), () -> "Wrong type for " + file.toString());
- unseenMime.remove(mimeType);
- }
+ for (FileDocument document : tikaFiles) {
+ String mimeType = TikaProcessor.process(document);
+ statistic.incCounter(document.getMetaData().getDocumentType(), 1);
+ String localizedName = document.getName().localized("/");
+ Matcher matcher = docTypeMatch.matcher(localizedName);
+ if (matcher.matches()) {
+ String type = matcher.group(1);
+ Document.Type expected = Document.Type.valueOf(type.toUpperCase(Locale.ROOT));
+ assertThat(document.getMetaData().getDocumentType()).describedAs("Wrong type for " + document)
+ .isEqualTo(expected);
}
+ unseenMime.remove(mimeType);
}
- System.out.println("untested mime types");
- unseenMime.keySet().forEach(System.out::println);
+ // TODO ensure that all mime-types are tested.
+ //assertThat(unseenMime.keySet()).describedAs("Untested mime types").isEmpty();
+ unseenMime.keySet().forEach( t -> DefaultLog.getInstance().warn("Untested mime-type: " + t));
+
+ // TODO ensure that all document types are tested.
for (Document.Type type : Document.Type.values()) {
- System.out.format("Tested %s %s files%n", statistic.getCounter(type), type);
+ //assertThat(statistic.getCounter(type)).describedAs("Untested document type: " + type)
+ // .isGreaterThan(0);
+ if (statistic.getCounter(type) == 0) {
+ DefaultLog.getInstance().warn("Untested documentType: " + type);
+ }
}
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenseAppender.java b/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenseAppender.java
index 7b5aef85..696e520d 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenseAppender.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/annotation/TestLicenseAppender.java
@@ -18,6 +18,7 @@
*/
package org.apache.rat.annotation;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -25,14 +26,19 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
import java.io.Writer;
import java.nio.charset.Charset;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.apache.rat.analysis.AnalyserFactoryTest;
+import org.apache.rat.document.DocumentName;
import org.apache.rat.test.utils.Resources;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
@@ -41,7 +47,6 @@ public class TestLicenseAppender {
@TempDir
private File baseTempFolder;
-
private static final String FIRST_LICENSE_LINE = " Licensed to the Apache Software Foundation (ASF) under one";
@FunctionalInterface
@@ -384,9 +389,23 @@ public class TestLicenseAppender {
}, checkLines(firstLine, secondLine, thirdLine));
}
+ private File copyResource(final DocumentName basedir, final String resourceName) throws IOException {
+ final DocumentName outputName = DocumentName.builder(basedir).setName(resourceName).build();
+ final File outputFile = outputName.asFile();
+ org.apache.rat.testhelpers.FileUtils.mkDir(outputFile.getParentFile());
+ try (InputStream input = TestLicenseAppender.class.getResourceAsStream(resourceName);
+ OutputStream output = new FileOutputStream(outputFile)) {
+ assertThat(input).isNotNull();
+ IOUtils.copy(input, output);
+ }
+ return outputFile;
+ }
+
@Test
public void fileWithBOM() throws IOException {
- File f = Resources.getResourceFile("violations/FilterTest.cs");
+ DocumentName basedir = DocumentName.builder(baseTempFolder).build();
+
+ File f = copyResource(basedir, "/violations/FilterTest.cs");
ApacheV2LicenseAppender appender = new ApacheV2LicenseAppender();
appender.append(f);
diff --git a/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java b/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java
index a4ef65ca..75650a0d 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/config/parameters/DescriptionBuilderTest.java
@@ -24,13 +24,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-import java.io.File;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
-import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.function.Consumer;
@@ -39,13 +39,12 @@ import org.apache.rat.BuilderParams;
import org.apache.rat.analysis.matchers.AndMatcher;
import org.apache.rat.analysis.matchers.CopyrightMatcher;
import org.apache.rat.api.Document;
-import org.apache.rat.document.DocumentName;
-import org.apache.rat.document.DocumentNameMatcher;
-import org.apache.rat.document.FileDocument;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
+import org.reflections.Reflections;
+import org.reflections.scanners.Scanners;
public class DescriptionBuilderTest {
@@ -74,12 +73,13 @@ public class DescriptionBuilderTest {
/**
* Test to verify that all Description based inspection invoked methods exist.
+ *
* @param clazz The class to check
* @param desc The description of an element in that class.
*/
- @ParameterizedTest
+ @ParameterizedTest(name = "{index} {0}")
@MethodSource("descriptionSource")
- public void textConfigParameters(Class<?> clazz, Description desc) {
+ public void textConfigParameters(String name, Class<?> clazz, Description desc) {
if (desc.getType() == ComponentType.BUILD_PARAMETER) {
try {
Method m = BuilderParams.class.getMethod(desc.getCommonName());
@@ -97,9 +97,12 @@ public class DescriptionBuilderTest {
}
}
- /** Class to build a list of documents that are class files. */
+ /**
+ * Class to build a list of documents that are class files.
+ */
private static class DocumentProcessor implements Consumer<Document> {
final SortedSet<Document> documents = new TreeSet<>();
+
@Override
public void accept(Document document) {
if (document.isDirectory()) {
@@ -114,31 +117,36 @@ public class DescriptionBuilderTest {
/**
* Scans the build classes directory to locate all class files that have Description annotations and ensure its validity.
+ *
* @return A stream of class and descriptions to validate.
* @throws URISyntaxException if URI is incorrect.
* @throws ClassNotFoundException if class can not be found.
*/
public static Stream<Arguments> descriptionSource() throws URISyntaxException, ClassNotFoundException {
- List<Arguments> arguments = new ArrayList<>();
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- URL url = classLoader.getResource("");
- File baseDir = new File(url.toURI());
- baseDir = new File(baseDir.getParent(), "classes");
- DocumentName documentName = DocumentName.builder(baseDir).build();
- FileDocument fileDocument = new FileDocument(documentName, baseDir, DocumentNameMatcher.MATCHES_ALL);
- DocumentProcessor processor = new DocumentProcessor();
- processor.accept(fileDocument);
+ Reflections reflections = new Reflections("org.apache.rat",
+ Scanners.TypesAnnotated,
+ Scanners.FieldsAnnotated,
+ Scanners.MethodsAnnotated);
+ Set<Class<?>> types = reflections
+ .getTypesAnnotatedWith(ConfigComponent.class);
+
+ Set<Method> methods = reflections
+ .getMethodsAnnotatedWith(ConfigComponent.class);
+ methods.forEach(method -> types.add(method.getDeclaringClass()));
- for (Document document : processor.documents) {
- String className = document.getName().localized(".");
- className = className.substring(1, className.length() - ".class".length());
- Class<?> clazz = Class.forName(className);
+ Set<Field> fields = reflections.getFieldsAnnotatedWith(ConfigComponent.class);
+ fields.forEach(field -> types.add(field.getDeclaringClass()));
+
+
+ List<Arguments> arguments = new ArrayList<>();
+ for (Class<?> clazz : types) {
List<Description> descriptionList = DescriptionBuilder.getConfigComponents(clazz);
if (descriptionList != null) {
- descriptionList.forEach( desc -> arguments.add(Arguments.of(clazz, desc)));
+ descriptionList.forEach(desc -> arguments.add(Arguments.of(
+ String.format("%s %s %s", clazz.getSimpleName(), desc.getType(), desc.getCommonName()),
+ clazz, desc)));
}
}
-
return arguments.stream();
}
}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java b/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
index 9176361f..f603b08a 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
@@ -56,6 +56,10 @@ public class XMLConfigurationReaderTest {
public static final String[] EXPECTED_LICENSES = { "AL1.0", "AL1.1", "AL2.0", "BSD-3", "DOJO", "TMF", "CDDL1", "ILLUMOS", "GPL1", "GPL2",
"GPL3", "MIT", "OASIS", "W3C", "W3CD" };
+ public static final String[] APPROVED_LICENSES = { "AL1.0", "AL1.1", "AL2.0", "BSD-3", "DOJO", "TMF", "CDDL1", "ILLUMOS",
+ "MIT", "OASIS", "W3C", "W3CD" };
+
+
@Test
public void approvedLicenseIdTest() throws URISyntaxException {
XMLConfigurationReader reader = new XMLConfigurationReader();
@@ -63,9 +67,8 @@ public class XMLConfigurationReaderTest {
assertThat(url).isNotNull();
reader.read(url.toURI());
- Collection<String> readCategories = reader.approvedLicenseId();
-
- assertArrayEquals(APPROVED_IDS, readCategories.toArray(new String[readCategories.size()]));
+ Collection<String> actual = reader.approvedLicenseId();
+ assertThat(actual).containsExactlyInAnyOrder(APPROVED_IDS);
}
@Test
@@ -74,20 +77,20 @@ public class XMLConfigurationReaderTest {
URL url = XMLConfigurationReaderTest.class.getResource("/org/apache/rat/default.xml");
reader.read(url.toURI());
- Collection<String> readCategories = reader.readLicenses().stream().map(IHeaderMatcher::getId)
- .collect(Collectors.toList());
- assertArrayEquals(EXPECTED_LICENSES, readCategories.toArray(new String[0]));
+ assertArrayEquals(EXPECTED_LICENSES, reader.readLicenses().stream().map(IHeaderMatcher::getId).toArray(String[]::new));
}
@Test
public void LicenseFamiliesTest() throws URISyntaxException {
XMLConfigurationReader reader = new XMLConfigurationReader();
URL url = XMLConfigurationReaderTest.class.getResource("/org/apache/rat/default.xml");
+ assertNotNull(url);
reader.read(url.toURI());
- Collection<String> readCategories = reader.readFamilies().stream().map(x -> x.getFamilyCategory().trim())
+ Collection<String> actual = reader.readFamilies().stream().map(lf -> lf.getFamilyCategory().trim())
.collect(Collectors.toList());
- assertArrayEquals(EXPECTED_IDS, readCategories.toArray(new String[readCategories.size()]));
+
+ assertThat(actual).containsExactlyInAnyOrder(EXPECTED_IDS);
}
private void checkMatcher(String name, Class<? extends AbstractBuilder> clazz) {
@@ -123,7 +126,7 @@ public class XMLConfigurationReaderTest {
IHeaderMatcher.Builder builder = MatcherBuilderTracker.getMatcherBuilder("copyright");
Description desc = DescriptionBuilder.buildMap(builder.getClass());
- assertNotNull(desc, () -> "did not build description for 'copyright'");
+ assertNotNull(desc, "did not build description for 'copyright'");
assertEquals("copyright", desc.getCommonName());
assertEquals(ComponentType.MATCHER, desc.getType());
assertFalse(desc.isCollection());
diff --git a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
index e3e99476..e4cb10be 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/help/HelpTest.java
@@ -25,7 +25,9 @@ import org.apache.rat.testhelpers.TextUtils;
import org.junit.jupiter.api.Test;
import java.io.StringWriter;
+import java.util.Arrays;
import java.util.Set;
+import java.util.stream.Collectors;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,7 +57,7 @@ public class HelpTest {
@Test
public void verifyArgumentsListed() {
Options opts = OptionCollection.buildOptions();
- Set<String> argTypes = OptionCollection.getArgumentTypes().keySet();
+ Set<String> argTypes = Arrays.stream(OptionCollection.ArgumentType.values()).map(OptionCollection.ArgumentType::getDisplayName).collect(Collectors.toSet());
StringWriter out = new StringWriter();
new Help(out).printUsage(opts);
String result = out.toString();
diff --git a/apache-rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java b/apache-rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java
index e6e00132..8a4c960e 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java
@@ -337,10 +337,25 @@ public class XmlWriterTest {
assertEquals(
writer, writer.openElement("alpha"), "XmlWriters should always return themselves");
assertEquals("<alpha", out.toString(), "Alpha element started");
- assertEquals(
- writer, writer.content(new String(ZERO_CHAR)), "XmlWriters should always return themselves");
- String out = this.out.toString();
- assertEquals("<alpha>?", out, "Replace illegal characters with question marks");
+ CharSequence cs = new CharSequence() {
+ @Override
+ public int length() {
+ return 1;
+ }
+
+ @Override
+ public char charAt(int index) {
+ return Character.highSurrogate(0x110000);
+ }
+
+ @Override
+ public CharSequence subSequence(int start, int end) {
+ return null;
+ }
+ };
+
+ assertEquals(writer, writer.content(cs), "XmlWriters should always return themselves");
+ assertEquals("<alpha>\\uDC00", this.out.toString(), "Replace illegal characters with \\u encoding");
}
@Test
diff --git a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractConfigurationOptionsProvider.java b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractConfigurationOptionsProvider.java
index 62287847..746e7052 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractConfigurationOptionsProvider.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractConfigurationOptionsProvider.java
@@ -1,836 +1,836 @@
-/*
- * 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.test;
-
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import org.apache.commons.cli.Option;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.rat.OptionCollectionTest;
-import org.apache.rat.ReportConfiguration;
-import org.apache.rat.ReporterTest;
-import org.apache.rat.commandline.Arg;
-import org.apache.rat.commandline.StyleSheets;
-import org.apache.rat.config.exclusion.StandardCollection;
-import org.apache.rat.document.DocumentNameMatcher;
-import org.apache.rat.document.DocumentName;
-import org.apache.rat.license.ILicense;
-import org.apache.rat.license.ILicenseFamily;
-import org.apache.rat.license.LicenseSetFactory;
-import org.apache.rat.report.claim.ClaimStatistic;
-import org.apache.rat.test.utils.Resources;
-import org.apache.rat.testhelpers.TextUtils;
-import org.apache.rat.utils.DefaultLog;
-import org.apache.rat.utils.Log.Level;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.nio.file.Files;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.SortedSet;
-
-import static org.apache.rat.commandline.Arg.HELP_LICENSES;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Fail.fail;
-
-/**
- * A list of methods that an OptionsProvider in a test case must support.
- * Use of this interface ensures consistent testing across the UIs. Each method
- * tests an Option from OptionCollection that must be implemented in the UI.
- * Each method in this interface tests an Option in {@link org.apache.rat.OptionCollection}.
- */
-public abstract class AbstractConfigurationOptionsProvider extends AbstractOptionsProvider {
-
- /**
- * Copy the runtime data to the "target" directory.
- * @param baseDir the base directory to copy to.
- * @param targetDir the directory relative to the base directory to copy to.
- */
- public static void preserveData(File baseDir, String targetDir) {
- final Path recordPath = FileSystems.getDefault().getPath("target", targetDir);
- recordPath.toFile().mkdirs();
- try {
- FileUtils.copyDirectory(baseDir, recordPath.toFile());
- } catch (IOException e) {
- System.err.format("Unable to copy data from %s to %s%n", baseDir, recordPath);
- }
- }
-
- /**
- * Copies the test data to the specified directory.
- * @param baseDir the directory to copy the {@code /src/test/resources} to.
- * @return the {@code baseDir} argument.
- */
- public static File setup(final File baseDir) {
- try {
- final File sourceDir = Resources.getResourceDirectory("OptionTools");
- FileUtils.copyDirectory(sourceDir, new File(baseDir,"/src/test/resources/OptionTools"));
- } catch (IOException e) {
- DefaultLog.getInstance().error("Can not copy 'OptionTools' to " + baseDir, e);
- }
- return baseDir;
- }
-
- protected AbstractConfigurationOptionsProvider(final Collection<String> unsupportedArgs, final File baseDir) {
- super(setup(baseDir));
- addTest(OptionCollectionTest.OptionTest.namedTest("addLicense", this::addLicenseTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("config", this::configTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("configuration-no-defaults", this::configurationNoDefaultsTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("copyright", this::copyrightTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("counter-min", this::counterMinTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("counter-max", this::counterMaxTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("dir", () -> DefaultLog.getInstance().info("--dir has no valid test")));
- addTest(OptionCollectionTest.OptionTest.namedTest("dry-run", this::dryRunTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("edit-copyright", this::editCopyrightTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("edit-license", this::editLicenseTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("edit-overwrite", this::editOverwriteTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("exclude", this::excludeTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("exclude-file", this::excludeFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("force", this::forceTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("help", this::helpTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("help-licenses", this::helpLicenses));
- addTest(OptionCollectionTest.OptionTest.namedTest("include", this::includeTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("includes-file", this::includesFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude", this::inputExcludeTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-file", this::inputExcludeFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-parsed-scm", this::inputExcludeParsedScmTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-std", this::inputExcludeStdTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-size", this::inputExcludeSizeTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-include", this::inputIncludeTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-include-file", this::inputIncludeFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-include-std", this::inputIncludeStdTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("input-source", this::inputSourceTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("license-families-approved", this::licenseFamiliesApprovedTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("license-families-approved-file", this::licenseFamiliesApprovedFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("license-families-denied", this::licenseFamiliesDeniedTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("license-families-denied-file", this::licenseFamiliesDeniedFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("licenses", this::licensesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("licenses-approved", this::licensesApprovedTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("licenses-approved-file", this::licensesApprovedFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("licenses-denied", this::licensesDeniedTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("licenses-denied-file", this::licensesDeniedFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("list-families", this::listFamiliesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("list-licenses", this::listLicensesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("log-level", this::logLevelTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("no-default-licenses", this::noDefaultsTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("out", this::outTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-archive", this::outputArchiveTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-families", this::outputFamiliesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-file", this::outputFileTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-licenses", this::outputLicensesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-standard", this::outputStandardTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("output-style", this::outputStyleTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("scan-hidden-directories", this::scanHiddenDirectoriesTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("stylesheet", this::styleSheetTest));
- addTest(OptionCollectionTest.OptionTest.namedTest("xml", this::xmlTest));
- super.validate(unsupportedArgs);
- }
-
- /** Help test */
- protected abstract void helpTest();
-
- // exclude tests
- private void execExcludeTest(final Option option, final String[] args) {
- String[] notExcluded = {"notbaz", "well._afile"};
- String[] excluded = {"some.foo", "B.bar", "justbaz"};
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void excludeFileTest(final Option option) {
- File outputFile = writeFile("exclude.txt", Arrays.asList(EXCLUDE_ARGS));
- execExcludeTest(option, new String[]{outputFile.getAbsolutePath()});
- }
-
- protected void excludeFileTest() {
- excludeFileTest(Arg.EXCLUDE_FILE.find("exclude-file"));
- }
-
- protected void inputExcludeFileTest() {
- excludeFileTest(Arg.EXCLUDE_FILE.find("input-exclude-file"));
- }
-
- protected void excludeTest() {
- execExcludeTest(Arg.EXCLUDE.find("exclude"), EXCLUDE_ARGS);
- }
-
- protected void inputExcludeTest() {
- execExcludeTest(Arg.EXCLUDE.find("input-exclude"), EXCLUDE_ARGS);
- }
-
- protected void inputExcludeStdTest() {
- Option option = Arg.EXCLUDE_STD.find("input-exclude-std");
- String[] args = {StandardCollection.MISC.name()};
- String[] excluded = {"afile~", ".#afile", "%afile%", "._afile"};
- String[] notExcluded = {"afile~more", "what.#afile", "%afile%withMore", "well._afile"};
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void inputExcludeParsedScmTest() {
- Option option = Arg.EXCLUDE_PARSE_SCM.find("input-exclude-parsed-scm");
- String[] args = {"GIT"};
- String[] lines = {
- "# somethings",
- "!thingone", "thing*", System.lineSeparator(),
- "# some fish",
- "**/fish", "*_fish",
- "# some colorful directories",
- "red/", "blue/*/"};
- String[] notExcluded = {"thingone", "dir/fish_two", "some/thingone", "blue/fish/dory" };
- String[] excluded = {"thingtwo", "some/things", "dir/fish", "red/fish", "blue/fish", "some/fish", "another/red_fish"};
-
- writeFile(".gitignore", Arrays.asList(lines));
- File dir = new File(baseDir, "red");
- dir.mkdirs();
- dir = new File(baseDir, "blue");
- dir = new File(dir, "fish");
- dir.mkdirs();
-
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void inputExcludeSizeTest() {
- Option option = Arg.EXCLUDE_SIZE.option();
- String[] args = {"5"};
- writeFile("Hi.txt", Collections.singletonList("Hi"));
- writeFile("Hello.txt", Collections.singletonList("Hello"));
- writeFile("HelloWorld.txt", Collections.singletonList("HelloWorld"));
-
- String[] notExcluded = {"Hello.txt", "HelloWorld.txt"};
- String[] excluded = {"Hi.txt"};
-
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- // include tests
- private void execIncludeTest(final Option option, final String[] args) {
- Option excludeOption = Arg.EXCLUDE.option();
- String[] notExcluded = {"B.bar", "justbaz", "notbaz"};
- String[] excluded = {"some.foo"};
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args),
- ImmutablePair.of(excludeOption, EXCLUDE_ARGS));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void includeFileTest(final Option option) {
- File outputFile = writeFile("include.txt", Arrays.asList(INCLUDE_ARGS));
- execIncludeTest(option, new String[]{outputFile.getAbsolutePath()});
- }
-
- protected void inputIncludeFileTest() {
- includeFileTest(Arg.INCLUDE_FILE.find("input-include-file"));
- }
-
- protected void includesFileTest() {
- includeFileTest(Arg.INCLUDE_FILE.find("includes-file"));
- }
-
- protected void includeTest() {
- execIncludeTest(Arg.INCLUDE.find("include"), INCLUDE_ARGS);
- }
-
- protected void inputIncludeTest() {
- execIncludeTest(Arg.INCLUDE.find("input-include"), INCLUDE_ARGS);
- }
-
- protected void inputIncludeStdTest() {
- ImmutablePair<Option, String[]> excludes = ImmutablePair.of(Arg.EXCLUDE.find("input-exclude"),
- new String[]{"*~more", "*~"});
- Option option = Arg.INCLUDE_STD.find("input-include-std");
- String[] args = {StandardCollection.MISC.name()};
- String[] excluded = {"afile~more"};
- String[] notExcluded = {"afile~", ".#afile", "%afile%", "._afile", "what.#afile", "%afile%withMore", "well._afile"};
- try {
- ReportConfiguration config = generateConfig(excludes, ImmutablePair.of(option, args));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- for (String fname : excluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
- }
- for (String fname : notExcluded) {
- DocumentName docName = mkDocName(fname);
- assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void inputSourceTest() {
- Option option = Arg.SOURCE.find("input-source");
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, new String[]{baseDir.getAbsolutePath()}));
- assertThat(config.hasSource()).isTrue();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- // LICENSE tests
- protected void execLicensesApprovedTest(final Option option, String[] args) {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
- try {
- ReportConfiguration config = generateConfig(arg1);
- SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).contains("one", "two");
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- Pair<Option, String[]> arg2 = ImmutablePair.of(
- Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"),
- null
- );
-
- try {
- ReportConfiguration config = generateConfig(arg1, arg2);
- SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).containsExactly("one", "two");
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void helpLicenses() {
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- PrintStream origin = System.out;
- try (PrintStream out = new PrintStream(output)) {
- System.setOut(out);
- generateConfig(ImmutablePair.of(HELP_LICENSES.option(), null));
- } catch (IOException e) {
- fail(e.getMessage());
- } finally {
- System.setOut(origin);
- }
- String txt = output.toString();
- TextUtils.assertContains("====== Licenses ======", txt);
- TextUtils.assertContains("====== Defined Matchers ======", txt);
- TextUtils.assertContains("====== Defined Families ======", txt);
- }
-
- protected void licensesApprovedFileTest() {
- File outputFile = writeFile("licensesApproved.txt", Arrays.asList("one", "two"));
- execLicensesApprovedTest(Arg.LICENSES_APPROVED_FILE.find("licenses-approved-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- protected void licensesApprovedTest() {
- execLicensesApprovedTest(Arg.LICENSES_APPROVED.find("licenses-approved"),
- new String[]{"one, two"});
- }
-
- private void execLicensesDeniedTest(final Option option, final String[] args) {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getLicenseIds(LicenseSetFactory.LicenseFilter.ALL)).contains("ILLUMOS");
- SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).doesNotContain("ILLUMOS");
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void licensesDeniedTest() {
- execLicensesDeniedTest(Arg.LICENSES_DENIED.find("licenses-denied"), new String[]{"ILLUMOS"});
- }
-
- protected void licensesDeniedFileTest() {
- File outputFile = writeFile("licensesDenied.txt", Collections.singletonList("ILLUMOS"));
- execLicensesDeniedTest(Arg.LICENSES_DENIED_FILE.find("licenses-denied-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- private void execLicenseFamiliesApprovedTest(final Option option, final String[] args) {
- String catz = ILicenseFamily.makeCategory("catz");
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
- try {
- ReportConfiguration config = generateConfig(arg1);
- SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).contains(catz);
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"), null);
- try {
- ReportConfiguration config = generateConfig(arg1, arg2);
- SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).containsExactly(catz);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void licenseFamiliesApprovedFileTest() {
- File outputFile = writeFile("familiesApproved.txt", Collections.singletonList("catz"));
- execLicenseFamiliesApprovedTest(Arg.FAMILIES_APPROVED_FILE.find("license-families-approved-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- protected void licenseFamiliesApprovedTest() {
- execLicenseFamiliesApprovedTest(Arg.FAMILIES_APPROVED.find("license-families-approved"),
- new String[]{"catz"});
- }
-
- private void execLicenseFamiliesDeniedTest(final Option option, final String[] args) {
- String gpl = ILicenseFamily.makeCategory("GPL");
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getLicenseCategories(LicenseSetFactory.LicenseFilter.ALL)).contains(gpl);
- SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
- assertThat(result).doesNotContain(gpl);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void licenseFamiliesDeniedFileTest() {
- File outputFile = writeFile("familiesDenied.txt", Collections.singletonList("GPL"));
- execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED_FILE.find("license-families-denied-file"),
- new String[]{outputFile.getAbsolutePath()});
- }
-
- protected void licenseFamiliesDeniedTest() {
- execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED.find("license-families-denied"),
- new String[]{"GPL"});
- }
-
- protected void counterMaxTest() {
- Option option = Arg.COUNTER_MAX.option();
- String[] args = {null, null};
-
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.nullPair());
- assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
- args[0] = "Unapproved:-1";
- args[1] = "ignored:1";
- config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(Integer.MAX_VALUE);
- assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
- args[1] = "unapproved:5";
- args[0] = "ignored:0";
- config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(5);
- assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void counterMinTest() {
- Option option = Arg.COUNTER_MIN.option();
- String[] args = {null, null};
-
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.nullPair());
- assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
- args[0] = "Unapproved:1";
- args[1] = "ignored:1";
- config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
- assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
- args[1] = "unapproved:5";
- args[0] = "ignored:0";
- config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(5);
- assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void configTest(final Option option) {
- String[] args = {"src/test/resources/OptionTools/One.xml", "src/test/resources/OptionTools/Two.xml"};
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
- try {
- ReportConfiguration config = generateConfig(arg1);
- SortedSet<ILicense> set = config.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
- assertThat(set).hasSizeGreaterThan(2);
- assertThat(LicenseSetFactory.search("ONE", "ONE", set)).isPresent();
- assertThat(LicenseSetFactory.search("TWO", "TWO", set)).isPresent();
-
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"), null);
-
- config = generateConfig(arg1, arg2);
- set = config.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
- assertThat(set).hasSize(2);
- assertThat(LicenseSetFactory.search("ONE", "ONE", set)).isPresent();
- assertThat(LicenseSetFactory.search("TWO", "TWO", set)).isPresent();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void licensesTest() {
- configTest(Arg.CONFIGURATION.find("licenses"));
- }
-
- protected void configTest() {
- configTest(Arg.CONFIGURATION.find("config"));
- }
-
- private void noDefaultsTest(final Option arg) {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(arg, null));
- assertThat(config.getLicenses(LicenseSetFactory.LicenseFilter.ALL)).isEmpty();
- config = generateConfig(ImmutablePair.nullPair());
- assertThat(config.getLicenses(LicenseSetFactory.LicenseFilter.ALL)).isNotEmpty();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void noDefaultsTest() {
- noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("no-default-licenses"));
- }
-
- protected void configurationNoDefaultsTest() {
- noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"));
- }
-
- protected void dryRunTest() {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.DRY_RUN.find("dry-run"), null));
- assertThat(config.isDryRun()).isTrue();
- config = generateConfig(ImmutablePair.nullPair());
- assertThat(config.isDryRun()).isFalse();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- private void editCopyrightTest(final Option option) {
- try {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, new String[]{"MyCopyright"});
- ReportConfiguration config = generateConfig(arg1);
- assertThat(config.getCopyrightMessage()).as("Copyright without --edit-license should not work").isNull();
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.EDIT_ADD.find("edit-license"), null);
- config = generateConfig(arg1, arg2);
- assertThat(config.getCopyrightMessage()).isEqualTo("MyCopyright");
- } catch (IOException e) {
- e.printStackTrace();
- if (e.getCause() != null) {
- fail(e.getMessage() + ": " + e.getCause().getMessage());
- }
- fail(e.getMessage());
- }
- }
-
- protected void copyrightTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("copyright"));
- }
-
- protected void editCopyrightTest() {
- editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"));
- }
-
- private void editLicenseTest(final Option option) {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, null));
- assertThat(config.isAddingLicenses()).isTrue();
- config = generateConfig(ImmutablePair.nullPair());
- assertThat(config.isAddingLicenses()).isFalse();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void addLicenseTest() {
- editLicenseTest(Arg.EDIT_ADD.find("addLicense"));
- }
-
- protected void editLicenseTest() {
- editLicenseTest(Arg.EDIT_ADD.find("edit-license"));
- }
-
- private void overwriteTest(final Option option) {
- Pair<Option, String[]> arg1 = ImmutablePair.of(option, null);
- try {
- ReportConfiguration config = generateConfig(arg1);
- assertThat(config.isAddingLicensesForced()).isFalse();
- Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.EDIT_ADD.find("edit-license"), null);
-
- config = generateConfig(arg1, arg2);
- assertThat(config.isAddingLicensesForced()).isTrue();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void forceTest() {
- overwriteTest(Arg.EDIT_OVERWRITE.find("force"));
- }
-
- protected void editOverwriteTest() {
- overwriteTest(Arg.EDIT_OVERWRITE.find("edit-overwrite"));
- }
-
- protected void logLevelTest() {
- Option option = Arg.LOG_LEVEL.find("log-level");
- String[] args = {null};
- Level logLevel = DefaultLog.getInstance().getLevel();
- try {
- for (Level level : Level.values()) {
- try {
- args[0] = level.name();
- generateConfig(ImmutablePair.of(option, args));
- assertThat(DefaultLog.getInstance().getLevel()).isEqualTo(level);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
- } finally {
- DefaultLog.getInstance().setLevel(logLevel);
- }
- }
-
- private void archiveTest(final Option option) {
- String[] args = {null};
- try {
- for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
- args[0] = proc.name();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getArchiveProcessing()).isEqualTo(proc);
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void outputArchiveTest() {
- archiveTest(Arg.OUTPUT_ARCHIVE.find("output-archive"));
- }
-
- private void listFamilies(final Option option) {
- String[] args = {null};
- for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
- try {
- args[0] = filter.name();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.listFamilies()).isEqualTo(filter);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
- }
-
- protected void listFamiliesTest() {
- listFamilies(Arg.OUTPUT_FAMILIES.find("list-families"));
- }
-
- protected void outputFamiliesTest() {
- listFamilies(Arg.OUTPUT_FAMILIES.find("output-families"));
- }
-
- private void outTest(final Option option) {
- File outFile = new File(baseDir, "outexample-" + option.getLongOpt());
- String[] args = new String[]{outFile.getAbsolutePath()};
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- try (OutputStream os = config.getOutput().get()) {
- os.write("Hello world".getBytes());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(outFile.toPath())))) {
- assertThat(reader.readLine()).isEqualTo("Hello world");
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void outTest() {
- outTest(Arg.OUTPUT_FILE.find("out"));
- }
-
- protected void outputFileTest() {
- outTest(Arg.OUTPUT_FILE.find("output-file"));
- }
-
- private void listLicenses(final Option option) {
- String[] args = {null};
- for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
- try {
- args[0] = filter.name();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.listLicenses()).isEqualTo(filter);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
- }
-
- protected void listLicensesTest() {
- listLicenses(Arg.OUTPUT_LICENSES.find("list-licenses"));
- }
-
- protected void outputLicensesTest() {
- listLicenses(Arg.OUTPUT_LICENSES.find("output-licenses"));
- }
-
- private void standardTest(final Option option) {
- String[] args = {null};
- try {
- for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
- args[0] = proc.name();
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- assertThat(config.getStandardProcessing()).isEqualTo(proc);
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void outputStandardTest() {
- standardTest(Arg.OUTPUT_STANDARD.find("output-standard"));
- }
-
- private void styleSheetTest(final Option option) {
- // copy the dummy stylesheet so that we have a local file for users of the testing jar.
- File file = new File(baseDir, "stylesheet-" + option.getLongOpt());
- try (
- InputStream in = ReporterTest.class.getResourceAsStream("MatcherContainerResource.txt");
- OutputStream out = Files.newOutputStream(file.toPath())) {
- IOUtils.copy(in, out);
- } catch (IOException e) {
- fail("Could not copy MatcherContainerResource.txt: " + e.getMessage());
- }
- // run the test
- String[] args = {null};
- try {
- for (String sheet : new String[]{"plain-rat", "missing-headers", "unapproved-licenses", file.getAbsolutePath()}) {
- args[0] = sheet;
- ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
- try (InputStream expected = StyleSheets.getStyleSheet(sheet).get();
- InputStream actual = config.getStyleSheet().get()) {
- assertThat(IOUtils.contentEquals(expected, actual)).as(() -> String.format("'%s' does not match", sheet)).isTrue();
- }
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void styleSheetTest() {
- styleSheetTest(Arg.OUTPUT_STYLE.find("stylesheet"));
- }
-
- protected void outputStyleTest() {
- styleSheetTest(Arg.OUTPUT_STYLE.find("output-style"));
- }
-
- protected void scanHiddenDirectoriesTest() {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.INCLUDE_STD.find("scan-hidden-directories"), null));
- DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
- assertThat(excluder.matches(mkDocName(".file"))).as(".file").isTrue();
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- protected void xmlTest() {
- try {
- ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.OUTPUT_STYLE.find("xml"), null));
- try (InputStream expected = StyleSheets.getStyleSheet("xml").get();
- InputStream actual = config.getStyleSheet().get()) {
- assertThat(IOUtils.contentEquals(expected, actual)).as("'xml' does not match").isTrue();
- }
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-}
+package org.apache.rat.test; ///*
+// * 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.test;
+//
+//import java.nio.file.FileSystems;
+//import java.nio.file.Path;
+//import org.apache.commons.cli.Option;
+//import org.apache.commons.io.FileUtils;
+//import org.apache.commons.io.IOUtils;
+//import org.apache.commons.lang3.tuple.ImmutablePair;
+//import org.apache.commons.lang3.tuple.Pair;
+//import org.apache.rat.OptionCollectionTest;
+//import org.apache.rat.ReportConfiguration;
+//import org.apache.rat.ReporterTest;
+//import org.apache.rat.commandline.Arg;
+//import org.apache.rat.commandline.StyleSheets;
+//import org.apache.rat.config.exclusion.StandardCollection;
+//import org.apache.rat.document.DocumentNameMatcher;
+//import org.apache.rat.document.DocumentName;
+//import org.apache.rat.license.ILicense;
+//import org.apache.rat.license.ILicenseFamily;
+//import org.apache.rat.license.LicenseSetFactory;
+//import org.apache.rat.report.claim.ClaimStatistic;
+//import org.apache.rat.test.utils.Resources;
+//import org.apache.rat.testhelpers.TextUtils;
+//import org.apache.rat.utils.DefaultLog;
+//import org.apache.rat.utils.Log.Level;
+//
+//import java.io.BufferedReader;
+//import java.io.ByteArrayOutputStream;
+//import java.io.File;
+//import java.io.IOException;
+//import java.io.InputStream;
+//import java.io.InputStreamReader;
+//import java.io.OutputStream;
+//import java.io.PrintStream;
+//import java.nio.file.Files;
+//import java.util.Arrays;
+//import java.util.Collection;
+//import java.util.Collections;
+//import java.util.SortedSet;
+//
+//import static org.apache.rat.commandline.Arg.HELP_LICENSES;
+//import static org.assertj.core.api.Assertions.assertThat;
+//import static org.assertj.core.api.Fail.fail;
+//
+///**
+// * A list of methods that an OptionsProvider in a test case must support.
+// * Use of this interface ensures consistent testing across the UIs. Each method
+// * tests an Option from OptionCollection that must be implemented in the UI.
+// * Each method in this interface tests an Option in {@link org.apache.rat.OptionCollection}.
+// */
+//public abstract class AbstractConfigurationOptionsProvider extends AbstractOptionsProvider {
+//
+// /**
+// * Copy the runtime data to the "target" directory.
+// * @param baseDir the base directory to copy to.
+// * @param targetDir the directory relative to the base directory to copy to.
+// */
+// public static void preserveData(File baseDir, String targetDir) {
+// final Path recordPath = FileSystems.getDefault().getPath("target", targetDir);
+// recordPath.toFile().mkdirs();
+// try {
+// FileUtils.copyDirectory(baseDir, recordPath.toFile());
+// } catch (IOException e) {
+// System.err.format("Unable to copy data from %s to %s%n", baseDir, recordPath);
+// }
+// }
+//
+// /**
+// * Copies the test data to the specified directory.
+// * @param baseDir the directory to copy the {@code /src/test/resources} to.
+// * @return the {@code baseDir} argument.
+// */
+// public static File setup(final File baseDir) {
+// try {
+// final File sourceDir = Resources.getResourceDirectory("OptionTools");
+// FileUtils.copyDirectory(sourceDir, new File(baseDir,"/src/test/resources/OptionTools"));
+// } catch (IOException e) {
+// DefaultLog.getInstance().error("Can not copy 'OptionTools' to " + baseDir, e);
+// }
+// return baseDir;
+// }
+//
+// protected AbstractConfigurationOptionsProvider(final Collection<String> unsupportedArgs, final File baseDir) {
+// super(setup(baseDir));
+// addTest(OptionCollectionTest.OptionTest.namedTest("addLicense", this::addLicenseTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("config", this::configTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("configuration-no-defaults", this::configurationNoDefaultsTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("copyright", this::copyrightTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("counter-min", this::counterMinTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("counter-max", this::counterMaxTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("dir", () -> DefaultLog.getInstance().info("--dir has no valid test")));
+// addTest(OptionCollectionTest.OptionTest.namedTest("dry-run", this::dryRunTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("edit-copyright", this::editCopyrightTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("edit-license", this::editLicenseTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("edit-overwrite", this::editOverwriteTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("exclude", this::excludeTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("exclude-file", this::excludeFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("force", this::forceTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("help", this::helpTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("help-licenses", this::helpLicenses));
+// addTest(OptionCollectionTest.OptionTest.namedTest("include", this::includeTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("includes-file", this::includesFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude", this::inputExcludeTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-file", this::inputExcludeFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-parsed-scm", this::inputExcludeParsedScmTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-std", this::inputExcludeStdTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-exclude-size", this::inputExcludeSizeTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-include", this::inputIncludeTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-include-file", this::inputIncludeFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-include-std", this::inputIncludeStdTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("input-source", this::inputSourceTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("license-families-approved", this::licenseFamiliesApprovedTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("license-families-approved-file", this::licenseFamiliesApprovedFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("license-families-denied", this::licenseFamiliesDeniedTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("license-families-denied-file", this::licenseFamiliesDeniedFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("licenses", this::licensesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("licenses-approved", this::licensesApprovedTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("licenses-approved-file", this::licensesApprovedFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("licenses-denied", this::licensesDeniedTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("licenses-denied-file", this::licensesDeniedFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("list-families", this::listFamiliesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("list-licenses", this::listLicensesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("log-level", this::logLevelTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("no-default-licenses", this::noDefaultsTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("out", this::outTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-archive", this::outputArchiveTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-families", this::outputFamiliesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-file", this::outputFileTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-licenses", this::outputLicensesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-standard", this::outputStandardTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("output-style", this::outputStyleTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("scan-hidden-directories", this::scanHiddenDirectoriesTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("stylesheet", this::styleSheetTest));
+// addTest(OptionCollectionTest.OptionTest.namedTest("xml", this::xmlTest));
+// super.validate(unsupportedArgs);
+// }
+//
+// /** Help test */
+// protected abstract void helpTest();
+//
+// // exclude tests
+// private void execExcludeTest(final Option option, final String[] args) {
+// String[] notExcluded = {"notbaz", "well._afile"};
+// String[] excluded = {"some.foo", "B.bar", "justbaz"};
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// private void excludeFileTest(final Option option) {
+// File outputFile = writeFile("exclude.txt", Arrays.asList(EXCLUDE_ARGS));
+// execExcludeTest(option, new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// protected void excludeFileTest() {
+// excludeFileTest(Arg.EXCLUDE_FILE.find("exclude-file"));
+// }
+//
+// protected void inputExcludeFileTest() {
+// excludeFileTest(Arg.EXCLUDE_FILE.find("input-exclude-file"));
+// }
+//
+// protected void excludeTest() {
+// execExcludeTest(Arg.EXCLUDE.find("exclude"), EXCLUDE_ARGS);
+// }
+//
+// protected void inputExcludeTest() {
+// execExcludeTest(Arg.EXCLUDE.find("input-exclude"), EXCLUDE_ARGS);
+// }
+//
+// protected void inputExcludeStdTest() {
+// Option option = Arg.EXCLUDE_STD.find("input-exclude-std");
+// String[] args = {StandardCollection.MISC.name()};
+// String[] excluded = {"afile~", ".#afile", "%afile%", "._afile"};
+// String[] notExcluded = {"afile~more", "what.#afile", "%afile%withMore", "well._afile"};
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void inputExcludeParsedScmTest() {
+// Option option = Arg.EXCLUDE_PARSE_SCM.find("input-exclude-parsed-scm");
+// String[] args = {"GIT"};
+// String[] lines = {
+// "# somethings",
+// "!thingone", "thing*", System.lineSeparator(),
+// "# some fish",
+// "**/fish", "*_fish",
+// "# some colorful directories",
+// "red/", "blue/*/"};
+// String[] notExcluded = {"thingone", "dir/fish_two", "some/thingone", "blue/fish/dory" };
+// String[] excluded = {"thingtwo", "some/things", "dir/fish", "red/fish", "blue/fish", "some/fish", "another/red_fish"};
+//
+// writeFile(".gitignore", Arrays.asList(lines));
+// File dir = new File(baseDir, "red");
+// dir.mkdirs();
+// dir = new File(baseDir, "blue");
+// dir = new File(dir, "fish");
+// dir.mkdirs();
+//
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// private void inputExcludeSizeTest() {
+// Option option = Arg.EXCLUDE_SIZE.option();
+// String[] args = {"5"};
+// writeFile("Hi.txt", Collections.singletonList("Hi"));
+// writeFile("Hello.txt", Collections.singletonList("Hello"));
+// writeFile("HelloWorld.txt", Collections.singletonList("HelloWorld"));
+//
+// String[] notExcluded = {"Hello.txt", "HelloWorld.txt"};
+// String[] excluded = {"Hi.txt"};
+//
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// // include tests
+// private void execIncludeTest(final Option option, final String[] args) {
+// Option excludeOption = Arg.EXCLUDE.option();
+// String[] notExcluded = {"B.bar", "justbaz", "notbaz"};
+// String[] excluded = {"some.foo"};
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args),
+// ImmutablePair.of(excludeOption, EXCLUDE_ARGS));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// private void includeFileTest(final Option option) {
+// File outputFile = writeFile("include.txt", Arrays.asList(INCLUDE_ARGS));
+// execIncludeTest(option, new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// protected void inputIncludeFileTest() {
+// includeFileTest(Arg.INCLUDE_FILE.find("input-include-file"));
+// }
+//
+// protected void includesFileTest() {
+// includeFileTest(Arg.INCLUDE_FILE.find("includes-file"));
+// }
+//
+// protected void includeTest() {
+// execIncludeTest(Arg.INCLUDE.find("include"), INCLUDE_ARGS);
+// }
+//
+// protected void inputIncludeTest() {
+// execIncludeTest(Arg.INCLUDE.find("input-include"), INCLUDE_ARGS);
+// }
+//
+// protected void inputIncludeStdTest() {
+// ImmutablePair<Option, String[]> excludes = ImmutablePair.of(Arg.EXCLUDE.find("input-exclude"),
+// new String[]{"*~more", "*~"});
+// Option option = Arg.INCLUDE_STD.find("input-include-std");
+// String[] args = {StandardCollection.MISC.name()};
+// String[] excluded = {"afile~more"};
+// String[] notExcluded = {"afile~", ".#afile", "%afile%", "._afile", "what.#afile", "%afile%withMore", "well._afile"};
+// try {
+// ReportConfiguration config = generateConfig(excludes, ImmutablePair.of(option, args));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// for (String fname : excluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isFalse();
+// }
+// for (String fname : notExcluded) {
+// DocumentName docName = mkDocName(fname);
+// assertThat(excluder.matches(docName)).as(() -> dump(option, fname, excluder, docName)).isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void inputSourceTest() {
+// Option option = Arg.SOURCE.find("input-source");
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, new String[]{baseDir.getAbsolutePath()}));
+// assertThat(config.hasSource()).isTrue();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// // LICENSE tests
+// protected void execLicensesApprovedTest(final Option option, String[] args) {
+// Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
+// try {
+// ReportConfiguration config = generateConfig(arg1);
+// SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).contains("one", "two");
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+//
+// Pair<Option, String[]> arg2 = ImmutablePair.of(
+// Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"),
+// null
+// );
+//
+// try {
+// ReportConfiguration config = generateConfig(arg1, arg2);
+// SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).containsExactly("one", "two");
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void helpLicenses() {
+// ByteArrayOutputStream output = new ByteArrayOutputStream();
+// PrintStream origin = System.out;
+// try (PrintStream out = new PrintStream(output)) {
+// System.setOut(out);
+// generateConfig(ImmutablePair.of(HELP_LICENSES.option(), null));
+// } catch (IOException e) {
+// fail(e.getMessage());
+// } finally {
+// System.setOut(origin);
+// }
+// String txt = output.toString();
+// TextUtils.assertContains("====== Licenses ======", txt);
+// TextUtils.assertContains("====== Defined Matchers ======", txt);
+// TextUtils.assertContains("====== Defined Families ======", txt);
+// }
+//
+// protected void licensesApprovedFileTest() {
+// File outputFile = writeFile("licensesApproved.txt", Arrays.asList("one", "two"));
+// execLicensesApprovedTest(Arg.LICENSES_APPROVED_FILE.find("licenses-approved-file"),
+// new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// protected void licensesApprovedTest() {
+// execLicensesApprovedTest(Arg.LICENSES_APPROVED.find("licenses-approved"),
+// new String[]{"one, two"});
+// }
+//
+// private void execLicensesDeniedTest(final Option option, final String[] args) {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getLicenseIds(LicenseSetFactory.LicenseFilter.ALL)).contains("ILLUMOS");
+// SortedSet<String> result = config.getLicenseIds(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).doesNotContain("ILLUMOS");
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void licensesDeniedTest() {
+// execLicensesDeniedTest(Arg.LICENSES_DENIED.find("licenses-denied"), new String[]{"ILLUMOS"});
+// }
+//
+// protected void licensesDeniedFileTest() {
+// File outputFile = writeFile("licensesDenied.txt", Collections.singletonList("ILLUMOS"));
+// execLicensesDeniedTest(Arg.LICENSES_DENIED_FILE.find("licenses-denied-file"),
+// new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// private void execLicenseFamiliesApprovedTest(final Option option, final String[] args) {
+// String catz = ILicenseFamily.makeCategory("catz");
+// Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
+// try {
+// ReportConfiguration config = generateConfig(arg1);
+// SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).contains(catz);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+//
+// Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"), null);
+// try {
+// ReportConfiguration config = generateConfig(arg1, arg2);
+// SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).containsExactly(catz);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void licenseFamiliesApprovedFileTest() {
+// File outputFile = writeFile("familiesApproved.txt", Collections.singletonList("catz"));
+// execLicenseFamiliesApprovedTest(Arg.FAMILIES_APPROVED_FILE.find("license-families-approved-file"),
+// new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// protected void licenseFamiliesApprovedTest() {
+// execLicenseFamiliesApprovedTest(Arg.FAMILIES_APPROVED.find("license-families-approved"),
+// new String[]{"catz"});
+// }
+//
+// private void execLicenseFamiliesDeniedTest(final Option option, final String[] args) {
+// String gpl = ILicenseFamily.makeCategory("GPL");
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getLicenseCategories(LicenseSetFactory.LicenseFilter.ALL)).contains(gpl);
+// SortedSet<String> result = config.getLicenseCategories(LicenseSetFactory.LicenseFilter.APPROVED);
+// assertThat(result).doesNotContain(gpl);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void licenseFamiliesDeniedFileTest() {
+// File outputFile = writeFile("familiesDenied.txt", Collections.singletonList("GPL"));
+// execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED_FILE.find("license-families-denied-file"),
+// new String[]{outputFile.getAbsolutePath()});
+// }
+//
+// protected void licenseFamiliesDeniedTest() {
+// execLicenseFamiliesDeniedTest(Arg.FAMILIES_DENIED.find("license-families-denied"),
+// new String[]{"GPL"});
+// }
+//
+// protected void counterMaxTest() {
+// Option option = Arg.COUNTER_MAX.option();
+// String[] args = {null, null};
+//
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.nullPair());
+// assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
+// args[0] = "Unapproved:-1";
+// args[1] = "ignored:1";
+// config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(Integer.MAX_VALUE);
+// assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
+// args[1] = "unapproved:5";
+// args[0] = "ignored:0";
+// config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(5);
+// assertThat(config.getClaimValidator().getMax(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void counterMinTest() {
+// Option option = Arg.COUNTER_MIN.option();
+// String[] args = {null, null};
+//
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.nullPair());
+// assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(0);
+// args[0] = "Unapproved:1";
+// args[1] = "ignored:1";
+// config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(1);
+// assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.IGNORED)).isEqualTo(1);
+// args[1] = "unapproved:5";
+// args[0] = "ignored:0";
+// config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.UNAPPROVED)).isEqualTo(5);
+// assertThat(config.getClaimValidator().getMin(ClaimStatistic.Counter.IGNORED)).isEqualTo(0);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// private void configTest(final Option option) {
+// String[] args = {"src/test/resources/OptionTools/One.xml", "src/test/resources/OptionTools/Two.xml"};
+// Pair<Option, String[]> arg1 = ImmutablePair.of(option, args);
+// try {
+// ReportConfiguration config = generateConfig(arg1);
+// SortedSet<ILicense> set = config.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
+// assertThat(set).hasSizeGreaterThan(2);
+// assertThat(LicenseSetFactory.search("ONE", "ONE", set)).isPresent();
+// assertThat(LicenseSetFactory.search("TWO", "TWO", set)).isPresent();
+//
+// Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"), null);
+//
+// config = generateConfig(arg1, arg2);
+// set = config.getLicenses(LicenseSetFactory.LicenseFilter.ALL);
+// assertThat(set).hasSize(2);
+// assertThat(LicenseSetFactory.search("ONE", "ONE", set)).isPresent();
+// assertThat(LicenseSetFactory.search("TWO", "TWO", set)).isPresent();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void licensesTest() {
+// configTest(Arg.CONFIGURATION.find("licenses"));
+// }
+//
+// protected void configTest() {
+// configTest(Arg.CONFIGURATION.find("config"));
+// }
+//
+// private void noDefaultsTest(final Option arg) {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(arg, null));
+// assertThat(config.getLicenses(LicenseSetFactory.LicenseFilter.ALL)).isEmpty();
+// config = generateConfig(ImmutablePair.nullPair());
+// assertThat(config.getLicenses(LicenseSetFactory.LicenseFilter.ALL)).isNotEmpty();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void noDefaultsTest() {
+// noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("no-default-licenses"));
+// }
+//
+// protected void configurationNoDefaultsTest() {
+// noDefaultsTest(Arg.CONFIGURATION_NO_DEFAULTS.find("configuration-no-defaults"));
+// }
+//
+// protected void dryRunTest() {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.DRY_RUN.find("dry-run"), null));
+// assertThat(config.isDryRun()).isTrue();
+// config = generateConfig(ImmutablePair.nullPair());
+// assertThat(config.isDryRun()).isFalse();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// private void editCopyrightTest(final Option option) {
+// try {
+// Pair<Option, String[]> arg1 = ImmutablePair.of(option, new String[]{"MyCopyright"});
+// ReportConfiguration config = generateConfig(arg1);
+// assertThat(config.getCopyrightMessage()).as("Copyright without --edit-license should not work").isNull();
+// Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.EDIT_ADD.find("edit-license"), null);
+// config = generateConfig(arg1, arg2);
+// assertThat(config.getCopyrightMessage()).isEqualTo("MyCopyright");
+// } catch (IOException e) {
+// e.printStackTrace();
+// if (e.getCause() != null) {
+// fail(e.getMessage() + ": " + e.getCause().getMessage());
+// }
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void copyrightTest() {
+// editCopyrightTest(Arg.EDIT_COPYRIGHT.find("copyright"));
+// }
+//
+// protected void editCopyrightTest() {
+// editCopyrightTest(Arg.EDIT_COPYRIGHT.find("edit-copyright"));
+// }
+//
+// private void editLicenseTest(final Option option) {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, null));
+// assertThat(config.isAddingLicenses()).isTrue();
+// config = generateConfig(ImmutablePair.nullPair());
+// assertThat(config.isAddingLicenses()).isFalse();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void addLicenseTest() {
+// editLicenseTest(Arg.EDIT_ADD.find("addLicense"));
+// }
+//
+// protected void editLicenseTest() {
+// editLicenseTest(Arg.EDIT_ADD.find("edit-license"));
+// }
+//
+// private void overwriteTest(final Option option) {
+// Pair<Option, String[]> arg1 = ImmutablePair.of(option, null);
+// try {
+// ReportConfiguration config = generateConfig(arg1);
+// assertThat(config.isAddingLicensesForced()).isFalse();
+// Pair<Option, String[]> arg2 = ImmutablePair.of(Arg.EDIT_ADD.find("edit-license"), null);
+//
+// config = generateConfig(arg1, arg2);
+// assertThat(config.isAddingLicensesForced()).isTrue();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void forceTest() {
+// overwriteTest(Arg.EDIT_OVERWRITE.find("force"));
+// }
+//
+// protected void editOverwriteTest() {
+// overwriteTest(Arg.EDIT_OVERWRITE.find("edit-overwrite"));
+// }
+//
+// protected void logLevelTest() {
+// Option option = Arg.LOG_LEVEL.find("log-level");
+// String[] args = {null};
+// Level logLevel = DefaultLog.getInstance().getLevel();
+// try {
+// for (Level level : Level.values()) {
+// try {
+// args[0] = level.name();
+// generateConfig(ImmutablePair.of(option, args));
+// assertThat(DefaultLog.getInstance().getLevel()).isEqualTo(level);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+// } finally {
+// DefaultLog.getInstance().setLevel(logLevel);
+// }
+// }
+//
+// private void archiveTest(final Option option) {
+// String[] args = {null};
+// try {
+// for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
+// args[0] = proc.name();
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getArchiveProcessing()).isEqualTo(proc);
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void outputArchiveTest() {
+// archiveTest(Arg.OUTPUT_ARCHIVE.find("output-archive"));
+// }
+//
+// private void listFamilies(final Option option) {
+// String[] args = {null};
+// for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
+// try {
+// args[0] = filter.name();
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.listFamilies()).isEqualTo(filter);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+// }
+//
+// protected void listFamiliesTest() {
+// listFamilies(Arg.OUTPUT_FAMILIES.find("list-families"));
+// }
+//
+// protected void outputFamiliesTest() {
+// listFamilies(Arg.OUTPUT_FAMILIES.find("output-families"));
+// }
+//
+// private void outTest(final Option option) {
+// File outFile = new File(baseDir, "outexample-" + option.getLongOpt());
+// String[] args = new String[]{outFile.getAbsolutePath()};
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// try (OutputStream os = config.getOutput().get()) {
+// os.write("Hello world".getBytes());
+// } catch (IOException e) {
+// throw new RuntimeException(e);
+// }
+// try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(outFile.toPath())))) {
+// assertThat(reader.readLine()).isEqualTo("Hello world");
+// } catch (IOException e) {
+// throw new RuntimeException(e);
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void outTest() {
+// outTest(Arg.OUTPUT_FILE.find("out"));
+// }
+//
+// protected void outputFileTest() {
+// outTest(Arg.OUTPUT_FILE.find("output-file"));
+// }
+//
+// private void listLicenses(final Option option) {
+// String[] args = {null};
+// for (LicenseSetFactory.LicenseFilter filter : LicenseSetFactory.LicenseFilter.values()) {
+// try {
+// args[0] = filter.name();
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.listLicenses()).isEqualTo(filter);
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+// }
+//
+// protected void listLicensesTest() {
+// listLicenses(Arg.OUTPUT_LICENSES.find("list-licenses"));
+// }
+//
+// protected void outputLicensesTest() {
+// listLicenses(Arg.OUTPUT_LICENSES.find("output-licenses"));
+// }
+//
+// private void standardTest(final Option option) {
+// String[] args = {null};
+// try {
+// for (ReportConfiguration.Processing proc : ReportConfiguration.Processing.values()) {
+// args[0] = proc.name();
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// assertThat(config.getStandardProcessing()).isEqualTo(proc);
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void outputStandardTest() {
+// standardTest(Arg.OUTPUT_STANDARD.find("output-standard"));
+// }
+//
+// private void styleSheetTest(final Option option) {
+// // copy the dummy stylesheet so that we have a local file for users of the testing jar.
+// File file = new File(baseDir, "stylesheet-" + option.getLongOpt());
+// try (
+// InputStream in = ReporterTest.class.getResourceAsStream("MatcherContainerResource.txt");
+// OutputStream out = Files.newOutputStream(file.toPath())) {
+// IOUtils.copy(in, out);
+// } catch (IOException e) {
+// fail("Could not copy MatcherContainerResource.txt: " + e.getMessage());
+// }
+// // run the test
+// String[] args = {null};
+// try {
+// for (String sheet : new String[]{"plain-rat", "missing-headers", "unapproved-licenses", file.getAbsolutePath()}) {
+// args[0] = sheet;
+// ReportConfiguration config = generateConfig(ImmutablePair.of(option, args));
+// try (InputStream expected = StyleSheets.getStyleSheet(sheet).get();
+// InputStream actual = config.getStyleSheet().get()) {
+// assertThat(IOUtils.contentEquals(expected, actual)).as(() -> String.format("'%s' does not match", sheet)).isTrue();
+// }
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void styleSheetTest() {
+// styleSheetTest(Arg.OUTPUT_STYLE.find("stylesheet"));
+// }
+//
+// protected void outputStyleTest() {
+// styleSheetTest(Arg.OUTPUT_STYLE.find("output-style"));
+// }
+//
+// protected void scanHiddenDirectoriesTest() {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.INCLUDE_STD.find("scan-hidden-directories"), null));
+// DocumentNameMatcher excluder = config.getDocumentExcluder(baseName());
+// assertThat(excluder.matches(mkDocName(".file"))).as(".file").isTrue();
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//
+// protected void xmlTest() {
+// try {
+// ReportConfiguration config = generateConfig(ImmutablePair.of(Arg.OUTPUT_STYLE.find("xml"), null));
+// try (InputStream expected = StyleSheets.getStyleSheet("xml").get();
+// InputStream actual = config.getStyleSheet().get()) {
+// assertThat(IOUtils.contentEquals(expected, actual)).as("'xml' does not match").isTrue();
+// }
+// } catch (IOException e) {
+// fail(e.getMessage());
+// }
+// }
+//}
diff --git a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java
index dac4b415..fab45575 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/test/AbstractOptionsProvider.java
@@ -1,217 +1,217 @@
-/*
- * 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.test;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.FileSystems;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.stream.Stream;
-import org.apache.commons.cli.Option;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.rat.OptionCollectionTest;
-import org.apache.rat.ReportConfiguration;
-import org.apache.rat.commandline.Arg;
-import org.apache.rat.document.DocumentName;
-import org.apache.rat.document.DocumentNameMatcher;
-import org.apache.rat.document.DocumentNameMatcherTest;
-import org.junit.jupiter.api.extension.ExtensionContext;
-import org.junit.jupiter.params.provider.Arguments;
-import org.junit.jupiter.params.provider.ArgumentsProvider;
-
-import static org.assertj.core.api.Fail.fail;
-
-/**
- * A list of methods that an OptionsProvider in a test case must support.
- * Use of this interface ensures consistent testing across the UIs. Each method
- * tests an Option from OptionCollection that must be implemented in the UI.
- * Each method in this interface tests an Option in {@link org.apache.rat.OptionCollection}.
- */
-public abstract class AbstractOptionsProvider implements ArgumentsProvider {
- /**
- * A map of test Options to tests.
- */
- protected final Map<String, OptionCollectionTest.OptionTest> testMap = new TreeMap<>();
- /** The list of exclude args */
- protected static final String[] EXCLUDE_ARGS = {"*.foo", "%regex[[A-Z]\\.bar]", "justbaz"};
- /** the list of include args */
- protected static final String[] INCLUDE_ARGS = {"B.bar", "justbaz"};
- /**
- * The directory to place test data in.
- */
- protected final File baseDir;
-
- /**
- * Copy the runtime data to the "target" directory.
- * @param baseDir the base directory to copy to.
- * @param targetDir the directory relative to the base directory to copy to.
- */
- public static void preserveData(File baseDir, String targetDir) {
- final Path recordPath = FileSystems.getDefault().getPath("target", targetDir);
- recordPath.toFile().mkdirs();
- try {
- FileUtils.copyDirectory(baseDir, recordPath.toFile());
- } catch (IOException e) {
- System.err.format("Unable to copy data from %s to %s%n", baseDir, recordPath);
- }
- }
-
- protected void processTestFunctionAnnotations() {
- testMap.putAll(OptionCollectionTest.processTestFunctionAnnotations(this));
- }
-
- protected void addTest(OptionCollectionTest.OptionTest test) {
- testMap.put(test.toString(), test);
- }
-
- /**
- * Gets the document name based on the baseDir.
- * @return The document name based on the baseDir.
- */
- protected DocumentName baseName() {
- return DocumentName.builder(baseDir).build();
- }
-
- protected AbstractOptionsProvider(final File baseDir) {
- this.baseDir = baseDir;
- }
-
- protected void validate(final Collection<String> unsupportedArgs) {
- unsupportedArgs.forEach(testMap::remove);
- verifyAllMethodsDefinedAndNeeded(unsupportedArgs);
- }
-
- private void verifyAllMethodsDefinedAndNeeded(final Collection<String> unsupportedArgs) {
- // verify all options have functions.
- final List<String> argNames = new ArrayList<>();
- Arg.getOptions().getOptions().forEach(o -> {
- if (o.getLongOpt() != null) {
- argNames.add(o.getLongOpt());
- }
- });
- argNames.removeAll(unsupportedArgs);
- argNames.removeAll(testMap.keySet());
- if (!argNames.isEmpty()) {
- fail("Missing methods for: " + String.join(", ", argNames));
- }
-
- // verify all functions have options.
- argNames.clear();
- argNames.addAll(testMap.keySet());
- argNames.remove("help");
- Arg.getOptions().getOptions().forEach(o -> {
- if (o.getLongOpt() != null) {
- argNames.remove(o.getLongOpt());
- }
- });
- if (!argNames.isEmpty()) {
- fail("Extra methods defined: " + String.join(", ", argNames));
- }
- unsupportedArgs.forEach(testMap::remove);
- }
-
- @SafeVarargs
- protected final ReportConfiguration generateConfig(final Pair<Option, String[]>... args) throws IOException {
- List<Pair<Option, String[]>> options = Arrays.asList(args);
- return generateConfig(options);
- }
-
- /**
- * Create the report configuration from the argument pairs.
- * There must be at least one arg. It may be {@code ImmutablePair.nullPair()}.
- *
- * @param args Pairs comprising the argument option and the values for the option.
- * @return The generated ReportConfiguration.
- * @throws IOException on error.
- */
- protected abstract ReportConfiguration generateConfig(final List<Pair<Option, String[]>> args) throws IOException;
-
- /**
- * Converts each {@code Pair<Option, String[]>} into the option string and its arguments.
- * @param args the argument paris to process.
- * @return an array of arguments for the processing.
- */
- public static String[] extractArgs(List<Pair<Option, String[]>> args) {
- List<String> sArgs = new ArrayList<>();
- for (Pair<Option, String[]> pair : args) {
- if (pair.getKey() != null) {
- sArgs.add("--" + pair.getKey().getLongOpt());
- String[] oArgs = pair.getValue();
- if (oArgs != null) {
- Collections.addAll(sArgs, oArgs);
- }
- }
- }
- return sArgs.toArray(new String[0]);
- }
-
- protected File writeFile(final String name, final Iterable<String> lines) {
- return org.apache.rat.testhelpers.FileUtils.writeFile(baseDir, name, lines);
- }
-
- final protected DocumentName mkDocName(final String name) {
- return DocumentName.builder(new File(baseDir, name)).build();
- }
-
- /** Help test */
- protected abstract void helpTest();
-
- /** Display the option and value under test */
- final protected String displayArgAndName(final Option option, final String fname) {
- return String.format("%s %s", option.getLongOpt(), fname);
- }
-
- final protected String dump(final DocumentNameMatcher nameMatcher, final DocumentName name) {
- StringBuilder sb = new StringBuilder();
- nameMatcher.decompose(name).forEach(s -> sb.append(s).append("\n"));
- return sb.toString();
- }
-
- final protected String dump(final Option option, final String fname, final DocumentNameMatcher matcher, final DocumentName name) {
- return String.format("Argument and Name: %s%nMatcher decomposition:%n%s", displayArgAndName(option, fname),
- DocumentNameMatcherTest.processDecompose(matcher, name));
- }
-
- @Override
- public Stream<? extends Arguments> provideArguments(final ExtensionContext context) {
- List<Arguments> lst = new ArrayList<>();
- List<String> missingTests = new ArrayList<>();
-
- for (String key : OptionsList.getKeys()) {
- OptionCollectionTest.OptionTest test = testMap.get(key);
- if (test == null) {
- missingTests.add(key);
- } else {
- lst.add(Arguments.of(key, test));
- }
- }
- if (!missingTests.isEmpty()) {
- System.out.println("The following tests are excluded: '" + String.join("', '", missingTests) + "'");
- }
- return lst.stream();
- }
-}
+package org.apache.rat.test; ///*
+// * 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.test;
+//
+//import java.io.File;
+//import java.io.IOException;
+//import java.nio.file.FileSystems;
+//import java.nio.file.Path;
+//import java.util.ArrayList;
+//import java.util.Arrays;
+//import java.util.Collection;
+//import java.util.Collections;
+//import java.util.List;
+//import java.util.Map;
+//import java.util.TreeMap;
+//import java.util.stream.Stream;
+//import org.apache.commons.cli.Option;
+//import org.apache.commons.io.FileUtils;
+//import org.apache.commons.lang3.tuple.Pair;
+//import org.apache.rat.OptionCollectionTest;
+//import org.apache.rat.ReportConfiguration;
+//import org.apache.rat.commandline.Arg;
+//import org.apache.rat.document.DocumentName;
+//import org.apache.rat.document.DocumentNameMatcher;
+//import org.apache.rat.document.DocumentNameMatcherTest;
+//import org.junit.jupiter.api.extension.ExtensionContext;
+//import org.junit.jupiter.params.provider.Arguments;
+//import org.junit.jupiter.params.provider.ArgumentsProvider;
+//
+//import static org.assertj.core.api.Fail.fail;
+//
+///**
+// * A list of methods that an OptionsProvider in a test case must support.
+// * Use of this interface ensures consistent testing across the UIs. Each method
+// * tests an Option from OptionCollection that must be implemented in the UI.
+// * Each method in this interface tests an Option in {@link org.apache.rat.OptionCollection}.
+// */
+//public abstract class AbstractOptionsProvider implements ArgumentsProvider {
+// /**
+// * A map of test Options to tests.
+// */
+// protected final Map<String, OptionCollectionTest.OptionTest> testMap = new TreeMap<>();
+// /** The list of exclude args */
+// protected static final String[] EXCLUDE_ARGS = {"*.foo", "%regex[[A-Z]\\.bar]", "justbaz"};
+// /** the list of include args */
+// protected static final String[] INCLUDE_ARGS = {"B.bar", "justbaz"};
+// /**
+// * The directory to place test data in.
+// */
+// protected final File baseDir;
+//
+// /**
+// * Copy the runtime data to the "target" directory.
+// * @param baseDir the base directory to copy to.
+// * @param targetDir the directory relative to the base directory to copy to.
+// */
+// public static void preserveData(File baseDir, String targetDir) {
+// final Path recordPath = FileSystems.getDefault().getPath("target", targetDir);
+// recordPath.toFile().mkdirs();
+// try {
+// FileUtils.copyDirectory(baseDir, recordPath.toFile());
+// } catch (IOException e) {
+// System.err.format("Unable to copy data from %s to %s%n", baseDir, recordPath);
+// }
+// }
+//
+// protected void processTestFunctionAnnotations() {
+// testMap.putAll(OptionCollectionTest.processTestFunctionAnnotations(this));
+// }
+//
+// protected void addTest(OptionCollectionTest.OptionTest test) {
+// testMap.put(test.toString(), test);
+// }
+//
+// /**
+// * Gets the document name based on the baseDir.
+// * @return The document name based on the baseDir.
+// */
+// protected DocumentName baseName() {
+// return DocumentName.builder(baseDir).build();
+// }
+//
+// protected AbstractOptionsProvider(final File baseDir) {
+// this.baseDir = baseDir;
+// }
+//
+// protected void validate(final Collection<String> unsupportedArgs) {
+// unsupportedArgs.forEach(testMap::remove);
+// verifyAllMethodsDefinedAndNeeded(unsupportedArgs);
+// }
+//
+// private void verifyAllMethodsDefinedAndNeeded(final Collection<String> unsupportedArgs) {
+// // verify all options have functions.
+// final List<String> argNames = new ArrayList<>();
+// Arg.getOptions().getOptions().forEach(o -> {
+// if (o.getLongOpt() != null) {
+// argNames.add(o.getLongOpt());
+// }
+// });
+// argNames.removeAll(unsupportedArgs);
+// argNames.removeAll(testMap.keySet());
+// if (!argNames.isEmpty()) {
+// fail("Missing methods for: " + String.join(", ", argNames));
+// }
+//
+// // verify all functions have options.
+// argNames.clear();
+// argNames.addAll(testMap.keySet());
+// argNames.remove("help");
+// Arg.getOptions().getOptions().forEach(o -> {
+// if (o.getLongOpt() != null) {
... 17860 lines suppressed ...