|
|
@ -234,32 +234,32 @@ class CachingOperationInvokerTests {
|
|
|
|
given(target.invoke(contextV2)).willReturn(expectedV2);
|
|
|
|
given(target.invoke(contextV2)).willReturn(expectedV2);
|
|
|
|
given(target.invoke(contextV3)).willReturn(expectedV3);
|
|
|
|
given(target.invoke(contextV3)).willReturn(expectedV3);
|
|
|
|
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
|
|
|
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
|
|
|
Object response = invoker.invoke(contextV2);
|
|
|
|
Object responseV2 = invoker.invoke(contextV2);
|
|
|
|
assertThat(response).isSameAs(expectedV2);
|
|
|
|
assertThat(responseV2).isSameAs(expectedV2);
|
|
|
|
verify(target, times(1)).invoke(contextV2);
|
|
|
|
verify(target, times(1)).invoke(contextV2);
|
|
|
|
Object cachedResponse = invoker.invoke(contextV3);
|
|
|
|
Object responseV3 = invoker.invoke(contextV3);
|
|
|
|
assertThat(cachedResponse).isNotSameAs(response);
|
|
|
|
assertThat(responseV3).isNotSameAs(responseV2);
|
|
|
|
verify(target, times(1)).invoke(contextV3);
|
|
|
|
verify(target, times(1)).invoke(contextV3);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
void targetInvokedWithDifferentWebServerNamespace() {
|
|
|
|
void targetInvokedWithDifferentWebServerNamespace() {
|
|
|
|
OperationInvoker target = mock(OperationInvoker.class);
|
|
|
|
OperationInvoker target = mock(OperationInvoker.class);
|
|
|
|
Object expectedV2 = new Object();
|
|
|
|
Object expectedServer = new Object();
|
|
|
|
Object expectedV3 = new Object();
|
|
|
|
Object expectedManagement = new Object();
|
|
|
|
InvocationContext contextV2 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
|
|
|
InvocationContext contextServer = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
|
|
|
new WebServerNamespaceArgumentResolver(WebServerNamespace.SERVER));
|
|
|
|
new WebServerNamespaceArgumentResolver(WebServerNamespace.SERVER));
|
|
|
|
InvocationContext contextV3 = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
|
|
|
InvocationContext contextManagement = new InvocationContext(mock(SecurityContext.class), Collections.emptyMap(),
|
|
|
|
new WebServerNamespaceArgumentResolver(WebServerNamespace.MANAGEMENT));
|
|
|
|
new WebServerNamespaceArgumentResolver(WebServerNamespace.MANAGEMENT));
|
|
|
|
given(target.invoke(contextV2)).willReturn(expectedV2);
|
|
|
|
given(target.invoke(contextServer)).willReturn(expectedServer);
|
|
|
|
given(target.invoke(contextV3)).willReturn(expectedV3);
|
|
|
|
given(target.invoke(contextManagement)).willReturn(expectedManagement);
|
|
|
|
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
|
|
|
CachingOperationInvoker invoker = new CachingOperationInvoker(target, CACHE_TTL);
|
|
|
|
Object response = invoker.invoke(contextV2);
|
|
|
|
Object responseServer = invoker.invoke(contextServer);
|
|
|
|
assertThat(response).isSameAs(expectedV2);
|
|
|
|
assertThat(responseServer).isSameAs(expectedServer);
|
|
|
|
verify(target, times(1)).invoke(contextV2);
|
|
|
|
verify(target, times(1)).invoke(contextServer);
|
|
|
|
Object cachedResponse = invoker.invoke(contextV3);
|
|
|
|
Object responseManagement = invoker.invoke(contextManagement);
|
|
|
|
assertThat(cachedResponse).isNotSameAs(response);
|
|
|
|
assertThat(responseManagement).isNotSameAs(responseServer);
|
|
|
|
verify(target, times(1)).invoke(contextV3);
|
|
|
|
verify(target, times(1)).invoke(contextManagement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static class MonoOperationInvoker implements OperationInvoker {
|
|
|
|
private static class MonoOperationInvoker implements OperationInvoker {
|
|
|
|