Search in sources :

Example 6 with RedirectionException

use of jakarta.ws.rs.RedirectionException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringResponseTest.

/*
   * @testName: constructorStringResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1097; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new redirection exception.
   * java.lang.IllegalArgumentException - in case the response status code is
   * not from the Response.Status.Family.REDIRECTION status code family.
   * 
   * getResponse
   */
@Test
public void constructorStringResponseTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        RedirectionException e = new RedirectionException(MESSAGE, buildResponse(status));
        assertResponse(e, status, HOST);
        assertMessage(e);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) RedirectionException(jakarta.ws.rs.RedirectionException) Test(org.junit.jupiter.api.Test)

Example 7 with RedirectionException

use of jakarta.ws.rs.RedirectionException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringStatusUriThrowsIAETest.

/*
   * @testName: constructorStringStatusUriThrowsIAETest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1095;
   * 
   * @test_Strategy: Construct a new redirection exception.
   * java.lang.IllegalArgumentException - in case the status code is null or is
   * not from Response.Status.Family.REDIRECTION status code family.
   */
@Test
public void constructorStringStatusUriThrowsIAETest() throws Fault {
    for (Status status : getStatusesOutsideFamily()) {
        try {
            RedirectionException e = new RedirectionException(MESSAGE, status, LOCATION);
            fault("IllegalArgumentException has not been thrown for status", status, "; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown as expected for status", status);
        }
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) RedirectionException(jakarta.ws.rs.RedirectionException) Test(org.junit.jupiter.api.Test)

Example 8 with RedirectionException

use of jakarta.ws.rs.RedirectionException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorResponseTest.

/*
   * @testName: constructorResponseTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:350; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new redirection exception.
   * java.lang.IllegalArgumentException - in case the response status code is
   * not from the Response.Status.Family.REDIRECTION status code family.
   * 
   * getResponse
   */
@Test
public void constructorResponseTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        RedirectionException e = new RedirectionException(buildResponse(status));
        assertResponse(e, status, HOST);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) RedirectionException(jakarta.ws.rs.RedirectionException) Test(org.junit.jupiter.api.Test)

Example 9 with RedirectionException

use of jakarta.ws.rs.RedirectionException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorStringStatusUriTest.

/*
   * @testName: constructorStringStatusUriTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:1095; JAXRS:JAVADOC:347; JAXRS:JAVADOC:12;
   * 
   * @test_Strategy: Construct a new redirection exception.
   * java.lang.IllegalArgumentException - in case the status code is null or is
   * not from Response.Status.Family.REDIRECTION status code family.
   * 
   * Get the redirection response location.
   * 
   * getResponse
   */
@Test
public void constructorStringStatusUriTest() throws Fault {
    for (Status status : getStatusesFromFamily()) {
        RedirectionException e = new RedirectionException(MESSAGE, status, LOCATION);
        assertResponse(e, status);
        assertLocation(e, LOCATION);
        assertMessage(e);
    }
}
Also used : Status(jakarta.ws.rs.core.Response.Status) RedirectionException(jakarta.ws.rs.RedirectionException) Test(org.junit.jupiter.api.Test)

Example 10 with RedirectionException

use of jakarta.ws.rs.RedirectionException in project jaxrs-api by eclipse-ee4j.

the class JAXRSClientIT method constructorIntNotValidStatusThrowsExceptionTest.

/*
   * @testName: constructorIntNotValidStatusThrowsExceptionTest
   * 
   * @assertion_ids: JAXRS:JAVADOC:349;
   * 
   * @test_Strategy: Construct a new server error exception.
   * java.lang.IllegalArgumentException - in case the status code is not a valid
   * HTTP status code or is not from Response.Status.Family.REDIRECTION status
   * code family.
   */
@Test
public void constructorIntNotValidStatusThrowsExceptionTest() throws Fault {
    for (int status : new int[] { -1, Integer.MAX_VALUE, Integer.MIN_VALUE }) {
        try {
            RedirectionException e = new RedirectionException(status, LOCATION);
            fault("IllegalArgumentException has not been thrown for status", status, "; exception", e);
        } catch (IllegalArgumentException e) {
            logMsg("IllegalArgumentException has been thrown as expected for status", status);
        }
    }
}
Also used : RedirectionException(jakarta.ws.rs.RedirectionException) Test(org.junit.jupiter.api.Test)

Aggregations

RedirectionException (jakarta.ws.rs.RedirectionException)14 Test (org.junit.jupiter.api.Test)14 Status (jakarta.ws.rs.core.Response.Status)10