use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertyTest.
/*
* @testName: getPropertyTest
*
* @assertion_ids: JAXRS:JAVADOC:996; JAXRS:JAVADOC:758;
*
* @test_Strategy: Get the value for the property with a given name. Set the new
* configuration property
*/
@Test
public void getPropertyTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertPropertyIsSet(client.getConfiguration(), "property0");
logMsg("Found", client.getConfiguration().getProperty("property0"));
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
assertPropertyIsSet(target.getConfiguration(), "property0");
assertPropertyIsSet(target.getConfiguration(), "property1");
logMsg("Found", target.getConfiguration().getProperty("property1"));
}
void assertPropertyIsSet(Configuration config, String property) throws Fault {
assertTrue(config.getProperty(property).equals(property), "config.setProperty() did not set anything: " + getLocation());
}
};
checkConfigWithProperties(assertable);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertyNamesTest.
/*
* @testName: getPropertyNamesTest
*
* @assertion_ids: JAXRS:JAVADOC:997;
*
* @test_Strategy: Returns an immutable collection containing the property names
* available within the context of the current configuration instance.
*/
@Test
public void getPropertyNamesTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertSizeAndLog(client.getConfiguration(), 1);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
assertSizeAndLog(target.getConfiguration(), 2);
}
void assertSizeAndLog(Configuration config, int size) throws Fault {
int names = config.getPropertyNames().size();
assertEqualsInt(names, size + registeredPropertiesCnt, "getPropertyNames() is unexpected", getLocation(), "got", names, "properties");
logMsg("Found", names, "properties");
}
};
checkConfigWithProperties(assertable);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertiesTest.
/*
* @testName: getPropertiesTest
*
* @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 getPropertiesTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertSizeAndLog(client.getConfiguration(), 1);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
assertSizeAndLog(target.getConfiguration(), 2);
}
void assertSizeAndLog(Configuration config, int size) throws Fault {
int pSize = config.getProperties().size();
assertEqualsInt(pSize, size + registeredPropertiesCnt, "getConfiguration().getProperties() is not unexpected", getLocation(), "got", pSize, "properties");
logMsg("Found", pSize, "properties");
}
};
checkConfigWithProperties(assertable);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getClassesTest.
/*
* @testName: getClassesTest
*
* @assertion_ids: JAXRS:JAVADOC:992; JAXRS:JAVADOC:758;
*
* @test_Strategy: Get the immutable set of registered provider classes to be
* instantiated, injected and utilized in the scope of the configured instance.
* A provider class is a Java class with a jakarta.ws.rs.ext.Provider annotation
* declared on the class that implements a specific service interface.
*
* Register a provider class to be instantiated
*/
@Test
public void getClassesTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertSizeAndLog(client.getConfiguration(), 1);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
assertSizeAndLog(target.getConfiguration(), 2);
}
void assertSizeAndLog(Configuration config, int count) throws Fault {
assertTrue(config.getClasses().size() == count + registeredClassesCnt, "config.getClasses() return unexcepted size " + getLocation() + " : " + config.getClasses().size());
logMsg("Found", config.getClasses().size(), "providers");
}
};
Class<?>[] providerClasses = new Class[] { CallableProvider1.class, CallableProvider2.class };
checkConfig(assertable, providerClasses);
}
use of jakarta.ws.rs.client.WebTarget in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method isRegisteredProviderRegisteredClassTest.
/*
* @testName: isRegisteredProviderRegisteredClassTest
*
* @assertion_ids: JAXRS:JAVADOC:1001; JAXRS:JAVADOC:1002;
*
* @test_Strategy: Check if a particular JAX-RS component instance (such as
* providers or features) has been previously registered in the runtime
* configuration context.
*/
@Test
public void isRegisteredProviderRegisteredClassTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
client.register(CallableProvider1.class);
assertSizeAndLog(client.getConfiguration(), 1);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
target.register(CallableProvider2.class);
assertSizeAndLog(target.getConfiguration(), 2);
}
void assertSizeAndLog(Configuration config, int size) throws Fault {
assertFalse(config.isRegistered(new CallableProvider()), "CallableProvider is unexpectedly registered");
assertFalse(config.isRegistered(CallableProvider.class), "CallableProvider is unexpectedly registered");
switch(size) {
case 2:
assertFalse(config.isRegistered(new CallableProvider2()), "CallableProvider2 is registered " + getLocation());
assertTrue(config.isRegistered(CallableProvider2.class), "CallableProvider2.class is NOT registered " + getLocation());
logMsg("Found registered CallableProvider2 as expected", getLocation());
case 1:
assertFalse(config.isRegistered(new CallableProvider1()), "CallableProvider1 is registered " + getLocation());
assertTrue(config.isRegistered(CallableProvider1.class), "CallableProvider1.class is NOT registered " + getLocation());
logMsg("Found registered CallableProvider1 as expected", getLocation());
}
}
};
checkConfigWithProperties(assertable);
}
Aggregations