Implement remainder of Spring Boot Checkstyle code rules

Fixes #532

Implements most of the remaining rules from Spring Boot, except JavaDoc + a few additional ones
This commit is contained in:
Marius Bogoevici
2016-05-12 15:55:03 -04:00
parent bbe5b3ee56
commit 18dc0a707d
97 changed files with 546 additions and 365 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.config;
import org.junit.Test;
@@ -42,16 +43,19 @@ import static org.junit.Assert.assertThat;
@SpringApplicationConfiguration({ContentTypeOutboundSourceTests.TestSource.class})
public class ContentTypeOutboundSourceTests {
@Autowired @Bindings(TestSource.class)
@Autowired
@Bindings(TestSource.class)
private Source testSource;
@Autowired
private BinderFactory binderFactory;
@Test
@SuppressWarnings("unchecked")
public void testMessageHeaderWhenNoExplicitContentTypeOnMessage() throws Exception {
testSource.output().send(MessageBuilder.withPayload("{\"message\":\"Hi\"}").build());
Message<String> received = (Message<String>) ((TestSupportBinder) binderFactory.getBinder(null)).messageCollector().forChannel(testSource.output()).poll();
Message<String> received = (Message<String>) ((TestSupportBinder) binderFactory.getBinder(null))
.messageCollector().forChannel(testSource.output()).poll();
assertThat(received.getHeaders().get(MessageHeaders.CONTENT_TYPE).toString(), equalTo("application/json"));
assertThat(received.getPayload(), equalTo("{\"message\":\"Hi\"}"));
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright 2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.config;
import java.util.List;
@@ -39,7 +55,8 @@ import static org.junit.Assert.assertTrue;
@SpringApplicationConfiguration(CustomMessageConverterTests.TestSource.class)
public class CustomMessageConverterTests {
@Autowired @Bindings(TestSource.class)
@Autowired
@Bindings(TestSource.class)
private Source testSource;
@Autowired

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.config;
import java.util.concurrent.TimeUnit;
@@ -54,7 +55,7 @@ public class ErrorChannelTests {
@Test
public void testErrorChannelBinding() throws Exception {
Message<?> message = (Message<?>) ((TestSupportBinder) binderFactory.getBinder(null)).messageCollector().forChannel(errorChannel).poll(10, TimeUnit.SECONDS);
Message<?> message = ((TestSupportBinder) binderFactory.getBinder(null)).messageCollector().forChannel(errorChannel).poll(10, TimeUnit.SECONDS);
Assert.isTrue(message instanceof ErrorMessage, "Message should be an instance of ErrorMessage");
Assert.isTrue(message.getPayload() instanceof MessagingException, "Message payload should be an instance" +
"of MessagingException");

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.cloud.stream.config;
import java.util.List;
@@ -54,7 +55,8 @@ import static org.junit.Assert.assertTrue;
@SpringApplicationConfiguration({MessageChannelConfigurerTests.TestSink.class})
public class MessageChannelConfigurerTests {
@Autowired @Bindings(TestSink.class)
@Autowired
@Bindings(TestSink.class)
private Sink testSink;
@Autowired
@@ -95,7 +97,7 @@ public class MessageChannelConfigurerTests {
assertTrue(objectMapper == this.objectMapper);
}
}
@EnableBinding(Sink.class)
@EnableAutoConfiguration
@PropertySource("classpath:/org/springframework/cloud/stream/config/channel/sink-channel-configurers.properties")