Add code formatting guidelines

Add 'eclipse' folder containing Eclipse code
formatter configuration and instructions how to use
 it.

Update rule for join_wrapped_lines

 - Set to `false`

Resolves #930

Update README

Address review comments
This commit is contained in:
Ilayaperumal Gopinathan
2017-05-12 21:34:39 +05:30
committed by Marius Bogoevici
parent 9632546f03
commit bd002e4aaf
159 changed files with 1770 additions and 1283 deletions

View File

@@ -22,8 +22,8 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
/**
* Maintains a map between (output) channels and messages received (in FIFO order). To be injected in tests that
* can then run assertions on the enqueued messages.
* Maintains a map between (output) channels and messages received (in FIFO order). To be
* injected in tests that can then run assertions on the enqueued messages.
*
* @author Eric Bottard
*/

View File

@@ -25,7 +25,8 @@ import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.MapPropertySource;
/**
* An {@link EnvironmentPostProcessor} that sets some configuration properties for {@link TestSupportBinder}.
* An {@link EnvironmentPostProcessor} that sets some configuration properties for
* {@link TestSupportBinder}.
*
* @author Ilayaperumal Gopinathan
*/

View File

@@ -36,9 +36,12 @@ import org.springframework.messaging.SubscribableChannel;
import org.springframework.util.Assert;
/**
* A minimal binder that<ul>
* <li>does nothing about binding consumers, leaving the channel as-is, so that a test author can interact with it directly,</li>
* <li>registers a queue channel on the producer side, so that it is easy to assert what is received.</li>
* A minimal binder that
* <ul>
* <li>does nothing about binding consumers, leaving the channel as-is, so that a test
* author can interact with it directly,</li>
* <li>registers a queue channel on the producer side, so that it is easy to assert what
* is received.</li>
* </ul>
*
* @author Eric Bottard
@@ -53,12 +56,14 @@ public class TestSupportBinder implements Binder<MessageChannel, ConsumerPropert
private final ConcurrentMap<String, MessageChannel> messageChannels = new ConcurrentHashMap<>();
@Override
public Binding<MessageChannel> bindConsumer(String name, String group, MessageChannel inboundBindTarget, ConsumerProperties properties) {
public Binding<MessageChannel> bindConsumer(String name, String group, MessageChannel inboundBindTarget,
ConsumerProperties properties) {
return new TestBinding(inboundBindTarget, null);
}
/**
* Registers a single subscriber to the channel, that enqueues messages for later retrieval and assertion in tests.
* Registers a single subscriber to the channel, that enqueues messages for later
* retrieval and assertion in tests.
*/
@Override
public Binding<MessageChannel> bindProducer(String name, MessageChannel outboundBindTarget,
@@ -99,7 +104,8 @@ public class TestSupportBinder implements Binder<MessageChannel, ConsumerPropert
}
private void unregister(MessageChannel channel) {
Assert.notNull(results.remove(channel), "Trying to unregister a mapping for an unknown channel [" + channel + "]");
Assert.notNull(results.remove(channel),
"Trying to unregister a mapping for an unknown channel [" + channel + "]");
}
@Override

View File

