Skip to content

Commit

Permalink
Simplify @⁠EnumSource usage
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Nov 18, 2024
1 parent d421f61 commit f5c3f35
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void incrementsSequenceUsingH2EmbeddedDatabaseConfigurer() {
* Tests that the incrementer works when using all supported H2 <em>compatibility modes</em>.
*/
@ParameterizedTest
@EnumSource(ModeEnum.class)
@EnumSource
void incrementsSequenceWithExplicitH2CompatibilityMode(ModeEnum mode) {
String connectionUrl = String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;MODE=%s", UUID.randomUUID(), mode);
DataSource dataSource = new SimpleDriverDataSource(new org.h2.Driver(), connectionUrl, "sa", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
class UriComponentsBuilderTests {

@ParameterizedTest // see gh-26453
@EnumSource(value = ParserType.class)
@EnumSource
void examplesInReferenceManual(ParserType parserType) {
final String expected = "/hotel%20list/New%20York?q=foo%2Bbar";

Expand Down Expand Up @@ -156,7 +156,7 @@ void fromOpaqueUri() {
}

@ParameterizedTest // see gh-9317
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriEncodedQuery(ParserType parserType) {
URI uri = URI.create("https://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D");
String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0);
Expand All @@ -167,7 +167,7 @@ void fromUriEncodedQuery(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriString(ParserType parserType) {
UriComponents result = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc3986.txt", parserType).build();
assertThat(result.getScheme()).isEqualTo("https");
Expand Down Expand Up @@ -224,7 +224,7 @@ void fromUriString(ParserType parserType) {
}

@ParameterizedTest // see SPR-9832
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriStringQueryParamWithReservedCharInValue(ParserType parserType) {
String uri = "https://www.google.com/ig/calculator?q=1USD=?EUR";
UriComponents result = UriComponentsBuilder.fromUriString(uri, parserType).build();
Expand All @@ -234,7 +234,7 @@ void fromUriStringQueryParamWithReservedCharInValue(ParserType parserType) {
}

@ParameterizedTest // see SPR-14828
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriStringQueryParamEncodedAndContainingPlus(ParserType parserType) {
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98";
URI uri = UriComponentsBuilder.fromUriString(httpUrl, parserType).build(true).toUri();
Expand All @@ -243,22 +243,22 @@ void fromUriStringQueryParamEncodedAndContainingPlus(ParserType parserType) {
}

@ParameterizedTest // see SPR-10539
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriStringIPv6Host(ParserType parserType) {
UriComponents result = UriComponentsBuilder
.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource", parserType).build().encode();
assertThat(result.getHost()).isEqualToIgnoringCase("[1abc:2abc:3abc::5ABC:6abc]");
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriStringInvalidIPv6Host(ParserType parserType) {
assertThatIllegalArgumentException().isThrownBy(() ->
UriComponentsBuilder.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource", parserType));
}

@ParameterizedTest // see SPR-11970
@EnumSource(value = ParserType.class)
@EnumSource
void fromUriStringNoPathWithReservedCharInQuery(ParserType parserType) {
UriComponents result = UriComponentsBuilder.fromUriString("https://example.com?foo=bar@baz", parserType).build();
assertThat(result.getUserInfo()).isNull();
Expand All @@ -268,7 +268,7 @@ void fromUriStringNoPathWithReservedCharInQuery(ParserType parserType) {
}

@ParameterizedTest // see SPR-1428
@EnumSource(value = ParserType.class)
@EnumSource
void fromHttpUrlQueryParamEncodedAndContainingPlus(ParserType parserType) {
String httpUrl = "http://localhost:8080/test/print?value=%EA%B0%80+%EB%82%98";
URI uri = UriComponentsBuilder.fromUriString(httpUrl, parserType).build(true).toUri();
Expand All @@ -277,7 +277,7 @@ void fromHttpUrlQueryParamEncodedAndContainingPlus(ParserType parserType) {
}

@ParameterizedTest // see SPR-10779
@EnumSource(value = ParserType.class)
@EnumSource
void fromHttpUrlCaseInsensitiveScheme(ParserType parserType) {
assertThat(UriComponentsBuilder.fromUriString("HTTP://www.google.com", parserType).build().getScheme())
.isEqualTo("http");
Expand All @@ -286,14 +286,14 @@ void fromHttpUrlCaseInsensitiveScheme(ParserType parserType) {
}

@ParameterizedTest // see SPR-10539
@EnumSource(value = ParserType.class)
@EnumSource
void fromHttpUrlInvalidIPv6Host(ParserType parserType) {
assertThatIllegalArgumentException().isThrownBy(() ->
UriComponentsBuilder.fromUriString("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource", parserType));
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void fromHttpUrlWithoutFragment(ParserType parserType) {
String httpUrl = "http://localhost:8080/test/print";
UriComponents uriComponents = UriComponentsBuilder.fromUriString(httpUrl, parserType).build();
Expand Down Expand Up @@ -333,7 +333,7 @@ void fromHttpUrlWithoutFragment(ParserType parserType) {
}

@ParameterizedTest // see gh-25300
@EnumSource(value = ParserType.class)
@EnumSource
void fromHttpUrlWithFragment(ParserType parserType) {
String httpUrl = "https://example.com/#baz";
UriComponents uriComponents = UriComponentsBuilder.fromUriString(httpUrl, parserType).build();
Expand Down Expand Up @@ -449,7 +449,7 @@ void pathWithDuplicateSlashes() {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void replacePath(ParserType parserType) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://www.ietf.org/rfc/rfc2396.txt", parserType);
builder.replacePath("/rfc/rfc3986.txt");
Expand All @@ -465,7 +465,7 @@ void replacePath(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void replaceQuery(ParserType parserType) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString("https://example.com/foo?foo=bar&baz=qux", parserType);
builder.replaceQuery("baz=42");
Expand Down Expand Up @@ -605,7 +605,7 @@ void buildAndExpandHierarchical() {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void parseBuildAndExpandHierarchical(ParserType parserType) {
URI uri = UriComponentsBuilder
.fromUriString("{scheme}://{host}:{port}/{segment}?{query}#{fragment}", parserType)
Expand All @@ -617,7 +617,7 @@ void parseBuildAndExpandHierarchical(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void buildAndExpandOpaque(ParserType parserType) {
UriComponents result = UriComponentsBuilder.fromUriString("mailto:{user}@{domain}", parserType)
.buildAndExpand("foo", "example.com");
Expand All @@ -631,7 +631,7 @@ void buildAndExpandOpaque(ParserType parserType) {
}

@ParameterizedTest // gh-33699
@EnumSource(value = ParserType.class)
@EnumSource
void schemeVariableMixedCase(ParserType parserType) {

BiConsumer<String, String> tester = (scheme, value) -> {
Expand All @@ -647,23 +647,23 @@ void schemeVariableMixedCase(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void queryParamWithValueWithEquals(ParserType parserType) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar=baz", parserType).build();
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar=baz");
assertThat(uriComponents.getQueryParams().get("bar")).containsExactly("baz");
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void queryParamWithoutValueWithEquals(ParserType parserType) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar=", parserType).build();
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar=");
assertThat(uriComponents.getQueryParams().get("bar")).element(0).asString().isEmpty();
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void queryParamWithoutValueWithoutEquals(ParserType parserType) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("https://example.com/foo?bar", parserType).build();
assertThat(uriComponents.toUriString()).isEqualTo("https://example.com/foo?bar");
Expand All @@ -688,7 +688,7 @@ void opaqueUriDoesNotResetOnNullInput() {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void relativeUrls(ParserType parserType) {
String baseUrl = "https://example.com";
assertThat(UriComponentsBuilder.fromUriString(baseUrl + "/foo/../bar", parserType).build().toString())
Expand All @@ -706,7 +706,7 @@ void relativeUrls(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void emptySegments(ParserType parserType) {
String baseUrl = "https://example.com/abc/";
assertThat(UriComponentsBuilder.fromUriString(baseUrl, parserType).path("/x/y/z").build().toString())
Expand All @@ -720,15 +720,15 @@ void emptySegments(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void parsesEmptyFragment(ParserType parserType) {
UriComponents components = UriComponentsBuilder.fromUriString("/example#", parserType).build();
assertThat(components.getFragment()).isNull();
assertThat(components.toString()).isEqualTo("/example");
}

@ParameterizedTest // SPR-13257
@EnumSource(value = ParserType.class)
@EnumSource
void parsesEmptyUri(ParserType parserType) {
UriComponents components = UriComponentsBuilder.fromUriString("", parserType).build();
assertThat(components.toString()).isEmpty();
Expand Down Expand Up @@ -791,7 +791,7 @@ void testDeepClone() {
}

@ParameterizedTest // gh-26466
@EnumSource(value = ParserType.class)
@EnumSource
void encodeTemplateWithInvalidPlaceholderSyntax(ParserType parserType) {

BiConsumer<String, String> tester = (in, out) ->
Expand Down Expand Up @@ -821,7 +821,7 @@ void encodeTemplateWithInvalidPlaceholderSyntax(ParserType parserType) {
}

@ParameterizedTest // SPR-16364
@EnumSource(value = ParserType.class)
@EnumSource
void uriComponentsNotEqualAfterNormalization(ParserType parserType) {
UriComponents uri1 = UriComponentsBuilder.fromUriString("http://test.com", parserType).build().normalize();
UriComponents uri2 = UriComponentsBuilder.fromUriString("http://test.com/", parserType).build();
Expand All @@ -832,7 +832,7 @@ void uriComponentsNotEqualAfterNormalization(ParserType parserType) {
}

@ParameterizedTest // SPR-17256
@EnumSource(value = ParserType.class)
@EnumSource
void uriComponentsWithMergedQueryParams(ParserType parserType) {
String uri = UriComponentsBuilder.fromUriString("http://localhost:8081", parserType)
.uriComponents(UriComponentsBuilder.fromUriString("/{path}?sort={sort}", parserType).build())
Expand All @@ -842,7 +842,7 @@ void uriComponentsWithMergedQueryParams(ParserType parserType) {
}

@ParameterizedTest // SPR-17630
@EnumSource(value = ParserType.class)
@EnumSource
void toUriStringWithCurlyBraces(ParserType parserType) {
assertThat(UriComponentsBuilder.fromUriString("/path?q={asa}asa", parserType).toUriString())
.isEqualTo("/path?q=%7Basa%7Dasa");
Expand All @@ -855,7 +855,7 @@ void verifyDoubleSlashReplacedWithSingleOne() {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void validPort(ParserType parserType) {
UriComponents uriComponents = UriComponentsBuilder.fromUriString("http://localhost:52567/path", parserType).build();
assertThat(uriComponents.getPort()).isEqualTo(52567);
Expand All @@ -871,7 +871,7 @@ void validPort(ParserType parserType) {
}

@ParameterizedTest
@EnumSource(value = ParserType.class)
@EnumSource
void verifyInvalidPort(ParserType parserType) {
String url = "http://localhost:XXX/path";
assertThatIllegalArgumentException()
Expand All @@ -881,7 +881,7 @@ void verifyInvalidPort(ParserType parserType) {
}

@ParameterizedTest // gh-27039
@EnumSource(value = ParserType.class)
@EnumSource
void expandPortAndPathWithoutSeparator(ParserType parserType) {
URI uri = UriComponentsBuilder
.fromUriString("ws://localhost:{port}/{path}", parserType)
Expand Down
Loading

0 comments on commit f5c3f35

Please sign in to comment.