Enable ModifierOrderCheck Checkstyle rule (#2673)
* Enable ModifierOrderCheck Checkstyle rule * Fix violations for `static` and `abstract` modifier * Remove redundant code in the `TcpNioConnection` * Mark `connectionFactoryName` as `@Nullable` in the `TcpConnectionSupport` ctor and its inheritors * Fix some smells according IDEA suggestions in the affected classes * This should fix some Sonar smells as well * * Fix `HeaderMapperTests` * * Polishing `TcpConnection` code style and fix Javdocs
This commit is contained in:
committed by
Gary Russell
parent
a01d09f0f1
commit
93d7c58b64
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.integration.file.config;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -120,7 +121,7 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
@Autowired
|
||||
MessageFlushPredicate predicate;
|
||||
|
||||
private volatile static int adviceCalled;
|
||||
private static volatile int adviceCalled;
|
||||
|
||||
@Test
|
||||
public void simpleAdapter() {
|
||||
@@ -237,10 +238,10 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
if (testFile.exists()) {
|
||||
testFile.delete();
|
||||
}
|
||||
usageChannel.send(new GenericMessage<String>("Initial File Content:"));
|
||||
usageChannel.send(new GenericMessage<String>("String content:"));
|
||||
usageChannel.send(new GenericMessage<byte[]>("byte[] content:".getBytes()));
|
||||
usageChannel.send(new GenericMessage<File>(new File("test/input.txt")));
|
||||
usageChannel.send(new GenericMessage<>("Initial File Content:"));
|
||||
usageChannel.send(new GenericMessage<>("String content:"));
|
||||
usageChannel.send(new GenericMessage<>("byte[] content:".getBytes()));
|
||||
usageChannel.send(new GenericMessage<>(new File("test/input.txt")));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -259,10 +260,10 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
if (testFile.exists()) {
|
||||
testFile.delete();
|
||||
}
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<String>("Initial File Content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<String>("String content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<byte[]>("byte[] content:".getBytes()));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<File>(new File("test/input.txt")));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<>("Initial File Content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<>("String content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<>("byte[] content:".getBytes()));
|
||||
adapterUsageWithAppendAndAppendNewLineTrue.send(new GenericMessage<>(new File("test/input.txt")));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -277,10 +278,10 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
if (testFile.exists()) {
|
||||
testFile.delete();
|
||||
}
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<String>("Initial File Content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<String>("String content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<byte[]>("byte[] content:".getBytes()));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<File>(new File("test/input.txt")));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<>("Initial File Content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<>("String content:"));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<>("byte[] content:".getBytes()));
|
||||
adapterUsageWithAppendAndAppendNewLineFalse.send(new GenericMessage<>(new File("test/input.txt")));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -288,20 +289,20 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterUsageWithFailMode() throws Exception {
|
||||
public void adapterUsageWithFailMode() {
|
||||
|
||||
File testFile = new File("test/fileToFail.txt");
|
||||
if (testFile.exists()) {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
usageChannelWithFailMode.send(new GenericMessage<String>("Initial File Content:"));
|
||||
usageChannelWithFailMode.send(new GenericMessage<>("Initial File Content:"));
|
||||
|
||||
try {
|
||||
usageChannelWithFailMode.send(new GenericMessage<String>("String content:"));
|
||||
usageChannelWithFailMode.send(new GenericMessage<>("String content:"));
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
assertTrue(e.getMessage().contains("The destination file already exists at"));
|
||||
assertThat(e.getMessage(), containsString("The destination file already exists at"));
|
||||
testFile.delete();
|
||||
return;
|
||||
}
|
||||
@@ -320,8 +321,8 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
usageChannelWithIgnoreMode.send(new GenericMessage<String>("Initial File Content:"));
|
||||
usageChannelWithIgnoreMode.send(new GenericMessage<String>("String content:"));
|
||||
usageChannelWithIgnoreMode.send(new GenericMessage<>("Initial File Content:"));
|
||||
usageChannelWithIgnoreMode.send(new GenericMessage<>("String content:"));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -347,8 +348,8 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
String bString = bBuffer.toString();
|
||||
|
||||
for (int i = 0; i < 1; i++) {
|
||||
usageChannelConcurrent.send(new GenericMessage<String>(aString));
|
||||
usageChannelConcurrent.send(new GenericMessage<String>(bString));
|
||||
usageChannelConcurrent.send(new GenericMessage<>(aString));
|
||||
usageChannelConcurrent.send(new GenericMessage<>(bString));
|
||||
}
|
||||
|
||||
assertTrue(this.fileWriteLatch.await(10, TimeUnit.SECONDS));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package org.springframework.integration.file.config;
|
||||
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
@@ -84,11 +86,10 @@ public class FileOutboundGatewayParserTests {
|
||||
@Autowired
|
||||
EventDrivenConsumer gatewayWithAppendNewLine;
|
||||
|
||||
private volatile static int adviceCalled;
|
||||
private static volatile int adviceCalled;
|
||||
|
||||
@Test
|
||||
public void checkOrderedGateway() throws Exception {
|
||||
|
||||
public void checkOrderedGateway() {
|
||||
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(ordered);
|
||||
FileWritingMessageHandler handler = (FileWritingMessageHandler)
|
||||
gatewayAccessor.getPropertyValue("handler");
|
||||
@@ -109,13 +110,13 @@ public class FileOutboundGatewayParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutboundGatewayWithDirectoryExpression() throws Exception {
|
||||
public void testOutboundGatewayWithDirectoryExpression() {
|
||||
FileWritingMessageHandler handler =
|
||||
TestUtils.getPropertyValue(gatewayWithDirectoryExpression, "handler", FileWritingMessageHandler.class);
|
||||
assertEquals("'build/foo'",
|
||||
TestUtils.getPropertyValue(handler, "destinationDirectoryExpression", Expression.class)
|
||||
.getExpressionString());
|
||||
handler.handleMessage(new GenericMessage<String>("foo"));
|
||||
handler.handleMessage(new GenericMessage<>("foo"));
|
||||
assertEquals(1, adviceCalled);
|
||||
}
|
||||
|
||||
@@ -130,7 +131,6 @@ public class FileOutboundGatewayParserTests {
|
||||
*/
|
||||
@Test
|
||||
public void gatewayWithIgnoreMode() throws Exception {
|
||||
|
||||
final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
messagingTemplate.setDefaultDestination(this.gatewayWithIgnoreModeChannel);
|
||||
|
||||
@@ -141,9 +141,9 @@ public class FileOutboundGatewayParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
|
||||
|
||||
Message<?> replyMessage = messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
|
||||
Message<?> replyMessage = messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -166,7 +166,6 @@ public class FileOutboundGatewayParserTests {
|
||||
*/
|
||||
@Test
|
||||
public void gatewayWithFailMode() throws Exception {
|
||||
|
||||
final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
messagingTemplate.setDefaultDestination(this.gatewayWithFailModeChannel);
|
||||
|
||||
@@ -178,18 +177,18 @@ public class FileOutboundGatewayParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
|
||||
|
||||
final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
|
||||
try {
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
|
||||
|
||||
}
|
||||
catch (MessageHandlingException e) {
|
||||
assertTrue(e.getMessage().startsWith("The destination file already exists at '"));
|
||||
assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -219,18 +218,18 @@ public class FileOutboundGatewayParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
|
||||
|
||||
final String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
|
||||
try {
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
|
||||
|
||||
}
|
||||
catch (MessageHandlingException e) {
|
||||
assertTrue(e.getMessage().startsWith("The destination file already exists at '"));
|
||||
assertThat(e.getMessage(), startsWith("The destination file already exists at '"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,8 +261,8 @@ public class FileOutboundGatewayParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
|
||||
Message<?> m = messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
|
||||
Message<?> m = messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -301,8 +300,8 @@ public class FileOutboundGatewayParserTests {
|
||||
testFile.delete();
|
||||
}
|
||||
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<String>("Initial File Content:"));
|
||||
Message<?> m = messagingTemplate.sendAndReceive(new GenericMessage<String>("String content:"));
|
||||
messagingTemplate.sendAndReceive(new GenericMessage<>("Initial File Content:"));
|
||||
Message<?> m = messagingTemplate.sendAndReceive(new GenericMessage<>("String content:"));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
assertEquals(expectedFileContent, actualFileContent);
|
||||
@@ -327,7 +326,7 @@ public class FileOutboundGatewayParserTests {
|
||||
public static class FooAdvice extends AbstractRequestHandlerAdvice {
|
||||
|
||||
@Override
|
||||
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) throws Exception {
|
||||
protected Object doInvoke(ExecutionCallback callback, Object target, Message<?> message) {
|
||||
adviceCalled++;
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user