use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildRelativizedThrowsIAEWhenSuppliedValueIsNullTest.
/*
* @testName: buildRelativizedThrowsIAEWhenSuppliedValueIsNullTest
*
* @assertion_ids: JAXRS:JAVADOC:1054;
*
* @test_Strategy: Throws: java.lang.IllegalArgumentException - if a value is
* null.
*/
@Test
public void buildRelativizedThrowsIAEWhenSuppliedValueIsNullTest() throws Fault {
// rfc6570
Builder linkBuilder = Link.fromUri(url() + "{x1}/{x2}/{x3}");
URI respect = null;
try {
respect = new URI(url());
} catch (URISyntaxException e) {
fault(e);
}
try {
Link link = linkBuilder.buildRelativized(respect, new Object[] { (String) null });
fault("IllegalArgumentException has not been thrown when value is not supplied, link=", link.toString());
} catch (IllegalArgumentException iae) {
logMsg("IllegalArgumentException has been thrown as expected when a supplied value is null");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method typeTest.
/*
* @testName: typeTest
*
* @assertion_ids: JAXRS:JAVADOC:811; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Convenience method to set a type on this link. If called more
* than once, the previous value of title is overwritten.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void typeTest() throws Fault {
String[] types = { "type1", "type2", "type3" };
Link.Builder builder = RuntimeDelegate.getInstance().createLinkBuilder().uri(url());
for (String type : types) {
Link link = builder.type(type).build();
assertTrue(link.getType().equals(type), "type " + type + " not found in " + link);
}
logMsg("#type set correct types");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method baseUriIsIgnoredURITest.
/*
* @testName: baseUriIsIgnoredURITest
*
* @assertion_ids: JAXRS:JAVADOC:1125; JAXRS:JAVADOC:1053;
*
* @test_Strategy: If the underlying URI is already absolute, the base URI is
* ignored.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void baseUriIsIgnoredURITest() throws Fault {
String ignored = "http://ignored.com";
URI ignoredUri = null;
try {
ignoredUri = new URI(ignored);
} catch (URISyntaxException e) {
fault(ignored);
}
URI uri = uri("something");
Builder linkBuilder = RuntimeDelegate.getInstance().createLinkBuilder();
linkBuilder = linkBuilder.uri(uri);
linkBuilder = linkBuilder.baseUri(ignoredUri);
URI createdUri = linkBuilder.build().getUri();
logMsg("Created URI", createdUri.toASCIIString());
assertFalse(createdUri.toASCIIString().contains(ignored), "Base Uri " + ignored + " is not ignored, though " + uri.toASCIIString() + " is absolute");
assertContains(createdUri.toASCIIString(), url());
logMsg("The base uri", ignored, "has been ignored as expected");
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method buildObjectsThrowsUriBuilderExceptionTest.
/*
* @testName: buildObjectsThrowsUriBuilderExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:804;
*
* @test_Strategy: throws UriBuilderException if a URI cannot be constructed
* based on the current state of the underlying URI builder.
*/
@Test
public void buildObjectsThrowsUriBuilderExceptionTest() throws Fault {
Link.Builder builder = Link.fromUri("http://:@");
try {
Link link = builder.build("aaa");
assertTrue(false, "No exception has been thrown for link " + link);
} catch (UriBuilderException e) {
logMsg("#build(someNonURIObjects) throw UriBuilderException as expected");
}
}
use of jakarta.ws.rs.core.Link.Builder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method relTest.
/*
* @testName: relTest
*
* @assertion_ids: JAXRS:JAVADOC:809; JAXRS:JAVADOC:1053;
*
* @test_Strategy: Convenience method to set a link relation. More than one rel
* value can be specified using this method.
*
* jakarta.ws.rs.ext.RuntimeDelegate.createLinkBuilder
*/
@Test
public void relTest() throws Fault {
String[] names = { "name1", "name2" };
Link.Builder builder = RuntimeDelegate.getInstance().createLinkBuilder().uri(url());
for (String name : names) {
Link link = builder.rel(name).build();
assertTrue(link.getRel().contains(name), "Rel " + name + " not found in " + link);
}
logMsg("#rel added expected relations");
}
Aggregations