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);
}
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);
}
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);
}
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());
}
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);
}
Aggregations