Skip to content

Commit

Permalink
Some testing of HttpURI for Issue #11448
Browse files Browse the repository at this point in the history
  • Loading branch information
joakime committed Feb 27, 2024
1 parent 98ceb73 commit 11b1d37
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,8 @@ public static Stream<Arguments> concatNormalizedURICases()
// Path choices
Arguments.of("http", "example.org", 0, "/a/b/c/d", null, null, "http://example.org/a/b/c/d"),
Arguments.of("http", "example.org", 0, "/a%20b/c%20d", null, null, "http://example.org/a%20b/c%20d"),
Arguments.of("http", "example.org", 0, "/foo%2Fbaz", null, null, "http://example.org/foo%2Fbaz"),
Arguments.of("http", "example.org", 0, "/foo%252Fbaz", null, null, "http://example.org/foo%252Fbaz"),
// Query specified
Arguments.of("http", "example.org", 0, "/", "a=b", null, "http://example.org/?a=b"),
Arguments.of("http", "example.org", 0, "/documentation/latest/", "a=b", null, "http://example.org/documentation/latest/?a=b"),
Expand All @@ -1046,6 +1048,24 @@ public void testFromAsStringNormalized(String scheme, String server, int port, S
assertThat(httpURI.asString(), is(expectedStr));
}

public static Stream<Arguments> fromStringAsStringCases()
{
return Stream.of(
Arguments.of("http://localhost:4444/", "http://localhost:4444/"),
Arguments.of("/foo/baz", "/foo/baz"),
Arguments.of("/foo%2Fbaz", "/foo%2Fbaz"),
Arguments.of("/foo%252Fbaz", "/foo%252Fbaz")
);
}

@ParameterizedTest
@MethodSource("fromStringAsStringCases")
public void testFromStringAsString(String input, String expected)
{
HttpURI httpURI = HttpURI.from(input);
assertThat(httpURI.asString(), is(expected));
}

/**
* Tests of parameters that result in undesired behaviors.
* {@link HttpURI#from(String, String, int, String)}
Expand Down

0 comments on commit 11b1d37

Please sign in to comment.