Migrate HttpWagonHttpServerTestCase and its subclasses off PlexusTestCase - #930
Merged
Conversation
…Case The container was only supplying Wagon.ROLE, which is HttpWagon, and AbstractHttpClientWagon declares no injected collaborators, so a plain constructor is equivalent. The base lifecycle method is renamed startTestServer so a subclass @beforeeach cannot override it: with the same signature JUnit 5 would run only the override and the server would never be created. The subclasses therefore drop their super.setUp() call, since JUnit 5 runs a superclass @beforeeach first on its own. getName() came from junit.framework.TestCase and is used to build unique temp file names; it now comes from an injected TestInfo, leaving the six call sites unchanged.
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.
Completes the wagon-http side of moving off
PlexusTestCase: the abstractHttpWagonHttpServerTestCaseand its two subclasses.No new dependency is needed. The container was only supplying
Wagon.ROLE, which isHttpWagon, andAbstractHttpClientWagondeclares no injected collaborators, sonew HttpWagon()is equivalent to thelookup — the same reasoning already applied to
HugeFileDownloadTest.Two details that are not mechanical and are worth a look:
startTestServer. Left assetUp(), the subclasses' ownsetUp()would override it, and JUnit 5 would then run only the override — the Jetty server wouldnever be created and every test would fail on a null. With distinct names JUnit 5 runs the
superclass
@BeforeEachfirst in its own right, so the subclasses drop theirsuper.setUp()call.getName()came fromjunit.framework.TestCaseand is used to build unique temp file names(
FileTestUtils.createUniqueFile(getName(), getName()), six call sites). It now comes from aninjected
TestInfo, so those call sites are unchanged.Verified:
mvn testonwagon-http, counting<testcase>elements per class — 295 before and after,2 skipped in both, zero failures.
HttpWagonErrorTeststays at 5 andHttpWagonTimeoutTestat 4,which is what shows the base setup still runs; had it not, both would have failed on a null server
rather than silently reporting fewer tests.
This change was created with AI assistance.