@Test public void testCommand() throws IOException, InterruptedException, ExecutionException { MockWebServer server = new MockWebServer(); String content = "Hello world"; MockResponse response = new MockResponse() .setResponseCode(200) .setHeader("Content-type", "text/plain") .setBody(content); server.enqueue(response); server.enqueue(response); server.enqueue(response); server.play(); HttpResourceGroup group = Ribbon.createHttpResourceGroup("myclient", ClientOptions.create() .withMaxAutoRetriesNextServer(3) .withReadTimeout(300000) .withConfigurationBasedServerList("localhost:12345, localhost:10092, localhost:" + server.getPort())); HttpRequestTemplate<ByteBuf> template = group.newTemplateBuilder("test", ByteBuf.class) .withUriTemplate("/") .withMethod("GET") .build(); RibbonRequest<ByteBuf> request = template.requestBuilder().build(); String result = request.execute().toString(Charset.defaultCharset()); assertEquals(content, result); ByteBuf raw = request.execute(); result = raw.toString(Charset.defaultCharset()); raw.release(); assertEquals(content, result); result = request.queue().get().toString(Charset.defaultCharset()); 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);  }