@Test public void testCacheMiss() throws IOException, InterruptedException { MockWebServer server = new MockWebServer(); String content = "Hello world"; server.enqueue(new MockResponse() .setResponseCode(200) .setHeader("Content-type", "text/plain") .setBody(content)); server.play(); HttpResourceGroup group = Ribbon.createHttpResourceGroup("myclient", ClientOptions.create() .withConfigurationBasedServerList("localhost:" + server.getPort()) .withMaxAutoRetriesNextServer(1)); final String cacheKey = "somekey"; HttpRequestTemplate<ByteBuf> template = group.newTemplateBuilder("test") .withCacheProvider(cacheKey, new CacheProvider<ByteBuf>(){ @Override public Observable<ByteBuf> get(String key, Map<String, Object> vars) { return Observable.error(new Exception("Cache miss again")); } }) .withMethod("GET") .withUriTemplate("/").build(); RibbonRequest<ByteBuf> request = template .requestBuilder().build(); String result = toStringBlocking(request); assertEquals(content, result); }
public static HttpResourceGroup createHttpResourceGroup(String name) { return factory.createHttpResourceGroup(name); }
Ribbon { public static HttpResourceGroup createHttpResourceGroup(String name) { return factory.createHttpResourceGroup(name); } }
Ribbon { public static HttpResourceGroup createHttpResourceGroup(String name) { return factory.createHttpResourceGroup(name); } private  Ribbon(); }
Ribbon { public static HttpResourceGroup createHttpResourceGroup(String name) { return factory.createHttpResourceGroup(name); } private  Ribbon(); static Builder createHttpResourceGroupBuilder(String name); static HttpResourceGroup createHttpResourceGroup(String name); static HttpResourceGroup createHttpResourceGroup(String name, ClientOptions options); static T from(Class<T> contract); }
Ribbon { public static HttpResourceGroup createHttpResourceGroup(String name) { return factory.createHttpResourceGroup(name); } private  Ribbon(); static Builder createHttpResourceGroupBuilder(String name); static HttpResourceGroup createHttpResourceGroup(String name); static HttpResourceGroup createHttpResourceGroup(String name, ClientOptions options); static T from(Class<T> contract);  }