org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient Java Examples

The following examples show how to use org.springframework.cloud.loadbalancer.blocking.client.BlockingLoadBalancerClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FeignLoadBalancerAutoConfigurationTests.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldInstantiateDefaultFeignBlockingLoadBalancerClientWhenHttpClientDisabled() {
	ConfigurableApplicationContext context = initContext(
			"feign.httpclient.enabled=false");
	assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
	assertLoadBalanced(context, Client.Default.class);
}
 
Example #2
Source File: FeignLoadBalancerAutoConfigurationTests.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldInstantiateHttpFeignClientWhenEnabled() {
	ConfigurableApplicationContext context = initContext(
			"spring.cloud.loadbalancer.ribbon.enabled=false");
	assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
	assertLoadBalanced(context, ApacheHttpClient.class);
}
 
Example #3
Source File: FeignLoadBalancerAutoConfigurationTests.java    From spring-cloud-openfeign with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldInstantiateOkHttpFeignClientWhenEnabled() {
	ConfigurableApplicationContext context = initContext(
			"feign.httpclient.enabled=false", "feign.okhttp.enabled=true");
	assertThatOneBeanPresent(context, BlockingLoadBalancerClient.class);
	assertLoadBalanced(context, OkHttpClient.class);
}
 
Example #4
Source File: TracingFeignObjectWrapperTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void should_wrap_feign_loadbalancer_client() {
	Client delegate = mock(Client.class);
	BlockingLoadBalancerClient loadBalancerClient = mock(
			BlockingLoadBalancerClient.class);
	when(beanFactory.getBean(LoadBalancerClient.class))
			.thenReturn(loadBalancerClient);

	Object wrapped = traceFeignObjectWrapper
			.wrap(new FeignBlockingLoadBalancerClient(delegate, loadBalancerClient));

	assertThat(wrapped).isInstanceOf(TraceFeignBlockingLoadBalancerClient.class);
}
 
Example #5
Source File: TracingFeignObjectWrapperTests.java    From spring-cloud-sleuth with Apache License 2.0 5 votes vote down vote up
@Test
public void should_wrap_subclass_of_feign_loadbalancer_client() {
	Client delegate = mock(Client.class);
	BlockingLoadBalancerClient loadBalancerClient = mock(
			BlockingLoadBalancerClient.class);
	when(beanFactory.getBean(LoadBalancerClient.class))
			.thenReturn(loadBalancerClient);

	Object wrapped = traceFeignObjectWrapper.wrap(
			new TestFeignBlockingLoadBalancerClient(delegate, loadBalancerClient));

	assertThat(wrapped).isInstanceOf(TraceFeignBlockingLoadBalancerClient.class);

}
 
Example #6
Source File: BlockingLoadBalancerClientAutoConfiguration.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(LoadBalancerClientFactory.class)
@ConditionalOnMissingBean
public LoadBalancerClient blockingLoadBalancerClient(
		LoadBalancerClientFactory loadBalancerClientFactory) {
	return new BlockingLoadBalancerClient(loadBalancerClientFactory);
}
 
Example #7
Source File: BlockingLoadBalancerClientAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@Test
public void worksWithoutSpringWeb() {
	applicationContextRunner
			.withClassLoader(new FilteredClassLoader(RestTemplate.class))
			.run(context -> {
				assertThat(context).doesNotHaveBean(BlockingLoadBalancerClient.class);
			});
}
 
Example #8
Source File: FeignClientFactoryTests.java    From spring-cloud-openfeign with Apache License 2.0 4 votes vote down vote up
@Bean
BlockingLoadBalancerClient loadBalancerClient() {
	return new BlockingLoadBalancerClient(new LoadBalancerClientFactory());
}
 
Example #9
Source File: SeataFeignBlockingLoadBalancerClient.java    From spring-cloud-alibaba with Apache License 2.0 4 votes vote down vote up
public SeataFeignBlockingLoadBalancerClient(Client delegate,
		BlockingLoadBalancerClient loadBalancerClient,
		SeataFeignObjectWrapper seataFeignObjectWrapper) {
	super((Client) seataFeignObjectWrapper.wrap(delegate), loadBalancerClient);
}
 
Example #10
Source File: TracingFeignObjectWrapperTests.java    From spring-cloud-sleuth with Apache License 2.0 4 votes vote down vote up
TestFeignBlockingLoadBalancerClient(Client delegate,
		BlockingLoadBalancerClient loadBalancerClient) {
	super(delegate, loadBalancerClient);
}
 
Example #11
Source File: OkHttpLoadBalancerInterceptor.java    From spring-cloud-square with Apache License 2.0 4 votes vote down vote up
public OkHttpLoadBalancerInterceptor(BlockingLoadBalancerClient client) {
	this.client = client;
}
 
Example #12
Source File: OkHttpLoadBalancerAutoConfiguration.java    From spring-cloud-square with Apache License 2.0 4 votes vote down vote up
@Bean
public OkHttpLoadBalancerInterceptor okHttpLoadBalancerInterceptor(BlockingLoadBalancerClient client) {
	return new OkHttpLoadBalancerInterceptor(client);
}
 
Example #13
Source File: DependencyFeignClientAutoConfiguration.java    From spring-cloud-zookeeper with Apache License 2.0 4 votes vote down vote up
public DependencyFeignClientAutoConfiguration(@Autowired(required = false) FeignBlockingLoadBalancerClient feignLoadBalancerClient,
		ZookeeperDependencies zookeeperDependencies, BlockingLoadBalancerClient loadBalancerClient) {
	this.feignLoadBalancerClient = feignLoadBalancerClient;
	this.zookeeperDependencies = zookeeperDependencies;
	this.loadBalancerClient = loadBalancerClient;
}
 
Example #14
Source File: BlockingLoadBalancerClientAutoConfigurationTests.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Test
public void beansCreatedNormally() {
	applicationContextRunner.run(
			ctxt -> assertThat(ctxt).hasSingleBean(BlockingLoadBalancerClient.class));
}
 
Example #15
Source File: CachingServiceInstanceListSupplierTests.java    From spring-cloud-commons with Apache License 2.0 4 votes vote down vote up
@Bean
BlockingLoadBalancerClient blockingLoadBalancerClient(
		LoadBalancerClientFactory loadBalancerClientFactory) {
	return new BlockingLoadBalancerClient(loadBalancerClientFactory);
}