Sonar fixes

- remaining hidden fields

* Fix copyright
This commit is contained in:
Gary Russell
2019-01-09 13:30:08 -05:00
committed by Artem Bilan
parent e30741f7eb
commit 2766707547
28 changed files with 280 additions and 272 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2018 the original author or authors.
* Copyright 2014-2019 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.
@@ -393,7 +393,7 @@ public class TestMailServer {
public abstract static class MailServer implements Runnable {
private final ServerSocket socket;
private final ServerSocket serverSocket;
private final ExecutorService exec = Executors.newCachedThreadPool();
@@ -404,13 +404,13 @@ public class TestMailServer {
private volatile boolean listening;
MailServer(int port) throws IOException {
this.socket = ServerSocketFactory.getDefault().createServerSocket(port);
this.serverSocket = ServerSocketFactory.getDefault().createServerSocket(port);
this.listening = true;
exec.execute(this);
}
public int getPort() {
return this.socket.getLocalPort();
return this.serverSocket.getLocalPort();
}
public boolean isListening() {
@@ -432,8 +432,8 @@ public class TestMailServer {
@Override
public void run() {
try {
while (!socket.isClosed()) {
Socket socket = this.socket.accept();
while (!serverSocket.isClosed()) {
Socket socket = this.serverSocket.accept();
exec.execute(mailHandler(socket));
}
}
@@ -446,7 +446,7 @@ public class TestMailServer {
public void stop() {
try {
this.socket.close();
this.serverSocket.close();
}
catch (IOException e) {
e.printStackTrace();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 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.
@@ -47,6 +47,7 @@ import org.springframework.messaging.MessageHeaders;
*
* @author Dave Syer
* @author Artem Bilan
* @author Gary Russell
*
*/
public class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
@@ -69,23 +70,25 @@ public class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
}
private Map<String, Object> extractHeadersToAssert(Message<?> operand) {
HashMap<String, Object> headers = new HashMap<>(operand.getHeaders());
headers.remove(MessageHeaders.ID);
headers.remove(MessageHeaders.TIMESTAMP);
HashMap<String, Object> headersToAssert = new HashMap<>(operand.getHeaders());
headersToAssert.remove(MessageHeaders.ID);
headersToAssert.remove(MessageHeaders.TIMESTAMP);
if (this.ignoreKeys != null) {
for (String key : this.ignoreKeys) {
headers.remove(key);
headersToAssert.remove(key);
}
}
return headers;
return headersToAssert;
}
@Override
public boolean matches(Object arg) {
Message<?> input = (Message<?>) arg;
Map<String, Object> inputHeaders = extractHeadersToAssert(input);
return input.getPayload().equals(this.payload) && inputHeaders.equals(this.headers);
}
@Override
public void describeTo(Description description) {
description.appendText("a Message with Headers that match except ID and timestamp for payload: ")
.appendValue(this.payload)