use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerObjectBindingPriorityTest.
/*
* @testName: registerObjectBindingPriorityTest
*
* @assertion_ids: JAXRS:JAVADOC:759;
*
* @test_Strategy: Any binding priority specified on the registered JAX-RS
* component class via
*
* @Priority annotation is overridden with the supplied bindingPriority value.
*/
@Test
public void registerObjectBindingPriorityTest() throws Fault {
final String content = "registerObjectBindingPriorityTest";
Class<?>[] classes = createProviderClasses();
// 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) {
config.register(new FirstFilter(), 400);
config.register(new SecondFilter(), 399);
}
}
};
setResourceMethod("echo");
// configurable each time
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);
Assertable assertable = getAssertableWithRegisteredProviderInstancesOnConfigurable(cnt, 2);
Invocation i = checkConfig(registrar, assertable, classes, entity);
String response = i.invoke(String.class);
assertEquals(FirstFilter.class.getName(), response, "Unexpected filter ordering, the last was", response);
logMsg(response, "has been executed as second, as expected");
}
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerObjectNullContractsTest.
/*
* @testName: registerObjectNullContractsTest
*
* @assertion_ids: JAXRS:JAVADOC:760;
*
* @test_Strategy: Implementations MUST ignore attempts to register a
* component class for a null collection of contracts via this method and
* SHOULD raise a warning about such event.
*/
@Test
public void registerObjectNullContractsTest() throws Fault {
Object[] instances = createProviderInstances();
// 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)
config.register(registerable, (Class<?>[]) null);
}
};
setResourceMethod("echo");
// build client configurableCnt times to register provider using a
// different
// configurable each time
Assertable assertable = getAssertableWithNoRegisteredProvider();
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, instances, entity);
logMsg("The provider with null contract has ben ignored as expected");
}
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerObjectReaderContractsTest.
/*
* @testName: registerObjectReaderContractsTest
*
* @assertion_ids: JAXRS:JAVADOC:760;
*
* @test_Strategy: This registration method provides the same functionality as
* register(Object) except the JAX-RS component class is only registered as a
* provider of the listed extension provider or meta-provider contracts.
*/
@Test
public void registerObjectReaderContractsTest() throws Fault {
final String content = "registerClassReaderContractsTest";
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)
config.register(registerable, MessageBodyReader.class);
}
};
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 registerClassBindingPriorityInMapTest.
/*
* @testName: registerClassBindingPriorityInMapTest
*
* @assertion_ids: JAXRS:JAVADOC:989;
*
* @test_Strategy: This registration method provides same functionality as
* register(Class, 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 registerClassBindingPriorityInMapTest() throws Fault {
final String content = "registerClassBindingPriorityInMapTest";
Class<?>[] classes = createProviderClasses();
// 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(ClientRequestFilter.class, 400);
config.register(FirstFilter.class, contracts);
contracts.clear();
contracts.put(ClientRequestFilter.class, 300);
config.register(SecondFilter.class, 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));
// set we want to register the provider on Configurable
// Assertable::LOCATION[cnt]
registrar.setCurrentValue(0).setFinalValue(cnt);
Assertable assertable = getAssertableWithRegisteredProviderClassesOnConfigurable(cnt, 2);
Invocation i = checkConfig(registrar, assertable, classes, entity);
String response = i.invoke(String.class);
assertEquals(FirstFilter.class.getName(), response, "Unexpected filter ordering, the last was", response);
logMsg(response, "has been executed as second, as expected");
}
}
use of ee.jakarta.tck.ws.rs.api.rs.core.configurable.Assertable in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerObjectBindingPriorityInMapTest.
/*
* @testName: registerObjectBindingPriorityInMapTest
*
* @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 registerObjectBindingPriorityInMapTest() throws Fault {
final String content = "registerObjectBindingPriorityInMapTest";
Class<?>[] classes = createProviderClasses();
// 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(ClientRequestFilter.class, 400);
config.register(new FirstFilter(), contracts);
contracts.clear();
contracts.put(ClientRequestFilter.class, 300);
config.register(new SecondFilter(), 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));
// set we want to register the provider on Configurable
// Assertable::LOCATION[cnt]
registrar.setCurrentValue(0).setFinalValue(cnt);
Assertable assertable = getAssertableWithRegisteredProviderInstancesOnConfigurable(cnt, 2);
Invocation i = checkConfig(registrar, assertable, classes, entity);
String response = i.invoke(String.class);
assertEquals(FirstFilter.class.getName(), response, "Unexpected filter ordering, the last was", response);
logMsg(response, "has been executed as second, as expected");
}
}
Aggregations