diff --git a/Test/org/spdx/licenselistpublisher/LicenseXmlTesterTest.java b/Test/org/spdx/licenselistpublisher/LicenseXmlTesterTest.java new file mode 100644 index 0000000..58db1fc --- /dev/null +++ b/Test/org/spdx/licenselistpublisher/LicenseXmlTesterTest.java @@ -0,0 +1,57 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright (c) Source Auditor Inc. 2024. + * + */ + +package org.spdx.licenselistpublisher; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.spdx.library.SpdxModelFactory; + +import java.io.File; +import java.util.List; + +public class LicenseXmlTesterTest { + + static final String SOURCE_XML = "TestFiles" + File.separator + "BSD-3-Clause.xml"; + static final String GOOD_TEST_DIR = "TestFiles" + File.separator + "good-tests"; + static final String BAD_TEST_DIR = "TestFiles" + File.separator + "bad-tests"; + static final String COMPARE_TEXT = GOOD_TEST_DIR + File.separator + "BSD-3-Clause" + File.separator + + "license" + File.separator + "good" + File.separator + "original.txt"; + static final String BAD_COMPARE_TEXT = GOOD_TEST_DIR + File.separator + "BSD-3-Clause" + File.separator + + "license" + File.separator + "bad" + File.separator + "must-not-reproduce.txt"; + + @Before + public void setUp() { + SpdxModelFactory.init(); + } + + @Test + public void testSingleFile() throws Exception { + List result = LicenseXmlTester.testLicenseXml(new File(SOURCE_XML), new File(COMPARE_TEXT), null); + Assert.assertTrue(result.isEmpty()); + } + + @Test + public void testSingleBadFile() throws Exception { + List result = LicenseXmlTester.testLicenseXml(new File(SOURCE_XML), new File(BAD_COMPARE_TEXT), null); + Assert.assertFalse(result.isEmpty()); + } + + @Test + public void testFullTest() throws Exception { + List result = LicenseXmlTester.testLicenseXml(new File(SOURCE_XML), new File(COMPARE_TEXT), + new File(GOOD_TEST_DIR)); + Assert.assertTrue(result.isEmpty()); + } + + @Test + public void testBadFullTest() throws Exception { + List result = LicenseXmlTester.testLicenseXml(new File(SOURCE_XML), new File(COMPARE_TEXT), + new File(BAD_TEST_DIR)); + Assert.assertFalse(result.isEmpty()); + } +} \ No newline at end of file diff --git a/TestFiles/BSD-3-Clause.xml b/TestFiles/BSD-3-Clause.xml new file mode 100644 index 0000000..5480818 --- /dev/null +++ b/TestFiles/BSD-3-Clause.xml @@ -0,0 +1,48 @@ + + + + + https://opensource.org/licenses/BSD-3-Clause + https://www.eclipse.org/org/documents/edl-v10.php + + Note for matching purposes, this license contains a number of equivalent variations, particularly in the third clause. See the XML file for more details. Also note that the Eclipse Distribution License - v 1.0 (EDL 1.0) is a match to BSD-3-Clause, even though it uses a different name. + + +

Copyright (c) <year> <owner>.

+
+

Redistribution and use in source and binary forms, + with or without modification, are permitted provided + that the following conditions are met:

