From 179a389d0053b945524000045da223872f8b5805 Mon Sep 17 00:00:00 2001 From: Gary O'Neall Date: Thu, 12 Mar 2026 14:09:03 -0700 Subject: [PATCH] Fix long running unit tests Fixes #403 Signed-off-by: Gary O'Neall --- .../utility/compare/LicenseCompareHelperTest.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/test/java/org/spdx/utility/compare/LicenseCompareHelperTest.java b/src/test/java/org/spdx/utility/compare/LicenseCompareHelperTest.java index 85e2b7c81..f6a19e9a7 100644 --- a/src/test/java/org/spdx/utility/compare/LicenseCompareHelperTest.java +++ b/src/test/java/org/spdx/utility/compare/LicenseCompareHelperTest.java @@ -22,13 +22,7 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import org.spdx.core.DefaultModelStore; import org.spdx.core.IModelCopyManager; @@ -777,8 +771,9 @@ public void testMatchingStandardLicenseExceptionIdsWithinText() throws InvalidSP String gpl20WithClasspathException20 = gpl20 + "\n\n" + classpathException20; String textWithRandomPrefixAndSuffix = "Some random preamble text.\n\n" + classpathException20 + "\n\nSome random epilogue text."; - List expectedResultEmpty = Arrays.asList(); - List expectedResultClasspathException20 = Arrays.asList("Classpath-exception-2.0"); + List expectedResultEmpty = Collections.emptyList(); + List classPathException20Only = Collections.singletonList("Classpath-exception-2.0"); + List expectedResultClasspathException20 = Arrays.asList("Classpath-exception-2.0", "Classpath-exception-2.0-short"); // Note: be cautious about adding too many assertions to this test, as LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText can have lengthy runtimes assertListsEqual(expectedResultEmpty, LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText(null)); @@ -786,7 +781,7 @@ public void testMatchingStandardLicenseExceptionIdsWithinText() throws InvalidSP assertListsEqual(expectedResultEmpty, LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText("Some random text that isn't a standard license exception")); // Tests for the 2-arg version of matchingStandardLicenseExceptionIdsWithinText (which is faster than the 1-arg version) - assertListsEqual(expectedResultClasspathException20, LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText(gpl20WithClasspathException20, Arrays.asList("Classpath-exception-2.0"))); + assertListsEqual(classPathException20Only, LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText(gpl20WithClasspathException20, classPathException20Only)); if (UnitTestHelper.runSlowTests()) { assertListsEqual(expectedResultClasspathException20, LicenseCompareHelper.matchingStandardLicenseExceptionIdsWithinText(classpathException20));