use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method responseMustRevalidateDirective_isIgnored.
@Test
public void responseMustRevalidateDirective_isIgnored() throws Exception {
cacheControlDirectives.add("must-revalidate");
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertSame(reply1, reply2);
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method requestWithOnlyIfCachedOption_usesCache.
@Test
public void requestWithOnlyIfCachedOption_usesCache() {
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT.withOption(SafeMethodCachingInterceptor.ONLY_IF_CACHED_CALL_OPTION, true), message);
assertSame(reply1, reply2);
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method requestWithNoCacheOptionSkipsCache.
@Test
public void requestWithNoCacheOptionSkipsCache() {
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT.withOption(SafeMethodCachingInterceptor.NO_CACHE_CALL_OPTION, true), message);
HelloReply reply3 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertNotEquals(reply1, reply2);
assertSame(reply1, reply3);
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method safeCallsAreCachedWithCopiedMethodDescriptor.
@Test
public void safeCallsAreCachedWithCopiedMethodDescriptor() {
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod.toBuilder().build(), CallOptions.DEFAULT, message);
assertSame(reply1, reply2);
}
use of io.grpc.examples.helloworld.HelloReply in project grpc-java by grpc.
the class SafeMethodCachingInterceptorTest method cacheHit_doesNotResetExpiration.
@Test
public void cacheHit_doesNotResetExpiration() throws Exception {
cacheControlDirectives.add("max-age=1");
HelloReply reply1 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
HelloReply reply2 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
sleepAtLeast(1001);
HelloReply reply3 = ClientCalls.blockingUnaryCall(channelToUse, safeGreeterSayHelloMethod, CallOptions.DEFAULT, message);
assertSame(reply1, reply2);
assertNotEquals(reply1, reply3);
Truth.assertThat(cache.internalCache).hasSize(1);
Truth.assertThat(cache.removedKeys).hasSize(1);
}
Aggregations