use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method constructorStringResponseThrowsIAETest.
/*
* @testName: constructorStringResponseThrowsIAETest
*
* @assertion_ids: JAXRS:JAVADOC:1071;
*
* @test_Strategy: Construct a new internal server error exception.
* java.lang.IllegalArgumentException - in case the status code set in the
* response is not HTTP 500.
*/
@Test
public void constructorStringResponseThrowsIAETest() throws Fault {
for (Status status : Status.values()) if (status != STATUS)
try {
Response response = Response.status(status).build();
InternalServerErrorException e = new InternalServerErrorException(MESSAGE, response);
fault("No exception has 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:322;
*
* @test_Strategy: Construct a new internal server error exception.
* java.lang.IllegalArgumentException - in case the status code set in the
* response is not HTTP 500.
*/
@Test
public void constructorResponseThrowableThrowsExceptionTest() throws Fault {
for (Status status : Status.values()) if (status != STATUS)
try {
Response response = Response.status(status).build();
InternalServerErrorException e = new InternalServerErrorException(response, new Throwable());
fault("No exception has 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 constructorStringResponseThrowsIAETest.
/*
* @testName: constructorStringResponseThrowsIAETest
*
* @assertion_ids: JAXRS:JAVADOC:1067;
*
* @test_Strategy: Construct a new "forbidden" exception.
* java.lang.IllegalArgumentException - in case the status code set in the
* response is not HTTP 403.
*/
@Test
public void constructorStringResponseThrowsIAETest() throws Fault {
for (Status status : Status.values()) if (status != STATUS)
try {
Response response = Response.status(status).build();
ForbiddenException e = new ForbiddenException(MESSAGE, response);
fault("IllegalArgumentException has not been thrown; 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 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()) {
Response response = Response.status(status).build();
StatusType info = response.getStatusInfo();
assertTrue(info.getStatusCode() == status.getStatusCode(), "#getStatusInfo returned unexpected value" + info);
}
logMsg("#getStatusInfo returned expected StatusTypes");
}
use of jakarta.ws.rs.core.Response.Status in project jaxrs-api by eclipse-ee4j.
the class JAXRSClientIT method statusValueOfTest.
/*
* @testName: statusValueOfTest
*
* @assertion_ids: JAXRS:JAVADOC:165; JAXRS:JAVADOC:166;
*
* @test_Strategy: Call Response.Status.valueOf(String) verify that correct
* Status is returned
*/
@Test
public void statusValueOfTest() throws Fault {
VerificationResult result = new VerificationResult();
Response.Status tmp = null;
for (int i = 0; i < resp_status.length; i++) {
try {
tmp = Response.Status.valueOf(status[i].replace(" ", "_").replace("-", "_").toUpperCase());
} catch (Exception ex) {
result.message.append("Exception thrown with status name ").append(status[i]).append(newline);
result.message.append(ex.getMessage());
result.pass = false;
}
if (!tmp.equals(resp_status[i])) {
result.pass = false;
result.message.append("Status.toString() failed with ").append(resp_status[i]).append(newline);
result.message.append("expecting ").append(resp_status[i]).append(", got ").append(tmp).append(newline);
}
}
logMsg(result);
assertResultTrue(result);
}
Aggregations