use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class SeBootstrapTest method shouldReturnSameUri.
/**
* Assert that calling {@code Configuration.baseUri} returns the correct URI as set
* by the mocked classes.
*
* @since 3.1
*/
@Test
public void shouldReturnSameUri() {
// given
final URI uri = URI.create("http://localhost:8080/foo");
final UriBuilder uriBuilder = mock(UriBuilder.class);
given(uriBuilder.build()).willReturn(uri);
final Configuration configuration = mock(Configuration.class);
given(configuration.baseUri()).willCallRealMethod();
given(configuration.baseUriBuilder()).willReturn(uriBuilder);
final SeBootstrap.Instance instance = mock(SeBootstrap.Instance.class);
given(instance.configuration()).willReturn(configuration);
// when
URI returnedUri = instance.configuration().baseUri();
// then
assertThat(uri, is(returnedUri));
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getUriBuilderIsDetachedTest.
/*
* @testName: getUriBuilderIsDetachedTest
*
* @assertion_ids: JAXRS:JAVADOC:609;
*
* @test_Strategy: Get the URI builder initialized with the URI of the current
* resource target. The returned URI builder is detached from the target, i.e.
* any updates in the URI builder MUST NOT have any effects on the URI of the
* originating target.
*/
@Test
public void getUriBuilderIsDetachedTest() throws Fault {
Client client = ClientBuilder.newClient();
WebTarget target = client.target(URL);
UriBuilder builder = target.getUriBuilder();
// The way to affect original target
client.close();
URI uri = builder.build();
assertContains(uri.toASCIIString(), URL);
logMsg("URI", uri, "contains", URL);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getUriBuilderTest.
/*
* @testName: getUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:797;
*
* @test_Strategy: Convenience method that returns a
* jakarta.ws.rs.core.UriBuilder initialized with this link's underlying URI.
*/
@Test
public void getUriBuilderTest() throws Fault {
URI uri = uri("get");
Builder builder = Link.fromUri(uri);
Link link = builder.build();
UriBuilder uriBuilder = link.getUriBuilder();
assertTrue(uriBuilder != null, "#getUriBuilder is null");
URI uriFromLink = uriBuilder.build();
assertTrue(uri.equals(uriFromLink), "#getUri() " + uriFromLink + " differes from original uri " + uri);
logMsg("Original URI", uri, "equals obtained", uriFromLink);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplateFromEncodedTest.
/*
* @testName: resolveTemplateFromEncodedTest
*
* @assertion_ids: JAXRS:JAVADOC:961;
*
* @test_Strategy: Resolve a URI template with a given name in this UriBuilder
* instance using a supplied encoded value.
*/
@Test
public void resolveTemplateFromEncodedTest() throws Fault {
Object[] s = { "path-rootless%2Ftest2", new StringBuilder("x%25yz"), "%2Fpath-absolute%2F%2525test1", "fred@example.com" };
UriBuilder builder = UriBuilder.fromPath("").path("{v}/{w}/{x}/{y}/{w}");
builder = builder.resolveTemplateFromEncoded("v", s[0]);
builder = builder.resolveTemplateFromEncoded("w", s[1]);
builder = builder.resolveTemplateFromEncoded("x", s[2]);
builder = builder.resolveTemplateFromEncoded("y", s[3]);
uri = builder.build();
gotExpectedPass(uri.getRawPath(), ENCODED_EXPECTED_PATH);
assertPassAndLog();
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesMapThrowsIAEOnNullValueTest.
/*
* @testName: resolveTemplatesMapThrowsIAEOnNullValueTest
*
* @assertion_ids: JAXRS:JAVADOC:963;
*
* @test_Strategy:java.lang.IllegalArgumentException - if the name-value map
* or any of the names or values in the map is null.
*/
@Test
public void resolveTemplatesMapThrowsIAEOnNullValueTest() throws Fault {
Map<String, Object> map = new HashMap<String, Object>();
map.put("a", null);
map.put("b", "path-rootless/test2");
UriBuilder builder = UriBuilder.fromPath("").path("{a}/{b}");
try {
builder.resolveTemplates(map);
fault("IllegalArgumentException has not been thrown");
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException has been thrown as expected", e);
}
}
Aggregations