use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method ioExceptionTest.
/*
* @testName: ioExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:921; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: Throws IOException - if an IO error arises.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void ioExceptionTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.IOEXCEPTION);
Response fake = builder.build();
addProviders(fake);
invoke();
try {
getResponseBody();
} catch (Exception e) {
assertNotNull(e.getMessage(), "Returned unexpected exception", e);
IOException io = assertCause(e, IOException.class, "Unexpected exception has been found:", e);
assertContains(io.getMessage(), TemplateInterceptorBody.IOE, "Found unexpected message from IOException", e.getMessage());
logMsg("found expected IOException", io);
return;
}
fault("Expected IOException not found");
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getPropertyIsNullTest.
/*
* @testName: getPropertyIsNullTest
*
* @assertion_ids: JAXRS:JAVADOC:906; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: Returns null if there is no property by that name.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void getPropertyIsNullTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.GETPROPERTY);
Response fake = builder.build();
addProviders(fake);
setProperty(Property.SEARCH_STRING, TemplateInterceptorBody.NULL);
invoke();
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method webApplicationExceptionTest.
/*
* @testName: webApplicationExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:922; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: throws WebApplicationException thrown by wrapped method.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void webApplicationExceptionTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.WEBAPPLICATIONEXCEPTION);
Response fake = builder.build();
addProviders(fake);
invoke();
try {
getResponseBody();
} catch (Exception e) {
WebApplicationException we = assertCause(e, WebApplicationException.class, "Found unexpected exception", e);
assertNotNull(we.getResponse(), "WebApplicationException.getResponse is null");
Response response = we.getResponse();
String entity = response.getEntity().toString();
assertEqualsInt(Status.CONFLICT.getStatusCode(), response.getStatus(), "Unexcpected status returned from WebApplicationException.getResponse", response.getStatus());
assertEquals(TemplateInterceptorBody.ENTITY2, entity, "Found unexpected body content from WebApplicationException.getResponse", entity);
logMsg("found expected WebApplicationException", we);
return;
}
fault("Expected WebApplicationException not found");
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method setPropertyNullTest.
/*
* @testName: setPropertyNullTest
*
* @assertion_ids: JAXRS:JAVADOC:913; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: If a null value is passed, the effect is the same as
* calling the removeProperty(String) method.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void setPropertyNullTest() throws Fault {
ResponseBuilder builder = createResponse(ContextOperation.SETPROPERTYNULL);
Response fake = builder.build();
addProviders(fake);
setProperty(Property.SEARCH_STRING, TemplateInterceptorBody.NULL);
invoke();
}
use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getAnnotationsTest.
/*
* @testName: getAnnotationsTest
*
* @assertion_ids: JAXRS:JAVADOC:903; JAXRS:JAVADOC:920; JAXRS:SPEC:85;
*
* @test_Strategy: Get an array of the annotations formally declared on the
* artifact that initiated the intercepted entity provider invocation. The
* annotations are not on client reader.
*
* ReaderInterceptor.aroundReadFrom If abortWith is invoked, execution is
* aborted
*/
@Test
public void getAnnotationsTest() throws Fault {
Annotation[] annotations = ContextOperation.class.getAnnotations();
ResponseBuilder builder = createResponse(ContextOperation.GETANNOTATIONS);
Response fake = builder.entity(TemplateInterceptorBody.ENTITY, annotations).build();
addProviders(fake);
for (Annotation a : annotations) setProperty(Property.UNEXPECTED_RESPONSE_MATCH, a.annotationType().getName());
invoke();
}
Aggregations