use of com.netflix.ribbon.RibbonTransportFactory in project ribbon by Netflix.
the class ShutDownTest method testLifeCycleShutdown.
@Test
public void testLifeCycleShutdown() throws Exception {
final AtomicBoolean shutDownCalled = new AtomicBoolean(false);
final HttpClient<ByteBuf, ByteBuf> client = new HttpClient<ByteBuf, ByteBuf>() {
@Override
public Observable<HttpClientResponse<ByteBuf>> submit(HttpClientRequest<ByteBuf> request) {
return null;
}
@Override
public Observable<HttpClientResponse<ByteBuf>> submit(HttpClientRequest<ByteBuf> request, ClientConfig config) {
return null;
}
@Override
public Observable<ObservableConnection<HttpClientResponse<ByteBuf>, HttpClientRequest<ByteBuf>>> connect() {
return null;
}
@Override
public void shutdown() {
shutDownCalled.set(true);
}
@Override
public String name() {
return "SampleMovieService";
}
@Override
public Subscription subscribe(MetricEventsListener<? extends ClientMetricsEvent<?>> listener) {
return null;
}
};
RibbonTransportFactory transportFactory = new RibbonTransportFactory(ClientConfigFactory.DEFAULT) {
@Override
public HttpClient<ByteBuf, ByteBuf> newHttpClient(IClientConfig config) {
return client;
}
};
HttpResourceGroup.Builder groupBuilder = HttpResourceGroup.Builder.newBuilder("SampleMovieService", ClientConfigFactory.DEFAULT, transportFactory);
HttpResourceGroup group = groupBuilder.build();
SampleMovieService service = RibbonDynamicProxy.newInstance(SampleMovieService.class, group);
ProxyLifeCycle proxyLifeCycle = (ProxyLifeCycle) service;
proxyLifeCycle.shutdown();
assertTrue(proxyLifeCycle.isShutDown());
assertTrue(shutDownCalled.get());
}
use of com.netflix.ribbon.RibbonTransportFactory in project ribbon by Netflix.
the class RxMovieProxyExampleTest method testTransportFactoryWithInjection.
@Test
public void testTransportFactoryWithInjection() {
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
}
});
RibbonTransportFactory transportFactory = injector.getInstance(RibbonTransportFactory.class);
HttpClient<ByteBuf, ByteBuf> client = transportFactory.newHttpClient("myClient");
IClientConfig config = ((LoadBalancingHttpClient) client).getClientConfig();
assertEquals("MyConfig", config.getNameSpace());
}
Aggregations