use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class UriBuilderIT method shouldBuildValidInstanceFromScratch.
/**
* Verifies that a valid instance can be created from scratch.
*
* @throws ExecutionException if the instance didn't boot correctly
* @throws InterruptedException if the test took much longer than usually
* expected
*/
@Test
public final void shouldBuildValidInstanceFromScratch() throws InterruptedException, ExecutionException {
// given
final UriBuilder uriBuilder = UriBuilder.newInstance();
// when
final URI uri = uriBuilder.scheme("scheme").host("host").port(1).build();
// then
assertThat(uri.toString(), is("scheme://host:1"));
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class UriBuilderIT method shouldThrowUriBuilderExceptionOnSchemeOnlyUri.
/**
* Verifies that {@code UriBuilder#build()} throws a {@link UriBuilderException}
* when it would be asked to create an invalid URI.
*
* @throws ExecutionException if the instance didn't boot correctly
* @throws InterruptedException if the test took much longer than usually
* expected
*/
@Test
public final void shouldThrowUriBuilderExceptionOnSchemeOnlyUri() throws InterruptedException, ExecutionException {
// given
final UriBuilder uriBuilder = UriBuilder.newInstance().scheme("http");
// then
assertThrows(UriBuilderException.class, /* when */
uriBuilder::build);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class URIInfoTest method requestTest.
@GET
@Path("/request")
public String requestTest(@Context UriInfo info) {
StringBuilder sb = new StringBuilder();
URI uri = info.getRequestUri();
UriBuilder urib = info.getRequestUriBuilder();
sb.append(uri.toString());
if (!uri.toString().equals(urib.build().toString())) {
sb.append("Got unexpected = " + urib.build().toString());
sb.append("FAILED");
}
return sb.toString();
}
Aggregations