use of org.springframework.cloud.stream.binder.AbstractBinder in project spring-cloud-stream by spring-cloud.
the class RetryTemplateTests method testSpecificCustomRetryTemplate.
@SuppressWarnings("rawtypes")
@Test
public void testSpecificCustomRetryTemplate() throws Exception {
ApplicationContext context = new SpringApplicationBuilder(SpecificCustomRetryTemplateConfiguration.class).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false", "--spring.cloud.stream.bindings.processor-in-0.consumer.retry-template-name=retryTemplateTwo");
RetryTemplate retryTemplateTwo = context.getBean("retryTemplateTwo", RetryTemplate.class);
BindingServiceProperties bindingServiceProperties = context.getBean(BindingServiceProperties.class);
ConsumerProperties consumerProperties = bindingServiceProperties.getConsumerProperties("processor-in-0");
AbstractBinder binder = context.getBean(AbstractBinder.class);
Method m = AbstractBinder.class.getDeclaredMethod("buildRetryTemplate", ConsumerProperties.class);
m.setAccessible(true);
RetryTemplate retryTemplate = (RetryTemplate) m.invoke(binder, consumerProperties);
assertThat(retryTemplate).isEqualTo(retryTemplateTwo);
}
use of org.springframework.cloud.stream.binder.AbstractBinder in project spring-cloud-stream by spring-cloud.
the class RetryTemplateTests method testSingleCustomRetryTemplate.
@SuppressWarnings("rawtypes")
@Test
public void testSingleCustomRetryTemplate() throws Exception {
ApplicationContext context = new SpringApplicationBuilder(SingleCustomRetryTemplateConfiguration.class).web(WebApplicationType.NONE).run("--spring.jmx.enabled=false");
AbstractBinder binder = context.getBean(AbstractBinder.class);
Field f = AbstractBinder.class.getDeclaredField("consumerBindingRetryTemplates");
f.setAccessible(true);
@SuppressWarnings("unchecked") Map<String, RetryTemplate> consumerBindingRetryTemplates = (Map<String, RetryTemplate>) f.get(binder);
assertThat(consumerBindingRetryTemplates).hasSize(1);
}
Aggregations