use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method deleteWithResponseClassWhileServerWaitTest.
/*
* @testName: deleteWithResponseClassWhileServerWaitTest
*
* @assertion_ids: JAXRS:JAVADOC:376;
*
* @test_Strategy: Invoke HTTP DELETE method for the current request
* asynchronously.
*/
@Test
public void deleteWithResponseClassWhileServerWaitTest() throws Fault {
AsyncInvoker async = startAsyncInvokerForMethod("deleteandwait");
Future<Response> future = async.delete(Response.class);
checkFutureOkResponse(future);
// return future;
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method optionsWithCallbackWhileServerWaitTest.
/*
* @testName: optionsWithCallbackWhileServerWaitTest
*
* @assertion_ids: JAXRS:JAVADOC:396;
*
* @test_Strategy: Invoke HTTP options method for the current request
* asynchronously.
*/
@Test
public void optionsWithCallbackWhileServerWaitTest() throws Fault {
AsyncInvoker async = startAsyncInvokerForMethod("optionsandwait");
InvocationCallback<Response> callback = createCallback(true);
Future<Response> future = async.options(callback);
checkFutureOkResponse(future);
assertCallbackCall();
// return future;
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class Resource method getResponseTest.
@GET
@Path("/getResponseTest")
public Response getResponseTest() {
Response r = Response.ok(TESTID).header("CTS-HEAD", TESTID).build();
WebApplicationException wae = new WebApplicationException(r);
return wae.getResponse();
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method assertResponse.
protected static void assertResponse(WebApplicationException e, Status status) throws Fault {
assertNotNull(e.getResponse(), "#getResponse is null");
Response response = e.getResponse();
assertEqualsInt(response.getStatus(), status.getStatusCode(), "response contains unexpected status", response.getStatus());
logMsg("response contains expected", status, "status");
}
use of jakarta.ws.rs.core.Response in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method registerClassWriterContractsInMapTest.
/*
* @testName: registerClassWriterContractsInMapTest
*
* @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 registerClassWriterContractsInMapTest() throws Fault {
final String content = "registerClassWriterContractsInMapTest";
Class<?>[] classes = createProviderClasses();
// entity to send to a server
Entity<?> entity = getCallableEntity(content);
// 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(MessageBodyWriter.class, 100);
config.register((Class<?>) 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 = getAssertableWithRegisteredProviderClassesOnConfigurable(cnt, 1);
// set we want to register the provider on Configurable
// Assertable::LOCATION[cnt]
registrar.setCurrentValue(0).setFinalValue(cnt);
Invocation i = checkConfig(registrar, assertable, classes, entity);
Response response = i.invoke();
response.bufferEntity();
String responseString = response.readEntity(String.class);
assertEquals(content, responseString, "Expected", content, "differs from given", response);
logMsg("sucessufully wrote Callable by provider registered on Configurable", Assertable.getLocation(cnt));
// check message body reader contract
try {
Callable<?> callable = response.readEntity(Callable.class);
fault("MessageBodyReader contract has been unexpectedly registered", callable);
} catch (Exception e) {
logMsg("MessageBodyReader contract has not been registered as expected", e);
}
}
}
Aggregations