use of jakarta.ws.rs.core.Configuration 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();
registeredClassesCnt = config.getClasses().size();
registeredInstancesCnt = config.getInstances().size();
logMsg("Already registered", registeredClassesCnt, "classes");
logMsg("Already registered", registeredInstancesCnt, "instances");
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.core.Configuration in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getClassesIsImmutableTest.
/*
* @testName: getClassesIsImmutableTest
*
* @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 getClassesIsImmutableTest() throws Fault {
Assertable assertable = new Assertable() {
@Override
public void check1OnClient(Client client) throws Fault {
assertSizeAndLog(client.getConfiguration(), 0);
registerNewProviderInstance(client.getConfiguration());
assertSizeAndLog(client.getConfiguration(), 0);
}
@Override
public void check2OnTarget(WebTarget target) throws Fault {
registerNewProviderInstance(target.getConfiguration());
assertSizeAndLog(target.getConfiguration(), 0);
}
void assertSizeAndLog(Configuration config, int count) throws Fault {
if (config.getClasses().size() == 1)
logMsg("Found", config.getClasses().iterator().next());
assertTrue(config.getClasses().size() == count + registeredClassesCnt, "config.getClasses() return unexcepted size " + getLocation() + " : " + config.getClasses().size());
logMsg("Found", config.getClasses().size(), "providers");
}
void registerNewProviderInstance(Configuration config) {
Class<?> clz = CallableProvider.class;
try {
config.getClasses().add(clz);
} catch (Exception e) {
// can throw exception or do nothing
// when adding to this immutable set
// or it can be a new hard copied set
}
}
};
checkConfigWithProperties(assertable);
}
use of jakarta.ws.rs.core.Configuration 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.core.Configuration 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.core.Configuration in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getInstancesIsImmutableTest.
/*
* @testName: getInstancesIsImmutableTest
*
* @assertion_ids: JAXRS:JAVADOC:994; JAXRS:JAVADOC:758;
*
* @test_Strategy: Get the immutable set of registered provider instances to be
* utilized by the configurable instance.
*
* Register a provider ("singleton") instance
*/
@Test
public void getInstancesIsImmutableTest() throws Fault {
Assertable assertable = new SingleCheckAssertable() {
@Override
protected void check(Configurable<?> configurable) throws Fault {
registerNewProviderInstance(configurable.getConfiguration());
assertSizeAndLog(configurable.getConfiguration(), 0);
}
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");
}
void registerNewProviderInstance(Configuration config) {
try {
config.getInstances().add(new CallableProvider());
} catch (Exception e) {
// can throw exception or do nothing
// when adding to this immutable set
// or it can be a new hard copied set
}
}
};
checkConfigWithProperties(assertable);
}
Aggregations