use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getContractsIsNeverNullTest.
/*
* @testName: getContractsIsNeverNullTest
*
* @assertion_ids: JAXRS:JAVADOC:993;
*
* @test_Strategy: Get the extension contract registration information for a
* component of a given class. Method does not return null.
*/
@Test
public void getContractsIsNeverNullTest() throws Fault {
Assertable assertable = new SingleCheckAssertable() {
void assertNotNullAndLog(Configurable<?> config) throws Fault {
Map<Class<?>, Integer> map = config.getConfiguration().getContracts(MessageBodyReader.class);
assertNotNull(map, "getContracts is null", getLocation());
logMsg("#getContracts() is not null as expected", getLocation());
}
@Override
protected void check(Configurable<?> configurable) throws Fault {
assertNotNullAndLog(configurable);
}
};
checkConfigWithProperties(assertable);
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable 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 ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertyIsNullTest.
/*
* @testName: getPropertyIsNullTest
*
* @assertion_ids: JAXRS:JAVADOC:996; JAXRS:JAVADOC:758;
*
* @test_Strategy: null if the property with such name is not configured.
*/
@Test
public void getPropertyIsNullTest() throws Fault {
Assertable assertable = new SingleCheckAssertable() {
void assertPropertyIsNull(Configurable<?> config) throws Fault {
assertTrue(config.getConfiguration().getProperty("property88") == null, "#getProperty('nonexisting') != null " + getLocation());
logMsg("#getProperty('nonexisting') is null as expected");
}
@Override
protected void check(Configurable<?> configurable) throws Fault {
assertPropertyIsNull(configurable);
}
};
checkConfigWithProperties(assertable);
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerObjectReaderContractsInMapTest.
/*
* @testName: registerObjectReaderContractsInMapTest
*
* @assertion_ids: JAXRS:JAVADOC:990;
*
* @test_Strategy: This registration method provides same functionality as
* register(Object, Class[]) except that any binding priority specified on the
* registered JAX-RS component class using @Priority annotation is overridden
* for each extension provider contract type separately with an integer
* binding priority value specified as a value in the supplied map.
*/
@Test
public void registerObjectReaderContractsInMapTest() throws Fault {
final String content = "registerObjectReaderContractsInMapTest";
Object[] instances = createProviderInstances();
// entity to send to a server
Entity<?> entity = Entity.entity(content, MediaType.WILDCARD);
// register only once per client build
IncrementableRegistrar registrar = new IncrementableRegistrar(0, 1) {
@Override
public void register(Configurable<?> config, Object registerable) {
if (currentValue++ == finalValue) {
Map<Class<?>, Integer> contracts = new HashMap<Class<?>, Integer>();
contracts.put(MessageBodyReader.class, 100);
config.register(registerable, contracts);
}
}
};
setResourceMethod("echo");
// configurable each time
for (int cnt = 0; cnt != configurableCnt; cnt++) {
// Check the provider is registered
logMsg("Check on Configurable", Assertable.getLocation(cnt));
Assertable assertable = getAssertableWithRegisteredProviderInstancesOnConfigurable(cnt, 1);
// set we want to register the provider on Configurable
// Assertable::LOCATION[cnt]
registrar.setCurrentValue(0).setFinalValue(cnt);
Invocation i = checkConfig(registrar, assertable, instances, entity);
Response response = i.invoke();
Callable<?> callable = response.readEntity(Callable.class);
assertEquals(content, callable.toString(), "Expected", content, "differs from given", response);
logMsg("sucessufully read Callable by provider registered on Configurable", Assertable.getLocation(cnt));
}
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerClassNotAssignableContractsInMapTest.
/*
* @testName: registerClassNotAssignableContractsInMapTest
*
* @assertion_ids: JAXRS:JAVADOC:989;
*
* @test_Strategy: Contracts that are not assignable from the registered
* component class MUST be ignored
*/
@Test
public void registerClassNotAssignableContractsInMapTest() throws Fault {
Class<?>[] classes = createProviderClasses();
// entity to send to a server
Entity<?> entity = Entity.entity("", MediaType.WILDCARD);
// register only once per client build
IncrementableRegistrar registrar = new IncrementableRegistrar(0, 1) {
@Override
public void register(Configurable<?> config, Object registerable) {
if (currentValue++ == finalValue) {
Map<Class<?>, Integer> contracts = new HashMap<Class<?>, Integer>();
contracts.put(ClientRequestFilter.class, 400);
config.register((Class<?>) registerable, contracts);
}
}
};
setResourceMethod("echo");
// build client configurableCnt times to register provider using a
// different
// configurable each time
Assertable assertable = getAssertableWithNoRegisteredProviderInstance();
for (int cnt = 0; cnt != configurableCnt; cnt++) {
// Check the provider is registered
logMsg("Check on Configurable", Assertable.getLocation(cnt));
// set we want to register the provider on Configurable
// Assertable::LOCATION[cnt]
registrar.setCurrentValue(0).setFinalValue(cnt);
checkConfig(registrar, assertable, classes, entity);
logMsg("The provider with unassignable contract has ben ignored as expected");
}
}
Aggregations