use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromPathTest.
/*
* @testName: fromPathTest
*
* @assertion_ids: JAXRS:JAVADOC:1038;
*
* @test_Strategy: Convenience method to build a link from a path. Equivalent to
* fromUriBuilder(UriBuilder.fromPath(path)).
*/
@Test
public void fromPathTest() throws Fault {
String path = "somewhere/somehow";
UriBuilder builder = UriBuilder.fromPath(path);
Link.Builder linkBuilder = Link.fromUriBuilder(builder);
Link.Builder fromPathBuilder = Link.fromPath(path);
String fromUriBuilderString = linkBuilder.build().toString();
String fromPathString = fromPathBuilder.build().toString();
assertEquals(fromUriBuilderString, fromPathString, "fromUriBuilder()=", fromUriBuilderString, "differs from Link.fromPath()", fromPathString);
logMsg("fromUriBuilder(UriBuilder.fromPath(path)) is equivalent to fromPath(path)", "The link is", fromPathString);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromPathWithUriTemplateParamsTest.
/*
* @testName: fromPathWithUriTemplateParamsTest
*
* @assertion_ids: JAXRS:JAVADOC:1038;
*
* @test_Strategy: Convenience method to build a link from a path. Equivalent to
* fromUriBuilder(UriBuilder.fromPath(path)).
*/
@Test
public void fromPathWithUriTemplateParamsTest() throws Fault {
String path = "somewhere/somehow/{p1}/{p2}";
String param1 = "param1", param2 = "param2";
UriBuilder builder = UriBuilder.fromPath(path);
Link.Builder linkBuilder = Link.fromUriBuilder(builder);
Link.Builder fromPathBuilder = Link.fromPath(path);
String fromUriBuilderString = linkBuilder.build(param1, param2).toString();
String fromPathString = fromPathBuilder.build(param1, param2).toString();
assertEquals(fromUriBuilderString, fromPathString, "fromUriBuilder(UriBuilder.fromPath(,", path, "))=", fromUriBuilderString, "differs from Link.fromPath(", path, ")", fromPathString);
logMsg("fromUriBuilder(UriBuilder.fromPath(", path, ")) is equivalent to fromPath(", path, ")", "The link is", fromPathString);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method fromUriBuilderTest.
/*
* @testName: fromUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:1005;
*
* @test_Strategy: Create a new builder instance initialized from a URI builder.
*/
@Test
public void fromUriBuilderTest() throws Fault {
String segment = "goto/label/ten/";
Link link = Link.fromUri(uri(segment)).build();
UriBuilder builder = link.getUriBuilder();
Builder fromBuilder = Link.fromUriBuilder(builder);
String sBuilder = builder.build().toASCIIString();
String sFromBuilder = fromBuilder.build().getUri().toASCIIString();
assertContains(sFromBuilder, sBuilder, "Original builder", sBuilder, "not found in #fromUriBuilder", sFromBuilder);
logMsg("#fromUriBuilder", sFromBuilder, "contains the original", sBuilder);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method closeOnClientTargetWithUriBuilderTest.
/*
* @testName: closeOnClientTargetWithUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:409;
*
* @test_Strategy: Close client instance and all it's associated resources.
* Subsequent calls have no effect and are ignored. Once the client is closed,
* invoking any other method on the client instance would result in an
* IllegalTStateException being thrown. Calling this method effectively
* invalidates all WebTarget resource targets produced by the client instance.
* Invoking any method on such targets once the client is closed would result
* in an IllegalStateException being thrown.
*/
@Test
public void closeOnClientTargetWithUriBuilderTest() throws Fault {
client.close();
Link link = Link.fromUri("cts").build();
UriBuilder builder = UriBuilder.fromUri(link.getUri());
assertException(IllegalStateException.class, client, "target", builder);
}
use of jakarta.ws.rs.core.UriBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method targetUriBuilderTest.
/*
* @testName: targetUriBuilderTest
*
* @assertion_ids: JAXRS:JAVADOC:418;
*
* @test_Strategy: Build a new web resource target.
*/
@Test
public void targetUriBuilderTest() throws Fault {
UriBuilder builder = UriBuilder.fromUri(getUrl("call"));
target = client.target(builder);
assertTrue(target != null, "WebTarget is null");
}
Aggregations