@@ -27,12 +27,12 @@ import org.springframework.core.Ordered;
import org.springframework.messaging.MessageChannel;
/**
* Installs the {@link TestSupportBinder} and exposes {@link TestSupportBinder.MessageCollectorImpl} to be injected in
* tests.
* Installs the {@link TestSupportBinder} and exposes
* {@link TestSupportBinder.MessageCollectorImpl} to be injected in tests.
*
* Note that this auto-configuration has higher priority than regular binder configuration, so adding
* this on the classpath in test scope is sufficient to have support kick in and replace all binders
* with the test binder.
* Note that this auto-configuration has higher priority than regular binder
* configuration, so adding this on the classpath in test scope is sufficient to have
* support kick in and replace all binders with the test binder.
*
* @author Eric Bottard
* @author Marius Bogoevici
@@ -47,7 +47,8 @@ public class TestSupportBinderAutoConfiguration {
public BinderFactory binderFactory() {
return new BinderFactory() {
@Override
public <T> Binder<T, ? extends ConsumerProperties, ? extends ProducerProperties> getBinder(String configurationName, Class<? extends T> bindableType) {
public <T> Binder<T, ? extends ConsumerProperties, ? extends ProducerProperties> getBinder(
String configurationName, Class<? extends T> bindableType) {
return (Binder<T, ? extends ConsumerProperties, ? extends ProducerProperties>) messageChannelBinder;
}
};

View File

@@ -33,7 +33,9 @@ import org.springframework.messaging.Message;
/**
* A Hamcrest Matcher meant to be used in conjunction with {@link TestSupportBinder}.
*
* <p>Expected usage is of the form (with appropriate static imports):
* <p>
* Expected usage is of the form (with appropriate static imports):
*
* <pre>
* public class TransformProcessorApplicationTests {
*
@@ -51,7 +53,8 @@ import org.springframework.messaging.Message;
* assertThat(messageCollector.forChannel(processor.output()), receivesPayloadThat(is("hellofoo")).within(10));
* }
*
* }</pre>
* }
* </pre>
* </p>
*
* @author Eric Bottard
@@ -62,12 +65,12 @@ public class MessageQueueMatcher<T> extends BaseMatcher<BlockingQueue<Message<?>
private final long timeout;
private final TimeUnit unit;
private Extractor<Message<?>, T> extractor;
private Map<BlockingQueue<Message<?>>, T> actuallyReceived = new HashMap<>();
private final TimeUnit unit;
public MessageQueueMatcher(Matcher<T> delegate, long timeout, TimeUnit unit, Extractor<Message<?>, T> extractor) {
this.delegate = delegate;
this.timeout = timeout;
@@ -75,6 +78,28 @@ public class MessageQueueMatcher<T> extends BaseMatcher<BlockingQueue<Message<?>
this.extractor = extractor;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <P> MessageQueueMatcher<P> receivesMessageThat(Matcher<Message<P>> messageMatcher) {
return new MessageQueueMatcher(messageMatcher, 5, TimeUnit.SECONDS,
new Extractor<Message<P>, Message<P>>("a message that ") {
@Override
public Message<P> apply(Message<P> m) {
return m;
}
});
}
@SuppressWarnings({ "unchecked", "rawtypes" })
public static <P> MessageQueueMatcher<P> receivesPayloadThat(Matcher<P> payloadMatcher) {
return new MessageQueueMatcher(payloadMatcher, 5, TimeUnit.SECONDS,
new Extractor<Message<P>, P>("a message whose payload ") {
@Override
public P apply(Message<P> m) {
return m.getPayload();
}
});
}
@Override
public boolean matches(Object item) {
@SuppressWarnings("unchecked")
@@ -129,28 +154,9 @@ public class MessageQueueMatcher<T> extends BaseMatcher<BlockingQueue<Message<?>
description.appendText("Channel to receive ").appendDescriptionOf(extractor).appendDescriptionOf(delegate);
}
@SuppressWarnings({"unchecked", "rawtypes"})
public static <P> MessageQueueMatcher<P> receivesMessageThat(Matcher<Message<P>> messageMatcher) {
return new MessageQueueMatcher(messageMatcher, 5, TimeUnit.SECONDS, new Extractor<Message<P>, Message<P>>("a message that ") {
@Override
public Message<P> apply(Message<P> m) {
return m;
}
});
}
@SuppressWarnings({"unchecked", "rawtypes"})
public static <P> MessageQueueMatcher<P> receivesPayloadThat(Matcher<P> payloadMatcher) {
return new MessageQueueMatcher(payloadMatcher, 5, TimeUnit.SECONDS, new Extractor<Message<P>, P>("a message whose payload ") {
@Override
public P apply(Message<P> m) {
return m.getPayload();
}
});
}
/**
* A transformation to be applied to a received message before asserting, <i>e.g.</i> to only inspect the payload.
* A transformation to be applied to a received message before asserting, <i>e.g.</i>
* to only inspect the payload.
*/
public static abstract class Extractor<R, T> implements Function<R, T>, SelfDescribing {
@@ -166,6 +172,4 @@ public class MessageQueueMatcher<T> extends BaseMatcher<BlockingQueue<Message<?>
}
}
}

View File

@@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Marius Bogoevici
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = AggregateWithBeanTest.ChainedProcessors.class, properties = {"server.port=-1"})
@SpringBootTest(classes = AggregateWithBeanTest.ChainedProcessors.class, properties = { "server.port=-1" })
public class AggregateWithBeanTest {
@Autowired

View File

@@ -43,8 +43,9 @@ public class AggregateWithMainTest {
@Test
public void testAggregateApplication() throws InterruptedException {
// emulate a main method
ConfigurableApplicationContext context = new AggregateApplicationBuilder(TestSupportBinderAutoConfiguration.class).from(UppercaseProcessor.class)
.namespace("upper").to(SuffixProcessor.class).namespace("suffix").run();
ConfigurableApplicationContext context = new AggregateApplicationBuilder(
TestSupportBinderAutoConfiguration.class).from(UppercaseProcessor.class)
.namespace("upper").to(SuffixProcessor.class).namespace("suffix").run();
AggregateApplication aggregateAccessor = context.getBean(AggregateApplication.class);
MessageCollector messageCollector = context.getBean(MessageCollector.class);
@@ -61,7 +62,6 @@ public class AggregateWithMainTest {
@EnableBinding(Processor.class)
public static class UppercaseProcessor {
@Autowired
Processor processor;

View File

@@ -36,11 +36,12 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Integration test that validates that {@link org.springframework.cloud.stream.test.binder.TestSupportBinder} applies
* Integration test that validates that
* {@link org.springframework.cloud.stream.test.binder.TestSupportBinder} applies
* correctly.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = ExampleTest.MyProcessor.class, properties = {"server.port=-1"})
@SpringBootTest(classes = ExampleTest.MyProcessor.class, properties = { "server.port=-1" })
@DirtiesContext
public class ExampleTest {
@@ -63,7 +64,6 @@ public class ExampleTest {
assertThat(received.getPayload()).isEqualTo("hello world");
}
@SpringBootApplication
@EnableBinding(Processor.class)
public static class MyProcessor {