+ + + 1. + Redistributions of source code must retain the above copyright notice, this list of conditions + and the following disclaimer. + + + 2. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions + and the following disclaimer in the documentation and/or other materials provided with the + distribution. + + + 3. + + Neither the name of the copyright holder nor the names of its contributors may + be used to endorse or promote products derived from this + software without specific prior written permission. + + +

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+
+
+
diff --git a/TestFiles/bad-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt b/TestFiles/bad-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt new file mode 100644 index 0000000..4ad1d70 --- /dev/null +++ b/TestFiles/bad-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must not reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/bad-tests/BSD-3-Clause/license/good/changed-copyright.txt b/TestFiles/bad-tests/BSD-3-Clause/license/good/changed-copyright.txt new file mode 100644 index 0000000..b52e7e9 --- /dev/null +++ b/TestFiles/bad-tests/BSD-3-Clause/license/good/changed-copyright.txt @@ -0,0 +1,11 @@ +Copyright (c) 2024 Source Auditor Inc. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/bad-tests/BSD-3-Clause/license/good/must-not-reproduce.txt b/TestFiles/bad-tests/BSD-3-Clause/license/good/must-not-reproduce.txt new file mode 100644 index 0000000..4ad1d70 --- /dev/null +++ b/TestFiles/bad-tests/BSD-3-Clause/license/good/must-not-reproduce.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must not reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/bad-tests/BSD-3-Clause/license/good/original.txt b/TestFiles/bad-tests/BSD-3-Clause/license/good/original.txt new file mode 100644 index 0000000..ea890af --- /dev/null +++ b/TestFiles/bad-tests/BSD-3-Clause/license/good/original.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/good-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt b/TestFiles/good-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt new file mode 100644 index 0000000..4ad1d70 --- /dev/null +++ b/TestFiles/good-tests/BSD-3-Clause/license/bad/must-not-reproduce.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must not reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/good-tests/BSD-3-Clause/license/good/changed-copyright.txt b/TestFiles/good-tests/BSD-3-Clause/license/good/changed-copyright.txt new file mode 100644 index 0000000..b52e7e9 --- /dev/null +++ b/TestFiles/good-tests/BSD-3-Clause/license/good/changed-copyright.txt @@ -0,0 +1,11 @@ +Copyright (c) 2024 Source Auditor Inc. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/TestFiles/good-tests/BSD-3-Clause/license/good/original.txt b/TestFiles/good-tests/BSD-3-Clause/license/good/original.txt new file mode 100644 index 0000000..ea890af --- /dev/null +++ b/TestFiles/good-tests/BSD-3-Clause/license/good/original.txt @@ -0,0 +1,11 @@ +Copyright (c) . + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java index 472eb88..77c8782 100644 --- a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java +++ b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java @@ -47,23 +47,11 @@ import org.spdx.library.model.v2.license.SpdxListedLicenseException; import org.spdx.licenseTemplate.InvalidLicenseTemplateException; import org.spdx.licenseTemplate.LicenseTextHelper; +import org.spdx.licenselistpublisher.licensegenerator.*; import org.spdx.licensexml.XmlLicenseProviderSingleFile; import org.spdx.licensexml.XmlLicenseProviderWithCrossRefDetails; import org.spdx.utility.compare.LicenseCompareHelper; import org.spdx.utility.compare.SpdxCompareException; -import org.spdx.licenselistpublisher.licensegenerator.FsfLicenseDataParser; -import org.spdx.licenselistpublisher.licensegenerator.ILicenseFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.ILicenseTester; -import org.spdx.licenselistpublisher.licensegenerator.LicenseHtmlFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseJsonFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseMarkdownFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseRdfFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseRdfaFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseTemplateFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseTextFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.LicenseV3JsonLdFormatWriter; -import org.spdx.licenselistpublisher.licensegenerator.SimpleLicenseTester; -import org.spdx.licenselistpublisher.licensegenerator.SpdxWebsiteFormatWriter; import au.com.bytecode.opencsv.CSVReader; @@ -106,7 +94,7 @@ public class LicenseRDFAGenerator { INVALID_TEXT_CHARS.add('\uFFFD'); } static int MIN_ARGS = 2; - static int MAX_ARGS = 6; + static int MAX_ARGS = 7; static final int ERROR_STATUS = 1; static final int WARNING_STATUS = 64; @@ -129,7 +117,13 @@ public class LicenseRDFAGenerator { private static final String ENV_USE_SYSTEM_TEST = "USE_TEST_FOR_TEXT"; /** - * @param args Arg 0 is either a license XML file or a directory of licenses in XML format, arg 1 is the directory for the output html files + * @param args Arg 0 is either a license XML file or a directory of licenses in XML format, + * arg 1 is the directory for the output html files + * arg 2 is the optional license list version + * arg 3 is the optional release date + * arg 4 is the optional directory of original license texts with file names {license-or-excpetion-id}.txt + * arg 5 is the optional file containing a list of warnings to ignore + * arg 6 is the optional directory of positive and negative tests for the licenses with the pattern {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt */ public static void main(String[] args) { SpdxModelFactory.init(); @@ -202,6 +196,21 @@ public static void main(String[] args) { } } } + + File fullTestDir = null; + if (args.length > 6) { + fullTestDir = new File(args[6]); + if (!fullTestDir.exists()) { + System.out.println("Full license test directory "+testFileDir.getName()+" does not exist"); + usage(); + System.exit(ERROR_STATUS); + } + if (!fullTestDir.isDirectory()) { + System.out.println("Full license test directory "+testFileDir.getName()+" is not a directory"); + usage(); + System.exit(ERROR_STATUS); + } + } boolean useTestText = true; // default to true try { @@ -214,7 +223,7 @@ public static void main(String[] args) { } try { - List warnings = generateLicenseData(licenseXmlFileOrDir, dir, version, releaseDate, testFileDir, useTestText); + List warnings = generateLicenseData(licenseXmlFileOrDir, dir, version, releaseDate, testFileDir, useTestText, fullTestDir); if (warnings != null && warnings.size() > 0) { int numUnexpectedWarnings = warnings.size(); for (String warning:warnings) { @@ -247,11 +256,14 @@ public static void main(String[] args) { * @param releaseDateUnformated Release data string for the license * @param testFileDir Directory of license text to test the generated licenses against * @param useTestText use the text file from the testFileDir for the verbatim text rather than the text from the XML document - * @return warnings - * @throws LicenseGeneratorException + * @param fullTestDir Directory for testing license texts with the pattern {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt + * @return warnings list of warnings + * @throws LicenseGeneratorException on errors */ public static List generateLicenseData(File licenseXml, File dir, - String version, String releaseDateUnformated, File testFileDir, boolean useTestText) throws LicenseGeneratorException { + String version, String releaseDateUnformated, + File testFileDir, boolean useTestText, + File fullTestDir) throws LicenseGeneratorException { String releaseDate = convertDateFormat(releaseDateUnformated); List warnings = new ArrayList<>(); List writers = new ArrayList<>(); @@ -336,7 +348,11 @@ public static List generateLicenseData(File licenseXml, File dir, writers.add(new LicenseV3JsonLdFormatWriter(version, releaseDate, v3JsonLd)); ILicenseTester tester = null; if (testFileDir != null) { - tester = new SimpleLicenseTester(testFileDir); + if (fullTestDir != null) { + tester = new CombinedLicenseTester(testFileDir, fullTestDir); + } else { + tester = new SimpleLicenseTester(testFileDir); + } } System.out.print("Processing License List"); Set licenseIds = writeLicenseList(version, releaseDate, licenseProvider, warnings, @@ -398,8 +414,6 @@ private static String convertDateFormat(String unformattedDate) throws LicenseGe * @param licenseIds license IDs * @param useTestText use the text file from the testFileDir for the verbatim text rather than the text from the XML document * @throws IOException - * @throws SpreadsheetException - * @throws LicenseRestrictionException * @throws LicenseGeneratorException * @throws InvalidLicenseTemplateException * @throws InvalidSPDXAnalysisException diff --git a/src/org/spdx/licenselistpublisher/LicenseXmlTester.java b/src/org/spdx/licenselistpublisher/LicenseXmlTester.java index 0a8ec03..eaad931 100644 --- a/src/org/spdx/licenselistpublisher/LicenseXmlTester.java +++ b/src/org/spdx/licenselistpublisher/LicenseXmlTester.java @@ -1,14 +1,14 @@ /** * SpdxLicenseIdentifier: Apache-2.0 - * + *

