use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetSerializationPolicyLogsAndReturnsDefaultIfModuleBaseURLIsNotPrefixByAppContextPath.
@Test
public void testGetSerializationPolicyLogsAndReturnsDefaultIfModuleBaseURLIsNotPrefixByAppContextPath() {
String moduleBaseURL = "http://localhost:8080/pentaho/content/data-access/resources/gwt/";
String appContextPath = "/sixtaho";
String strongName = "ABCDF12345";
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
SerializationPolicy defaultPolicyMock = mock(SerializationPolicy.class);
try (MockedStatic<AbstractGwtRpc> rpc = Mockito.mockStatic(AbstractGwtRpc.class)) {
rpc.when(AbstractGwtRpc::getDefaultSerializationPolicy).thenReturn(defaultPolicyMock);
TestGwtRpc gwtRpcSpy = spy(new TestGwtRpc(httpRequestMock));
doReturn(appContextPath).when(gwtRpcSpy).getAppContextPath();
SerializationPolicy result = gwtRpcSpy.getSerializationPolicy(moduleBaseURL, strongName);
assertEquals(defaultPolicyMock, result);
verify(loggerMock).error(anyString());
}
}
use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testLoadSerializationPolicyFromInputStreamSuccessfully.
// endregion
// region static loadSerializationPolicyFromInputStream
@Test
public void testLoadSerializationPolicyFromInputStreamSuccessfully() {
String serializationPolicyFileName = "ABCDF12345.gwt.rpc";
InputStream inputStreamMock = mock(InputStream.class);
ThrowingSupplier<InputStream, IOException> inputStreamSupplier = () -> inputStreamMock;
SerializationPolicy policyMock = mock(SerializationPolicy.class);
try (MockedStatic<SerializationPolicyLoader> serializationPolicyLoader = Mockito.mockStatic(SerializationPolicyLoader.class)) {
serializationPolicyLoader.when(() -> SerializationPolicyLoader.loadFromStream(inputStreamMock, null)).thenReturn(policyMock);
SerializationPolicy result = AbstractGwtRpc.loadSerializationPolicyFromInputStream(inputStreamSupplier, serializationPolicyFileName);
assertEquals(policyMock, result);
}
}
use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetSerializationPolicyCallsLoadSerializationPolicyReturnsDefaultIfItReturnsNull.
@Test
public void testGetSerializationPolicyCallsLoadSerializationPolicyReturnsDefaultIfItReturnsNull() {
String moduleBaseURL = "http://localhost:8080/pentaho/content/data-access/resources/gwt/";
String appContextPath = "/pentaho";
String moduleContextPath = "/content/data-access/resources/gwt/";
String strongName = "ABCDF12345";
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
SerializationPolicy defaultPolicyMock = mock(SerializationPolicy.class);
try (MockedStatic<AbstractGwtRpc> rpc = Mockito.mockStatic(AbstractGwtRpc.class)) {
rpc.when(AbstractGwtRpc::getDefaultSerializationPolicy).thenReturn(defaultPolicyMock);
TestGwtRpc gwtRpcSpy = spy(new TestGwtRpc(httpRequestMock));
doReturn(appContextPath).when(gwtRpcSpy).getAppContextPath();
doReturn(null).when(gwtRpcSpy).loadSerializationPolicy(moduleContextPath, strongName);
SerializationPolicy result = gwtRpcSpy.getSerializationPolicy(moduleBaseURL, strongName);
assertEquals(defaultPolicyMock, result);
}
}
use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetSerializationPolicyLogsAndReturnsDefaultIfModuleBaseURLIsNotValidURL.
@Test
public void testGetSerializationPolicyLogsAndReturnsDefaultIfModuleBaseURLIsNotValidURL() {
String moduleBaseURL = "ht123_-tp:localhost:8080/pentaho/content/data-access/resources/gwt/";
String strongName = "ABCDF12345";
HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
SerializationPolicy defaultPolicyMock = mock(SerializationPolicy.class);
try (MockedStatic<AbstractGwtRpc> rpc = Mockito.mockStatic(AbstractGwtRpc.class)) {
rpc.when(AbstractGwtRpc::getDefaultSerializationPolicy).thenReturn(defaultPolicyMock);
TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
SerializationPolicy result = gwtRpc.getSerializationPolicy(moduleBaseURL, strongName);
assertEquals(defaultPolicyMock, result);
verify(loggerMock).error(nullable(String.class), any(MalformedURLException.class));
}
}
use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetDefaultSerializationPolicyDelegatesToRPCClass.
// endregion
// region static getDefaultSerializationPolicy
@Test
public void testGetDefaultSerializationPolicyDelegatesToRPCClass() {
SerializationPolicy defaultPolicyMock = mock(SerializationPolicy.class);
try (MockedStatic<RPC> rpc = Mockito.mockStatic(RPC.class)) {
rpc.when(RPC::getDefaultSerializationPolicy).thenReturn(defaultPolicyMock);
SerializationPolicy result = AbstractGwtRpc.getDefaultSerializationPolicy();
assertEquals(defaultPolicyMock, result);
}
}
Aggregations