Search in sources :

Example 1 with ErrorResponse

use of fish.payara.ejb.http.protocol.ErrorResponse in project Payara by payara.

the class EjbOverHttpResourceTest method invoke_ErrorMalformedArguments.

@Test
public void invoke_ErrorMalformedArguments() {
    Object argValues = isJavaObjectSerialisation() ? new byte[] { 42 } : Collections.singletonMap("foo", "bar");
    ErrorResponse response = invokeExpectError(mediaType, EJB_NAME, "add", new String[] { int.class.getName(), int.class.getName() }, argValues);
    assertEquals("javax.ws.rs.InternalServerErrorException", response.exceptionType);
    assertEquals("Failed to de-serialise method arguments from binary representation.", response.message);
}
Also used : ErrorResponse(fish.payara.ejb.http.protocol.ErrorResponse) Test(org.junit.Test)

Example 2 with ErrorResponse

use of fish.payara.ejb.http.protocol.ErrorResponse in project Payara by payara.

the class EjbOverHttpResourceTest method invokeExpectError.

private static ErrorResponse invokeExpectError(String mediaType, String jndiName, String method, String[] argTypes, Object argValues) {
    Entity<InvokeMethodRequest> entity = invokeBody(mediaType, jndiName, method, argTypes, argValues);
    try (Response response = target.path("jndi/invoke").request(mediaType).buildPost(entity).invoke()) {
        assertNotEquals(Status.OK.getStatusCode(), response.getStatus());
        if (mediaType.equals(response.getMediaType().toString())) {
            return response.readEntity(ErrorResponse.class);
        }
        fail("Unexpected error response in media type " + response.getMediaType() + ": " + response.readEntity(String.class));
        return null;
    }
}
Also used : Response(javax.ws.rs.core.Response) ErrorResponse(fish.payara.ejb.http.protocol.ErrorResponse) LookupResponse(fish.payara.ejb.http.protocol.LookupResponse) InvokeMethodResponse(fish.payara.ejb.http.protocol.InvokeMethodResponse) InvokeMethodRequest(fish.payara.ejb.http.protocol.InvokeMethodRequest)

Example 3 with ErrorResponse

use of fish.payara.ejb.http.protocol.ErrorResponse in project Payara by payara.

the class EjbOverHttpResourceTest method invoke_ErrorClassNotFound.

@Test
public void invoke_ErrorClassNotFound() {
    ErrorResponse response = invokeExpectError(mediaType, EJB_NAME, "add", new String[] { "undefined", "int" }, pack(1, 2));
    assertThat(response.message, CoreMatchers.endsWith("java.lang.ClassNotFoundException: undefined"));
    assertNotNull(response.cause);
}
Also used : ErrorResponse(fish.payara.ejb.http.protocol.ErrorResponse) Test(org.junit.Test)

Example 4 with ErrorResponse

use of fish.payara.ejb.http.protocol.ErrorResponse in project Payara by payara.

the class EjbOverHttpResourceTest method lookup_ErrorNoGlobalJndiName.

@Test
public void lookup_ErrorNoGlobalJndiName() {
    ErrorResponse response = lookupExpectError(mediaType, "java:app/myapp/" + RemoteCalculator.class.getName());
    assertEquals("javax.naming.NamingException", response.exceptionType);
    assertEquals("Only global names are supported but got: java:app/myapp/fish.payara.ejb.endpoint.EjbOverHttpResourceTest$RemoteCalculator", response.message);
    assertNull(response.cause);
}
Also used : ErrorResponse(fish.payara.ejb.http.protocol.ErrorResponse) Test(org.junit.Test)

Example 5 with ErrorResponse

use of fish.payara.ejb.http.protocol.ErrorResponse in project Payara by payara.

the class EjbOverHttpResourceTest method invoke_ErrorNoSuchEjb.

@Test
public void invoke_ErrorNoSuchEjb() {
    ErrorResponse response = invokeExpectError(mediaType, EJB_NAME + "x", "add", new String[] { int.class.getName(), int.class.getName() }, pack(1, 2));
    assertEquals("javax.naming.NamingException", response.exceptionType);
    assertEquals("No such bean: java:global/myapp/RemoteCalculatorx", response.message);
    assertNull(response.cause);
}
Also used : ErrorResponse(fish.payara.ejb.http.protocol.ErrorResponse) Test(org.junit.Test)

Aggregations

ErrorResponse (fish.payara.ejb.http.protocol.ErrorResponse)12 Test (org.junit.Test)10 InvokeMethodResponse (fish.payara.ejb.http.protocol.InvokeMethodResponse)2 InvokeMethodRequest (fish.payara.ejb.http.protocol.InvokeMethodRequest)1 LookupResponse (fish.payara.ejb.http.protocol.LookupResponse)1 Response (javax.ws.rs.core.Response)1