TestBinding polishing

This commit is contained in:
Mark Fisher
2016-02-22 17:44:37 -05:00
parent 2fa9cda89c
commit 9c3eef49da
3 changed files with 18 additions and 20 deletions

View File

@@ -53,7 +53,7 @@ public class TestSupportBinder implements Binder<MessageChannel> {
@Override
public Binding<MessageChannel> bindConsumer(String name, String group, MessageChannel inboundBindTarget, Properties properties) {
return new TestBinding(name, inboundBindTarget, messageCollector);
return new TestBinding(inboundBindTarget, messageCollector);
}
/**
@@ -69,7 +69,7 @@ public class TestSupportBinder implements Binder<MessageChannel> {
}
});
this.messageChannels.put(name, outboundBindTarget);
return new TestBinding(name, outboundBindTarget, messageCollector);
return new TestBinding(outboundBindTarget, messageCollector);
}
public MessageCollector messageCollector() {
@@ -85,7 +85,7 @@ public class TestSupportBinder implements Binder<MessageChannel> {
*
* @author Eric Bottard
*/
private static class MessageCollectorImpl implements MessageCollector{
private static class MessageCollectorImpl implements MessageCollector {
private final Map<MessageChannel, BlockingQueue<Message<?>>> results = new HashMap<>();
@@ -111,15 +111,13 @@ public class TestSupportBinder implements Binder<MessageChannel> {
/**
* @author Marius Bogoevici
*/
public static class TestBinding implements Binding<MessageChannel> {
private static class TestBinding implements Binding<MessageChannel> {
private final MessageChannel target;
private final MessageCollectorImpl messageCollector;
private String name;
public TestBinding(String name, MessageChannel target, MessageCollectorImpl messageCollector) {
this.name = name;
private TestBinding(MessageChannel target, MessageCollectorImpl messageCollector) {
this.target = target;
this.messageCollector = messageCollector;
}

View File

@@ -17,9 +17,10 @@
package org.springframework.cloud.stream.binder;
/**
* Represents a binding between an input or output and an adapter endpoint that connects via a Binder. The binding
* could be for a consumer or a producer. A consumer binding represents a connection from an adapter to an
* input. A producer binding represents a connection from an output to an adapter.
* Represents a binding between an input or output and an adapter endpoint that connects via a
* Binder. The binding could be for a consumer or a producer. A consumer binding represents a
* connection from an adapter to an input. A producer binding represents a connection from an
* output to an adapter.
*
* @author Jennifer Hickey
* @author Mark Fisher
@@ -28,10 +29,12 @@ package org.springframework.cloud.stream.binder;
* @see org.springframework.cloud.stream.annotation.EnableBinding
*/
public interface Binding<T> {
/**
* Unbinds the target component represented by this instance and stops any active components. Implementations must
* be idempotent. After this method is invoked, the target is not expected to receive any message, this instance
* should be discarded, and a new Binding should be created instead.
* Unbinds the target component represented by this instance and stops any active components.
* Implementations must be idempotent. After this method is invoked, the target is not expected
* to receive any messages; this instance should be discarded, and a new Binding should be
* created instead.
*/
void unbind();
}

View File

@@ -164,7 +164,7 @@ public class BinderAwareChannelResolverTests {
}
DirectHandler directHandler = new DirectHandler(inboundBindTarget);
destinations.get(name).subscribe(directHandler);
return new TestBinding(inboundBindTarget, name, directHandler);
return new TestBinding(name, directHandler);
}
@@ -178,19 +178,16 @@ public class BinderAwareChannelResolverTests {
DirectHandler directHandler = new DirectHandler(destinations.get(name));
// for test purposes we can assume it is a SubscribableChannel
((SubscribableChannel) outboundBindTarget).subscribe(directHandler);
return new TestBinding(outboundBindTarget, name, directHandler);
return new TestBinding(name, directHandler);
}
private class TestBinding implements Binding<MessageChannel> {
private final MessageChannel target;
private final String name;
private final DirectHandler directHandler;
public TestBinding(MessageChannel outboundChannel, String name, DirectHandler directHandler) {
this.target = outboundChannel;
private TestBinding(String name, DirectHandler directHandler) {
this.name = name;
this.directHandler = directHandler;
}