Search in sources :

Example 1 with GwtRpcUtil

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);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) GwtRpcUtil(org.pentaho.platform.web.gwt.rpc.impl.GwtRpcUtil)

Aggregations

SerializationPolicy (com.google.gwt.user.server.rpc.SerializationPolicy)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 GwtRpcUtil (org.pentaho.platform.web.gwt.rpc.impl.GwtRpcUtil)1