use of org.pentaho.platform.web.gwt.rpc.impl.GwtRpcUtil in project pentaho-platform by pentaho.
the class AbstractGwtRpcTest method testGetSerializationPolicyReplacesWebAppRootToken.
@Test
public void testGetSerializationPolicyReplacesWebAppRootToken() {
String moduleBaseURL = "http://localhost:8080/WEBAPP_ROOT//content/data-access/resources/gwt/";
String modulePath = "/WEBAPP_ROOT//content/data-access/resources/gwt/";
String modulePathScrubbed = "/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 policyMock = mock(SerializationPolicy.class);
TestGwtRpc gwtRpcSpy = spy(new TestGwtRpc(httpRequestMock));
doReturn(appContextPath).when(gwtRpcSpy).getAppContextPath();
doReturn(policyMock).when(gwtRpcSpy).loadSerializationPolicy(moduleContextPath, strongName);
try (MockedStatic<GwtRpcUtil> gwtRpcUtil = Mockito.mockStatic(GwtRpcUtil.class)) {
gwtRpcUtil.when(() -> GwtRpcUtil.scrubWebAppRoot(modulePath, appContextPath)).thenReturn(modulePathScrubbed);
gwtRpcSpy.getSerializationPolicy(moduleBaseURL, strongName);
gwtRpcUtil.verify(() -> GwtRpcUtil.scrubWebAppRoot(modulePath, appContextPath));
GwtRpcUtil.scrubWebAppRoot(modulePath, appContextPath);
}
}
Aggregations