Search in sources :

Example 26 with SerializationPolicy

use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.

the class AbstractGwtRpcTest method testGetSerializationPolicyUsesCacheIfSet.

// endregion
// region getSerializationPolicy
@Test
public void testGetSerializationPolicyUsesCacheIfSet() {
    String moduleBaseURL = "http://localhost:8080/pentaho/content/data-access/resources/gwt/";
    String strongName = "ABCDF12345";
    HttpServletRequest httpRequestMock = mock(HttpServletRequest.class);
    SerializationPolicy policyMock = mock(SerializationPolicy.class);
    IGwtRpcSerializationPolicyCache cache = mock(IGwtRpcSerializationPolicyCache.class);
    when(cache.getSerializationPolicy(eq(moduleBaseURL), eq(strongName), any())).thenReturn(policyMock);
    TestGwtRpc gwtRpc = new TestGwtRpc(httpRequestMock);
    gwtRpc.setSerializationPolicyCache(cache);
    SerializationPolicy result = gwtRpc.getSerializationPolicy(moduleBaseURL, strongName);
    assertEquals(policyMock, result);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString)

Example 27 with SerializationPolicy

use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.

the class GwtRpcSerializationPolicyCacheTest method testSerializationPolicyIsNewAndCreated.

// region Helpers
private static void testSerializationPolicyIsNewAndCreated(IGwtRpcSerializationPolicyCache cache, String moduleBaseURL, String strongName, SerializationPolicy policy) {
    SerializationPolicyProvider sourceProviderMock = createProviderMock(moduleBaseURL, strongName, policy);
    SerializationPolicy result = cache.getSerializationPolicy(moduleBaseURL, strongName, sourceProviderMock);
    assertEquals(policy, result);
    verify(sourceProviderMock, times(1)).getSerializationPolicy(moduleBaseURL, strongName);
}
Also used : SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) SerializationPolicyProvider(com.google.gwt.user.server.rpc.SerializationPolicyProvider)

Example 28 with SerializationPolicy

use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.

the class GwtRpcSerializationPolicyCacheTest method testGetSerializationPolicyWithNullKeysIsSupported.

// endregion
@Test
public void testGetSerializationPolicyWithNullKeysIsSupported() {
    GwtRpcSerializationPolicyCache cache = new GwtRpcSerializationPolicyCache();
    SerializationPolicy policy = mock(SerializationPolicy.class);
    testSerializationPolicyIsNewAndCreated(cache, null, null, policy);
    testSerializationPolicyIsInCache(cache, null, null, policy);
}
Also used : SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) Test(org.junit.Test)

Example 29 with SerializationPolicy

use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.

the class GwtRpcSerializationPolicyCacheTest method testSerializationPolicyIsInCache.

private static void testSerializationPolicyIsInCache(IGwtRpcSerializationPolicyCache cache, String moduleBaseURL, String strongName, SerializationPolicy policy) {
    SerializationPolicyProvider sourceProviderMock = createProviderMock(moduleBaseURL, strongName, policy);
    SerializationPolicy result = cache.getSerializationPolicy(moduleBaseURL, strongName, sourceProviderMock);
    assertEquals(policy, result);
    verify(sourceProviderMock, times(0)).getSerializationPolicy(any(), any());
}
Also used : SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) SerializationPolicyProvider(com.google.gwt.user.server.rpc.SerializationPolicyProvider)

Example 30 with SerializationPolicy

use of com.google.gwt.user.server.rpc.SerializationPolicy in project pentaho-platform by pentaho.

the class GwtRpcSerializationPolicyCacheTest method testGetSerializationPolicyWithMultipleKeysMaintainsCache.

@Test
public void testGetSerializationPolicyWithMultipleKeysMaintainsCache() {
    GwtRpcSerializationPolicyCache cache = new GwtRpcSerializationPolicyCache();
    SerializationPolicy policy1 = mock(SerializationPolicy.class);
    String moduleBaseURL1 = "url1";
    String strongName1 = "abc1";
    SerializationPolicy policy2 = mock(SerializationPolicy.class);
    String moduleBaseURL2 = "url2";
    String strongName2 = "abc2";
    SerializationPolicy policy3 = mock(SerializationPolicy.class);
    String moduleBaseURL3 = "url3";
    String strongName3 = "abc3";
    testSerializationPolicyIsNewAndCreated(cache, moduleBaseURL1, strongName1, policy1);
    testSerializationPolicyIsNewAndCreated(cache, moduleBaseURL2, strongName2, policy2);
    testSerializationPolicyIsNewAndCreated(cache, moduleBaseURL3, strongName3, policy3);
    testSerializationPolicyIsInCache(cache, moduleBaseURL1, strongName1, policy1);
    testSerializationPolicyIsInCache(cache, moduleBaseURL2, strongName2, policy2);
    testSerializationPolicyIsInCache(cache, moduleBaseURL3, strongName3, policy3);
}
Also used : SerializationPolicy(com.google.gwt.user.server.rpc.SerializationPolicy) IGwtRpcSerializationPolicyCache(org.pentaho.platform.web.gwt.rpc.IGwtRpcSerializationPolicyCache) Test(org.junit.Test)

Aggregations

SerializationPolicy (com.google.gwt.user.server.rpc.SerializationPolicy)34 HttpServletRequest (javax.servlet.http.HttpServletRequest)18 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)16 IOException (java.io.IOException)11 InputStream (java.io.InputStream)11 Test (org.junit.Test)9 RPC (com.google.gwt.user.server.rpc.RPC)5 RPCRequest (com.google.gwt.user.server.rpc.RPCRequest)5 SerializationPolicyLoader (com.google.gwt.user.server.rpc.SerializationPolicyLoader)5 Method (java.lang.reflect.Method)5 URL (java.net.URL)5 PentahoSystem (org.pentaho.platform.engine.core.system.PentahoSystem)5 PluginUtil (org.pentaho.platform.plugin.services.pluginmgr.PluginUtil)5 MalformedURLException (java.net.MalformedURLException)4 GwtRpcProxyException (org.pentaho.platform.web.servlet.GwtRpcProxyException)4 NonNull (edu.umd.cs.findbugs.annotations.NonNull)3 ParseException (java.text.ParseException)3 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)3 SerializationException (com.google.gwt.user.client.rpc.SerializationException)2 SerializationPolicyProvider (com.google.gwt.user.server.rpc.SerializationPolicyProvider)2