* Copyright (c) 2019 Source Auditor Inc. - * + *

* Licensed 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. @@ -20,32 +20,31 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.Charset; -import java.nio.file.Files; import java.text.DateFormat; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.stream.Stream; +import java.util.*; import org.spdx.core.IModelCopyManager; import org.spdx.core.InvalidSPDXAnalysisException; import org.spdx.library.ModelCopyManager; import org.spdx.library.model.v3_0_1.SpdxConstantsV3; +import org.spdx.licenselistpublisher.licensegenerator.LicenseTester; +import org.spdx.licenselistpublisher.licensegenerator.SimpleLicenseTester; import org.spdx.licensexml.LicenseXmlDocument; import org.spdx.licensexml.LicenseXmlException; import org.spdx.licensexml.XmlLicenseProvider; import org.spdx.storage.IModelStore; import org.spdx.storage.simple.InMemSpdxStore; -import org.spdx.utility.compare.CompareTemplateOutputHandler.DifferenceDescription; -import org.spdx.utility.compare.LicenseCompareHelper; import org.spdx.utility.compare.SpdxCompareException; +import javax.annotation.Nullable; + /** * Tests a license XML file against license text expected to match * TestLicenseXML licenseXmlFile textFile * licenseXmlFile XML - file - * textFile - Text file which should match the the license text for the licenseXmlFile + * textFile - Text file which should match the license text for the licenseXmlFile + * testDirectory - optional directory of text files to test with the pattern {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt * * @author Gary O'Neall * @@ -53,12 +52,12 @@ public class LicenseXmlTester { static int MIN_ARGS = 2; - static int MAX_ARGS = 2; + static int MAX_ARGS = 3; static final int ERROR_STATUS = 1; static final int WARNING_STATUS = 64; /** - * @param args + * @param args arguments - see usage for documentation */ public static void main(String[] args) { if (args == null || args.length < MIN_ARGS || args.length > MAX_ARGS) { @@ -88,30 +87,33 @@ public static void main(String[] args) { usage(); System.exit(ERROR_STATUS); } - try { - IModelStore spdxV2ModelStore = new InMemSpdxStore(); - IModelStore spdxV3ModelStore = new InMemSpdxStore(); - IModelCopyManager copyManager = new ModelCopyManager(); - DateFormat format = new SimpleDateFormat(SpdxConstantsV3.SPDX_DATE_FORMAT); - String now = format.format(new Date()); - LicenseXmlDocument licDoc = new LicenseXmlDocument(licenseXmlFile, spdxV2ModelStore, spdxV3ModelStore, - copyManager, XmlLicenseProvider.createCreationInfo(spdxV3ModelStore, copyManager, now, "3.25.0" )); - List licenses = licDoc.getListedLicenses(); - if (licenses.size() == 0) { - System.out.println("Empty license XML file - no licenses found"); + + File testDirectory = null; + if (args.length > 2) { + testDirectory = new File(args[2]); + if (!testDirectory.exists()) { + System.out.println("Test directory "+testDirectory.getName()+" does not exist"); + usage(); System.exit(ERROR_STATUS); } - if (licenses.size() > 1) { - System.out.println("More than one licenses found"); + if (!testDirectory.isDirectory()) { + System.out.println("Test directory "+testDirectory.getName()+" is not a directory"); + usage(); System.exit(ERROR_STATUS); } - String compareText = readText(testFile); - DifferenceDescription diff = LicenseCompareHelper.isTextStandardLicense(licenses.get(0).getV3ListedLicense(), compareText); - if (diff.isDifferenceFound()) { - System.out.println("Difference found comparing to test file: "+diff.getDifferenceMessage()); - System.exit(ERROR_STATUS); + } + try { + List result = testLicenseXml(licenseXmlFile, testFile, testDirectory); + if (result.isEmpty()) { + System.out.println("License passed"); + } else { + System.out.println("The following error(s) were found:"); + for (String error:result) { + System.out.print("\t"); + System.out.println(error); + } + System.exit(WARNING_STATUS); } - System.out.println("License "+licenses.get(0).getV3ListedLicense().getName()+" passed"); } catch (LicenseXmlException e) { System.out.println("Invalid license XML document: "+e.getMessage()); System.exit(ERROR_STATUS); @@ -122,21 +124,42 @@ public static void main(String[] args) { System.out.println("I/O error reading test file: "+e.getMessage()); System.exit(ERROR_STATUS); } catch (SpdxCompareException e) { - System.out.println("Invalid license template: "+e.getMessage()); + System.out.println("Compare error: "+e.getMessage()); System.exit(ERROR_STATUS); - } - } + } + } - private static String readText(File f) throws IOException { - Charset utf8 = Charset.forName("UTF-8"); - StringBuilder text = new StringBuilder(); - try(Stream fileLines = Files.lines(f.toPath(), utf8)) { - fileLines.forEach(line -> { - text.append(line); - text.append("\n"); - }); + /** + * test a license XML against a single file and optionally a directory of test files + * @param licenseXmlFile file in LicenseXML Format + * @param testFile single file to compare + * @param testDirectory optional directory to test against with the pattern {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt + * @return list of errors when comparing - if empty, no errors occurs + * @throws InvalidSPDXAnalysisException on SPDX parsing errors + * @throws LicenseXmlException on errors parsing the LicenseXML + * @throws IOException on errors reading either the XML or test files + */ + public static List testLicenseXml(File licenseXmlFile, File testFile, @Nullable File testDirectory) throws InvalidSPDXAnalysisException, LicenseXmlException, IOException, SpdxCompareException { + IModelStore spdxV2ModelStore = new InMemSpdxStore(); + IModelStore spdxV3ModelStore = new InMemSpdxStore(); + IModelCopyManager copyManager = new ModelCopyManager(); + DateFormat format = new SimpleDateFormat(SpdxConstantsV3.SPDX_DATE_FORMAT); + String now = format.format(new Date()); + LicenseXmlDocument licDoc = new LicenseXmlDocument(licenseXmlFile, spdxV2ModelStore, spdxV3ModelStore, + copyManager, XmlLicenseProvider.createCreationInfo(spdxV3ModelStore, copyManager, now, "3.25.0" )); + List licenses = licDoc.getListedLicenses(); + if (licenses.isEmpty()) { + return List.of("Empty license XML file - no licenses found"); + } + if (licenses.size() > 1) { + return List.of("More than one licenses found"); + } + List retval = SimpleLicenseTester.testLicense(licenses.get(0).getV2ListedLicense(), testFile); + if (Objects.nonNull(testDirectory)) { + LicenseTester tester = new LicenseTester(testDirectory); + retval.addAll(tester.testLicense(licenses.get(0))); } - return text.toString(); + return retval; } private static void usage() { @@ -144,5 +167,6 @@ private static void usage() { System.out.println("TestLicenseXML licenseXmlFile textFile"); System.out.println(" licenseXmlFile XML - file to test"); System.out.println(" textFile - Text file which should match the the license text for the licenseXmlFile"); + System.out.println(" testDirectory - Optional directory of test files in the form {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt"); } } diff --git a/src/org/spdx/licenselistpublisher/licensegenerator/CombinedLicenseTester.java b/src/org/spdx/licenselistpublisher/licensegenerator/CombinedLicenseTester.java new file mode 100644 index 0000000..cd4eb8e --- /dev/null +++ b/src/org/spdx/licenselistpublisher/licensegenerator/CombinedLicenseTester.java @@ -0,0 +1,62 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright (c) Source Auditor Inc. 2024. + * + */ + +package org.spdx.licenselistpublisher.licensegenerator; + +import org.spdx.core.InvalidSPDXAnalysisException; +import org.spdx.licenselistpublisher.ListedExceptionContainer; +import org.spdx.licenselistpublisher.ListedLicenseContainer; +import org.spdx.utility.compare.SpdxCompareException; + +import javax.annotation.Nullable; +import java.io.File; +import java.io.IOException; +import java.util.List; + +/** + * Combines a simple license tester and the standard license tester into a single tester + */ +public class CombinedLicenseTester implements ILicenseTester { + + private final ILicenseTester simpleLicenseTester; + private final ILicenseTester licenseTester; + + /** + * Create a license tester that will test both simple licenses and standard licenses + * @param simpleLicenseTestDir Directory containing license texts in the format [license-id].txt + * @param licenseTestDir Directory of license text files for comparison in the form {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt + */ + public CombinedLicenseTester(File simpleLicenseTestDir, File licenseTestDir) { + simpleLicenseTester = new SimpleLicenseTester(simpleLicenseTestDir); + licenseTester = new LicenseTester(licenseTestDir); + } + + @Override + public List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException { + List retval = simpleLicenseTester.testException(exceptionContainer); + retval.addAll(licenseTester.testException(exceptionContainer)); + return retval; + } + + @Override + public List testLicense(ListedLicenseContainer licenseContainer) throws IOException, SpdxCompareException, InvalidSPDXAnalysisException { + List retval = simpleLicenseTester.testLicense(licenseContainer); + retval.addAll(licenseTester.testLicense(licenseContainer)); + return retval; + } + + @Nullable + @Override + public String getLicenseTestText(String licenseId) throws IOException { + return simpleLicenseTester.getLicenseTestText(licenseId); + } + + @Nullable + @Override + public String getExceptionTestText(String licenseExceptionId) throws IOException { + return simpleLicenseTester.getExceptionTestText(licenseExceptionId); + } +} diff --git a/src/org/spdx/licenselistpublisher/licensegenerator/ILicenseTester.java b/src/org/spdx/licenselistpublisher/licensegenerator/ILicenseTester.java index 0e414a3..a64c753 100644 --- a/src/org/spdx/licenselistpublisher/licensegenerator/ILicenseTester.java +++ b/src/org/spdx/licenselistpublisher/licensegenerator/ILicenseTester.java @@ -1,12 +1,13 @@ /** * Copyright (c) 2017 Source Auditor Inc. * + *

* Licensed 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. @@ -34,34 +35,35 @@ public interface ILicenseTester { /** * Test exception against the test files directory - * @param exceptionContainer - * @return - * @throws IOException - * @throws InvalidSPDXAnalysisException + * @param exceptionContainer Exception to test + * @return list of test failure descriptions. List is empty if all tests pass. + * @throws IOException on I/O error reading test file(s) + * @throws InvalidSPDXAnalysisException on error parsing SPDX licenses */ - public List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException; + List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException; /** * Test a license against the license test files * @param licenseContainer license to test * @return list of test failure descriptions. List is empty if all tests pass. - * @throws IOException - * @throws SpdxCompareException - * @throws InvalidSPDXAnalysisException + * @throws IOException on I/O error reading test file(s) + * @throws SpdxCompareException on error executing the compare + * @throws InvalidSPDXAnalysisException on error parsing SPDX licenses */ - public List testLicense(ListedLicenseContainer licenseContainer) throws IOException, SpdxCompareException, InvalidSPDXAnalysisException; + List testLicense(ListedLicenseContainer licenseContainer) throws IOException, SpdxCompareException, InvalidSPDXAnalysisException; /** - * @param licenseId + * @param licenseId license ID for the license text + * @throws IOException on I/O error reading test file(s) * @return text for the test for a license ID, null if no license text is found */ - public @Nullable String getLicenseTestText(String licenseId) throws IOException; + @Nullable String getLicenseTestText(String licenseId) throws IOException; /** - * @param licenseExceptionId - * @return text for the test for a exception ID, null if no license text is found - * @throws IOException + * @param licenseExceptionId license exception text + * @return text for the test for an exception ID, null if no license text is found + * @throws IOException on I/O error reading test file(s) */ - public @Nullable String getExceptionTestText(String licenseExceptionId) throws IOException; + @Nullable String getExceptionTestText(String licenseExceptionId) throws IOException; } diff --git a/src/org/spdx/licenselistpublisher/licensegenerator/LicenseTester.java b/src/org/spdx/licenselistpublisher/licensegenerator/LicenseTester.java index 22e2d9d..d299e4a 100644 --- a/src/org/spdx/licenselistpublisher/licensegenerator/LicenseTester.java +++ b/src/org/spdx/licenselistpublisher/licensegenerator/LicenseTester.java @@ -1,12 +1,12 @@ /** * Copyright (c) 2017 Source Auditor Inc. - * + *

* Licensed 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. @@ -37,9 +37,9 @@ /** * Test SPDX licenses against a directory of test licenses. - * + *

* The directory of test licenses contains license text with the following file naming convention: - * + *

* {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt * * @author Gary O'Neall @@ -47,21 +47,14 @@ */ public class LicenseTester implements ILicenseTester { - private Map licenseIdToTestMap; - private static FileFilter testFileFilter = new FileFilter() { - - @Override - public boolean accept(File arg0) { - return (arg0.isFile() && arg0.getName().toLowerCase().endsWith(".txt")); - } - - }; + private final Map licenseIdToTestMap; + private static final FileFilter testFileFilter = arg0 -> (arg0.isFile() && arg0.getName().toLowerCase().endsWith(".txt")); /** * @param licenseTestDirectory Directory of license text files for comparison in the form {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt */ public LicenseTester(File licenseTestDirectory) { - licenseIdToTestMap = new HashMap(); + licenseIdToTestMap = new HashMap<>(); File[] licenseIdDirs = licenseTestDirectory.listFiles(); if (licenseIdDirs != null) { for (File dir:licenseIdDirs) { @@ -74,16 +67,16 @@ public LicenseTester(File licenseTestDirectory) { /** * Test a license against the license test files - * @param license license to test + * @param licenseContainer license to test * @return list of test failure descriptions. List is empty if all tests pass. - * @throws IOException - * @throws SpdxCompareException - * @throws InvalidSPDXAnalysisException + * @throws IOException on I/O error reading test file(s) + * @throws SpdxCompareException on error comparing exceptions + * @throws InvalidSPDXAnalysisException on SPDX parsing errors */ @Override public List testLicense(ListedLicenseContainer licenseContainer) throws IOException, SpdxCompareException, InvalidSPDXAnalysisException { License license = licenseContainer.getV2ListedLicense(); - List retval = new ArrayList(); + List retval = new ArrayList<>(); File licenseDir = this.licenseIdToTestMap.get(license.getLicenseId()); if (licenseDir == null || !licenseDir.exists()) { return retval; @@ -130,15 +123,15 @@ private String readText(File f) throws IOException { /** * Test exception against the test files directory - * @param exception - * @return - * @throws IOException - * @throws InvalidSPDXAnalysisException + * @param exceptionContainer exception to test + * @return list of test failure descriptions. List is empty if all tests pass. + * @throws IOException on I/O error reading test file(s) + * @throws InvalidSPDXAnalysisException on SPDX parsing errors */ @Override public List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException { LicenseException exception = exceptionContainer.getV2Exception(); - List retval = new ArrayList(); + List retval = new ArrayList<>(); File exceptionDir = this.licenseIdToTestMap.get(exception.getLicenseExceptionId()); if (exceptionDir == null || !exceptionDir.exists()) { return retval; @@ -171,12 +164,12 @@ public List testException(ListedExceptionContainer exceptionContainer) t } @Override - public String getLicenseTestText(String licenseId) throws IOException { + public String getLicenseTestText(String licenseId) { throw new RuntimeException("Unimplemented getLicenseTestText"); } @Override - public String getExceptionTestText(String licenseExceptionId) throws IOException { + public String getExceptionTestText(String licenseExceptionId) { throw new RuntimeException("Unimplemented getExceptionTestText"); } } diff --git a/src/org/spdx/licenselistpublisher/licensegenerator/SimpleLicenseTester.java b/src/org/spdx/licenselistpublisher/licensegenerator/SimpleLicenseTester.java index ced2a9d..c792447 100644 --- a/src/org/spdx/licenselistpublisher/licensegenerator/SimpleLicenseTester.java +++ b/src/org/spdx/licenselistpublisher/licensegenerator/SimpleLicenseTester.java @@ -1,12 +1,12 @@ /** * Copyright (c) 2017 Source Auditor Inc. - * + *

* Licensed 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. @@ -17,7 +17,7 @@ import java.io.File; import java.io.IOException; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; @@ -33,16 +33,14 @@ import org.spdx.utility.compare.SpdxCompareException; /** - * Tests licenses against cononical text. + * Tests licenses against canonical text. * * @author Gary O'Neall * */ public class SimpleLicenseTester implements ILicenseTester { - - private Charset utf8 = Charset.forName("UTF-8"); - private File testFileDir; + private final File testFileDir; /** * @param testFileDir Directory containing license texts in the format [license-id].txt @@ -51,18 +49,12 @@ public SimpleLicenseTester(File testFileDir) { this.testFileDir = testFileDir; } - /* (non-Javadoc) - * @see org.spdx.licenselistpublisher.licensegenerator.ILicenseTester#testException(org.spdx.rdfparser.license.LicenseException) - */ - @Override - public List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException { - LicenseException exception = exceptionContainer.getV2Exception(); - File exceptionFile = new File(testFileDir.getPath() + File.separator + exception.getLicenseExceptionId() + ".txt"); - List retval = new ArrayList(); - if (!exceptionFile.exists()) { + public static List testException(LicenseException exception, File compareFile) throws InvalidSPDXAnalysisException, IOException { + List retval = new ArrayList<>(); + if (!compareFile.exists()) { retval.add("No test text exists for license exception ID "+exception.getLicenseExceptionId()); } else { - String compareText = readText(exceptionFile); + String compareText = readText(compareFile); DifferenceDescription result; try { result = LicenseCompareHelper.isTextStandardException(exception, compareText); @@ -76,30 +68,14 @@ public List testException(ListedExceptionContainer exceptionContainer) t return retval; } - private String readText(File f) throws IOException { - StringBuilder text = new StringBuilder(); - try(Stream fileLines = Files.lines(f.toPath(), utf8)) { - fileLines.forEach(line -> { - text.append(line); - text.append("\n"); - }); - } - return text.toString(); - } - /* (non-Javadoc) - * @see org.spdx.licenselistpublisher.licensegenerator.ILicenseTester#testLicense(org.spdx.rdfparser.license.License) - */ - @Override - public List testLicense(ListedLicenseContainer licenseContainer) throws IOException, InvalidSPDXAnalysisException { - License license = licenseContainer.getV2ListedLicense(); - List retval = new ArrayList(); - File licenseTextFile = new File(testFileDir.getPath() + File.separator + license.getLicenseId() + ".txt"); - if (!licenseTextFile.exists()) { + public static List testLicense(License license, File compareFile) throws InvalidSPDXAnalysisException, IOException { + List retval = new ArrayList<>(); + if (!compareFile.exists()) { if (!license.isDeprecated()) { retval.add("No test text exists for license ID "+license.getLicenseId()); } } else { - String compareText = readText(licenseTextFile); + String compareText = readText(compareFile); DifferenceDescription result; try { result = LicenseCompareHelper.isTextStandardLicense(license, compareText); @@ -113,6 +89,36 @@ public List testLicense(ListedLicenseContainer licenseContainer) throws return retval; } + /* (non-Javadoc) + * @see org.spdx.licenselistpublisher.licensegenerator.ILicenseTester#testException(org.spdx.rdfparser.license.LicenseException) + */ + @Override + public List testException(ListedExceptionContainer exceptionContainer) throws IOException, InvalidSPDXAnalysisException { + LicenseException exception = exceptionContainer.getV2Exception(); + File exceptionFile = new File(testFileDir.getPath() + File.separator + exception.getLicenseExceptionId() + ".txt"); + return testException(exception, exceptionFile); + } + + private static String readText(File f) throws IOException { + StringBuilder text = new StringBuilder(); + try(Stream fileLines = Files.lines(f.toPath(), StandardCharsets.UTF_8)) { + fileLines.forEach(line -> { + text.append(line); + text.append("\n"); + }); + } + return text.toString(); + } + /* (non-Javadoc) + * @see org.spdx.licenselistpublisher.licensegenerator.ILicenseTester#testLicense(org.spdx.rdfparser.license.License) + */ + @Override + public List testLicense(ListedLicenseContainer licenseContainer) throws IOException, InvalidSPDXAnalysisException { + License license = licenseContainer.getV2ListedLicense(); + File licenseTextFile = new File(testFileDir.getPath() + File.separator + license.getLicenseId() + ".txt"); + return testLicense(license, licenseTextFile); + } + @Override public String getLicenseTestText(String licenseId) throws IOException { File licenseTextFile = new File(testFileDir.getPath() + File.separator + licenseId + ".txt");