test: cover Locale.ROOT lowercasing paths from #1086 - #1225
Open
pjfanning wants to merge 1 commit into
Open
Conversation
Motivation: apache#1086 switched a dozen call sites to Locale.ROOT but landed without tests, so TurkishISpec still only covers HttpCharsets and nothing exercises the directives. A regression in any of these paths would only show up for users running with a turkish default locale. Modification: Extend TurkishISpec with cases for `HttpHeader.parse`, `Uri` scheme normalization, `MediaTypes.forExtension` and `ErrorInfo.withErrorHeaderName`. Add TurkishLocaleDirectivesSpec covering `headerValueByName` and `overrideMethodWithParameter`, which live in the http module. Result: The header-name, scheme, file-extension, error-header-name, header-directive and method-override paths are pinned against locale sensitive case conversion. Tests: - sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.TurkishISpec" - 5 passed - sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.TurkishLocaleDirectivesSpec" - 2 passed; both fail when the two directives are reverted to default-locale case conversion - sbt headerCreateAll - added the Apache header to the new file - scalafmt --mode diff-ref=upstream/main - clean References: Refs apache#1086
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.
Motivation
#1086 moved a dozen call sites to
Locale.ROOTbut landed without tests. Onmaintoday the only turkish-i coverage is theHttpCharsetscase inTurkishISpec, and nothing exercises the two directives that were fixed, so a regression would only surface for users running with a turkish default locale.Two gaps worth calling out:
Uritest does not actually cover the fixed code.Uri("IPP://example.com")passes even against pre-use Locale.ROOT for toLowerCase/toUpperCase #1086 code, because the string parser lowercases the scheme through the ASCII-onlyCharUtils.toLowerCaseinUriParser.appendLoweredand never reachesUri.normalizeScheme. The test here usesUri(scheme = "IPP", authority = ...), which does go throughnormalizeScheme.headerValueByNameandoverrideMethodWithParameterlive in thehttpmodule, so they need a spec outsidehttp-core.Modification
TurkishISpec(http-core): four new cases under atr-TRdefault locale coveringHttpHeader.parse,Urischeme normalization,MediaTypes.forExtensionandErrorInfo.withErrorHeaderName.TurkishLocaleDirectivesSpec(http-tests): coversheaderValueByName("If-Match")andoverrideMethodWithParameterwith_method=options("options".toUpperCaseundertr-TRisOPTİONS, which used to yield501 Not Implemented).Both specs restore the previous default locale in a
finally. Test-only change; no production code is touched.Result
The paths #1086 fixed are pinned, and the same cases are available to check backports against.
Tests
sbt "http-core / Test / testOnly org.apache.pekko.http.scaladsl.model.TurkishISpec"- 5 passed (JDK 21).sbt "http-tests / Test / testOnly org.apache.pekko.http.scaladsl.server.directives.TurkishLocaleDirectivesSpec"- 2 passed. Both fail whenheaderValueByNameandoverrideMethodWithParameterare locally reverted to default-locale case conversion, so the cases are directional.TurkishISpeccases likewise all fail against1.4.xwithout use Locale.ROOT for toLowerCase/toUpperCase #1086 (verified while preparing the backport in backport: use Locale.ROOT for toLowerCase/toUpperCase (#1086) and RouteTest header lookup (#1223) #1224).sbt headerCreateAll- added the standard Apache header to the new file.scalafmt --mode diff-ref=upstream/main- clean.References
Refs #1086, Refs #1224