use of com.google.gwt.user.server.rpc.RPCServletUtils in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetRequestPayloadFirstTime.
// endregion
// region Request Payload
@Test
public void testGetRequestPayloadFirstTime() {
String requestPayload = "REQUEST_PAYLOAD";
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
try (MockedStatic<RPCServletUtils> rpcServletUtils = Mockito.mockStatic(RPCServletUtils.class)) {
rpcServletUtils.when(() -> RPCServletUtils.readContentAsGwtRpc(any())).thenReturn(requestPayload);
String result = gwtRpc.getRequestPayload();
assertEquals(requestPayload, result);
}
}
use of com.google.gwt.user.server.rpc.RPCServletUtils in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetRequestPayloadSecondTimeIsCached.
@Test
public void testGetRequestPayloadSecondTimeIsCached() throws ServletException, IOException {
String requestPayload = "REQUEST_PAYLOAD";
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
try (MockedStatic<RPCServletUtils> rpcServletUtils = Mockito.mockStatic(RPCServletUtils.class)) {
rpcServletUtils.when(() -> RPCServletUtils.readContentAsGwtRpc(any())).thenReturn(requestPayload);
gwtRpc.getRequestPayload();
String result = gwtRpc.getRequestPayload();
assertEquals(requestPayload, result);
rpcServletUtils.verify(() -> RPCServletUtils.readContentAsGwtRpc(any()));
RPCServletUtils.readContentAsGwtRpc(any());
}
}
use of com.google.gwt.user.server.rpc.RPCServletUtils in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetRequestPayloadLogsAndWrapsThrownIOException.
@Test
public void testGetRequestPayloadLogsAndWrapsThrownIOException() {
IOException error = mock(IOException.class);
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
try (MockedStatic<RPCServletUtils> rpcServletUtils = Mockito.mockStatic(RPCServletUtils.class)) {
rpcServletUtils.when(() -> RPCServletUtils.readContentAsGwtRpc(any())).thenThrow(error);
try {
gwtRpc.getRequestPayload();
fail();
} catch (GwtRpcProxyException ex) {
assertEquals(error, ex.getCause());
verify(loggerMock).error(nullable(String.class), eq(error));
}
}
}
use of com.google.gwt.user.server.rpc.RPCServletUtils in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetRequestPayloadLogsAndWrapsThrownServletException.
@Test
public void testGetRequestPayloadLogsAndWrapsThrownServletException() {
ServletException error = mock(ServletException.class);
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
try (MockedStatic<RPCServletUtils> rpcServletUtils = Mockito.mockStatic(RPCServletUtils.class)) {
rpcServletUtils.when(() -> RPCServletUtils.readContentAsGwtRpc(any())).thenThrow(error);
try {
gwtRpc.getRequestPayload();
fail();
} catch (GwtRpcProxyException ex) {
assertEquals(error, ex.getCause());
verify(loggerMock).error(nullable(String.class), eq(error));
}
}
}
Aggregations