use of org.springframework.cloud.stream.binding.BindingService in project spring-cloud-stream by spring-cloud.
the class BinderAwareChannelResolverTests method propertyPassthrough.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void propertyPassthrough() {
Map<String, BindingProperties> bindings = new HashMap<>();
BindingProperties genericProperties = new BindingProperties();
genericProperties.setContentType("text/plain");
bindings.put("foo", genericProperties);
this.bindingServiceProperties.setBindings(bindings);
Binder binder = mock(Binder.class);
Binder binder2 = mock(Binder.class);
BinderFactory mockBinderFactory = Mockito.mock(BinderFactory.class);
Binding<MessageChannel> fooBinding = Mockito.mock(Binding.class);
Binding<MessageChannel> barBinding = Mockito.mock(Binding.class);
when(binder.bindProducer(matches("foo"), any(DirectChannel.class), any(ProducerProperties.class))).thenReturn(fooBinding);
when(binder2.bindProducer(matches("bar"), any(DirectChannel.class), any(ProducerProperties.class))).thenReturn(barBinding);
when(mockBinderFactory.getBinder(null, DirectChannel.class)).thenReturn(binder);
when(mockBinderFactory.getBinder("someTransport", DirectChannel.class)).thenReturn(binder2);
BindingService bindingService = new BindingService(bindingServiceProperties, mockBinderFactory);
BinderAwareChannelResolver resolver = new BinderAwareChannelResolver(bindingService, this.bindingTargetFactory, new DynamicDestinationsBindable());
resolver.setBeanFactory(context.getBeanFactory());
SubscribableChannel resolved = (SubscribableChannel) resolver.resolveDestination("foo");
verify(binder).bindProducer(eq("foo"), any(MessageChannel.class), any(ProducerProperties.class));
assertThat(resolved).isSameAs(context.getBean("foo"));
this.context.close();
}
Aggregations