use of jakarta.ws.rs.core.Configuration 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.core.Configuration 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.core.Configuration 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);
}
use of jakarta.ws.rs.core.Configuration 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.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();
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();
}
Aggregations