Class LicenseTester

java.lang.Object
org.spdx.licenselistpublisher.licensegenerator.LicenseTester
All Implemented Interfaces:
ILicenseTester

public class LicenseTester extends Object implements ILicenseTester
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
  • Constructor Details

    • LicenseTester

      public LicenseTester(File licenseTestDirectory)
      Parameters:
      licenseTestDirectory - Directory of license text files for comparison in the form {license-id}/(license|header|exception)/(good|bad)/{test-id}.txt
  • Method Details

    • testLicense

      public List<String> testLicense(ListedLicenseContainer licenseContainer) throws IOException, org.spdx.utility.compare.SpdxCompareException, org.spdx.core.InvalidSPDXAnalysisException
      Test a license against the license test files
      Specified by:
      testLicense in interface ILicenseTester
      Parameters:
      licenseContainer - license to test
      Returns:
      list of test failure descriptions. List is empty if all tests pass.
      Throws:
      IOException - on I/O error reading test file(s)
      org.spdx.utility.compare.SpdxCompareException - on error comparing exceptions
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
    • testException

      public List<String> testException(ListedExceptionContainer exceptionContainer) throws IOException, org.spdx.core.InvalidSPDXAnalysisException
      Test exception against the test files directory
      Specified by:
      testException in interface ILicenseTester
      Parameters:
      exceptionContainer - exception to test
      Returns:
      list of test failure descriptions. List is empty if all tests pass.
      Throws:
      IOException - on I/O error reading test file(s)
      org.spdx.core.InvalidSPDXAnalysisException - on SPDX parsing errors
    • getLicenseTestText

      public String getLicenseTestText(String licenseId)
      Specified by:
      getLicenseTestText in interface ILicenseTester
      Parameters:
      licenseId - license ID for the license text
      Returns:
      text for the test for a license ID, null if no license text is found
    • getExceptionTestText

      public String getExceptionTestText(String licenseExceptionId)
      Specified by:
      getExceptionTestText in interface ILicenseTester
      Parameters:
      licenseExceptionId - license exception text
      Returns:
      text for the test for an exception ID, null if no license text is found