use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertiesIsImmutableTest.
/*
* @testName: getPropertiesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:995; JAXRS:JAVADOC:758;
*
* @test_Strategy: Get the immutable bag of configuration properties. Set the
* new configuration property
*/
@Test
public void getPropertiesIsImmutableTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
setNewProperty(client.getConfiguration());
assertSizeAndLog(client.getConfiguration(), 1);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
setNewProperty(target.getConfiguration());
assertSizeAndLog(target.getConfiguration(), 2);
}
void setNewProperty(Configuration config) {
try {
config.getProperties().put("property88", "property88");
} catch (Exception e) {
// can throw an exception or do nothing
// or getProperties can be hard copy
}
}
void assertSizeAndLog(Configuration config, int size) throws Fault {
assertTrue(config.getProperties().size() == size + registeredPropertiesCnt, "getConfiguration().getProperties() is NOT immutable " + getLocation() + " got " + config.getProperties().size());
logMsg("Found", config.getProperties().size(), " properties");
}
};
checkConfigWithProperties(assertable);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method checkConfig.
protected void checkConfig(Registrar registrar, Assertable assertable, Object[] registerables) throws Fault {
Client client = ClientBuilder.newClient();
Configuration config = client.getConfiguration();
registeredPropertiesCnt = config.getProperties().size();
registeredClassesCnt = config.getClasses().size();
registeredInstancesCnt = config.getInstances().size();
logMsg("Already registered", registeredClassesCnt, "classes");
logMsg("Already registered", registeredInstancesCnt, "instances");
logMsg("Already registered", registeredPropertiesCnt, "properties");
register(registrar, client, registerables[0]);
assertable.check1OnClient(client);
assertable.incrementLocation();
WebTarget target = client.target("http://tck.cts:888");
register(registrar, target, registerables[1]);
assertable.check2OnTarget(target);
assertable.incrementLocation();
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesWithBooleanNullValueTest.
/*
* @testName: resolveTemplatesWithBooleanNullValueTest
*
* @assertion_ids: JAXRS:JAVADOC:948;
*
* @test_Strategy: NullPointerException - if the name-value map or any of the
* names or values in the map is null.
*/
@Test
public void resolveTemplatesWithBooleanNullValueTest() throws Fault {
Map<String, Object> map = new HashMap<String, Object>();
map.put("path", null);
WebTarget target = createWebTarget();
try {
target.path("{path}").resolveTemplates(map, true);
throw new Fault("NullPointerException has not been thrown");
} catch (NullPointerException npe) {
logMsg("NullPointerException has been thrown as expected", npe);
}
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method resolveTemplatesWithBooleanFalseReturnsTheSameTargetTest.
/*
* @testName: resolveTemplatesWithBooleanFalseReturnsTheSameTargetTest
*
* @assertion_ids: JAXRS:JAVADOC:948;
*
* @test_Strategy: A call to the method with an empty parameter map is
* ignored, i.e. same WebTarget instance is returned.
*/
@Test
public void resolveTemplatesWithBooleanFalseReturnsTheSameTargetTest() throws Fault {
WebTarget target = createWebTarget();
target = target.path("{path}");
WebTarget other = target.resolveTemplates(new TreeMap<String, Object>(), false);
assertEquals(target, other, "#pathParams did not return the same target when the input map is empty");
logMsg("#pathParams returned the same traget wehn empty as expected");
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method requestStringTest.
/*
* @testName: requestStringTest
*
* @assertion_ids: JAXRS:JAVADOC:623;
*
* @test_Strategy: Start building a request to the targeted web resource and
* define the accepted response media types.
*/
@Test
public void requestStringTest() throws Fault {
WebTarget target = createWebTarget();
Response response = target.request(MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.TEXT_XML).buildGet().invoke();
String body = response.readEntity(String.class);
assertContains(body, URL);
assertContains(body, MediaType.APPLICATION_ATOM_XML);
assertContains(body, MediaType.APPLICATION_JSON);
assertContains(body, MediaType.TEXT_XML);
}
Aggregations