Fix under-determined test: testWithParam#2737
Merged
bjagg merged 3 commits intoDec 22, 2023
Merged
Conversation
Member
|
Hey @KiruthikaJanakiraman 👋
I'm not sure I follow, |
Contributor
Author
|
Hi, If I'm not wrong, the case where |
Member
|
@jgribonvald do you have insights on the intent of this method? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist
Description of change
This PR aims to fix an under-determined test: org.apereo.portal.url.CasLoginRefUrlEncoderTest.testWithParam
I found and confirmed the failure of the test using an open-source research tool NonDex, which shuffles implementations of nondeterminism operations.
Problem
The test case org.apereo.portal.url.CasLoginRefUrlEncoderTest.testWithParam fails due to the below assertion:
uPortal/uPortal-security/uPortal-security-mvc/src/test/java/org/apereo/portal/url/CasLoginRefUrlEncoderTest.java
Lines 66 to 68 in 23e387d
This is because, findMatchingServerName returns the first element from
allServerNamescollection.uPortal/uPortal-utils/uPortal-utils-url/src/main/java/org/apereo/portal/url/UrlMultiServerNameCustomizer.java
Line 63 in 5d1d743
Since
allServerNamesis aHashSet, the order of the items"myhost:8080", "theirhost:8443"in theHashSetis not preserved. Hence the server name returned byfindMatchingServerNamemay vary which may cause the test testWithParam to fail in a hypothetical future.Solution
This PR fixes the test by using a
LinkedHashSetto storeallServerNamessinceLinkedHashSetpreserves the order of the elements.Steps to reproduce
The following command can be used to reproduce the assertion errors and verify the fix.
Integrate NonDex:
Add the following snippet to the top of the build.gradle in $PROJ_DIR:
Append to build.gradle in $PROJ_DIR:
Execute Test with Gradle:
Run NonDex:
Test Environment:
Please let me know if you have any concerns or questions.