use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorStringResponseThrowableThrowsIAETest.
/*
* @testName: constructorStringResponseThrowableThrowsIAETest
*
* @assertion_ids: JAXRS:JAVADOC:1065;
*
* @test_Strategy: Construct a new client error exception.
* java.lang.IllegalArgumentException - in case the response status code is
* not from the Response.Status.Family.CLIENT_ERROR status code family.
*/
@Test
public void constructorStringResponseThrowableThrowsIAETest() throws Fault {
for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
try {
Response response = Response.status(status).build();
ClientErrorException e = new ClientErrorException(MESSAGE, response, new Throwable());
fault("IllegalArgumentException has not been thrown for status", status, "; exception", e);
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException has been thrown as expected for status", status);
}
}
use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorStringIntThrowsIAETest.
/*
* @testName: constructorStringIntThrowsIAETest
*
* @assertion_ids: JAXRS:JAVADOC:1061;
*
* @test_Strategy: Construct a new client error exception.
* java.lang.IllegalArgumentException - in case the status code is not a valid
* HTTP status code or if it is not from the
* Response.Status.Family.CLIENT_ERROR status code family.
*/
@Test
public void constructorStringIntThrowsIAETest() throws Fault {
for (Status status : Status.values()) if (Status.Family.familyOf(status.getStatusCode()) != Status.Family.CLIENT_ERROR)
try {
ClientErrorException e = new ClientErrorException(MESSAGE, status.getStatusCode());
fault("IllegalArgumentException has not been thrown for status", status, "; exception", e);
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException has been thrown as expected for status", status);
}
}
use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorResponseThrowableThrowsExceptionTest.
/*
* @testName: constructorResponseThrowableThrowsExceptionTest
*
* @assertion_ids: JAXRS:JAVADOC:308;
*
* @test_Strategy: Construct a new bad client request exception. throws -
* java.lang.IllegalArgumentException - in case the status code set in the
* response is not HTTP 400.
*/
@Test
public void constructorResponseThrowableThrowsExceptionTest() throws Fault {
for (Status status : Status.values()) if (status != STATUS)
try {
Response response = Response.status(status).build();
BadRequestException e = new BadRequestException(response, new Throwable());
fault("Exception has been not been thrown for response with status", status, "; exception", e);
} catch (IllegalArgumentException e) {
logMsg("IllegalArgumentException has been thrown for status", status, "as expected");
}
}
use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method headTest.
// ------------------------------------------------------------------
// ---------------------------HEAD-----------------------------------
// ------------------------------------------------------------------
/*
* @testName: headTest
*
* @assertion_ids: JAXRS:JAVADOC:557;
*
* @test_Strategy: Invoke HTTP HEAD method for the current request
* synchronously.
*/
@Test
public void headTest() throws Fault {
SyncInvoker sync = createSyncInvokerForMethod("head");
Response response = sync.head();
Status status = Status.fromStatusCode(response.getStatus());
assertTrue(status == Status.OK || status == Status.NO_CONTENT, "Incorrect status for head received");
}
use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method getStatusInfoTest.
/*
* @testName: getStatusInfoTest
*
* @assertion_ids: JAXRS:JAVADOC:858;
*
* @test_Strategy: Get the complete status information associated with the
* response.
*/
@Test
public void getStatusInfoTest() throws Fault {
for (Status status : Status.values()) {
setProperty(Property.STATUS_CODE, getStatusCode(status));
Response response = invokePost("statusinfo", status.name());
StatusType info = response.getStatusInfo();
assertEqualsInt(info.getStatusCode(), status.getStatusCode(), "#getStatusInfo returned unexpected value", info);
}
logMsg("#getStatusInfo returned expected StatusTypes");
}
Aggregations