Fix SocketSupportTests for SSL handshake exception

https://build.spring.io/browse/INT-FATS5IC-79/

Since there is no guaranty which exception message will be built by the SSL handshake error, we can't rely on only one expectation.

Also fix Checkstyle vulnerabilities in the IP module for ImportOrder rule
This commit is contained in:
Artem Bilan
2017-02-07 10:11:24 -05:00
parent c71240575c
commit 5987f2e3b9
3 changed files with 18 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -22,6 +22,7 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.scheduling.TaskScheduler;
@@ -67,5 +68,7 @@ public class ClientModeControlBusTests {
boolean boolResult(String command);
void voidResult(String command);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.SocketException;
import javax.net.SocketFactory;
@@ -30,6 +29,7 @@ import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.AbstractApplicationContext;
@@ -162,7 +162,7 @@ public class TcpConfigInboundGatewayTests {
crLfGuts(socket);
}
private void crLfGuts(Socket socket) throws SocketException, IOException {
private void crLfGuts(Socket socket) throws IOException {
socket.setSoTimeout(5000);
String greetings = "Hello World!";
socket.getOutputStream().write((greetings + "\r\n").getBytes());
@@ -192,7 +192,7 @@ public class TcpConfigInboundGatewayTests {
stxEtxGuts(socket);
}
private void stxEtxGuts(Socket socket) throws SocketException, IOException {
private void stxEtxGuts(Socket socket) throws IOException {
socket.setSoTimeout(5000);
String greetings = "Hello World!";
socket.getOutputStream().write(ByteArrayStxEtxSerializer.STX);
@@ -227,8 +227,7 @@ public class TcpConfigInboundGatewayTests {
serializedGuts(socket);
}
private void serializedGuts(Socket socket) throws SocketException,
IOException, ClassNotFoundException {
private void serializedGuts(Socket socket) throws IOException, ClassNotFoundException {
socket.setSoTimeout(5000);
String greetings = "Hello World!";
new ObjectOutputStream(socket.getOutputStream()).writeObject(greetings);
@@ -250,7 +249,7 @@ public class TcpConfigInboundGatewayTests {
lengthGuts(socket);
}
private void lengthGuts(Socket socket) throws SocketException, IOException {
private void lengthGuts(Socket socket) throws IOException {
socket.setSoTimeout(5000);
String greetings = "Hello World!";
byte[] header = new byte[4];
@@ -300,4 +299,5 @@ public class TcpConfigInboundGatewayTests {
public static void shutDown() {
staticContext.close();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 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.
@@ -17,6 +17,7 @@
package org.springframework.integration.ip.tcp.connection;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.Matchers.anyOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
@@ -424,7 +425,10 @@ Certificate fingerprints:
}
catch (IOException e) {
if (!(e instanceof ClosedChannelException)) {
assertThat(e.getMessage(), containsString("Socket closed during SSL Handshake"));
assertThat(e.getMessage(),
anyOf(
containsString("Socket closed during SSL Handshake"),
containsString("Broken pipe")));
}
}
}
@@ -442,7 +446,7 @@ Certificate fingerprints:
sslEngine.setNeedClientAuth(true);
}
};
};
server.setTcpNioConnectionSupport(tcpNioConnectionSupport);
final List<Message<?>> messages = new ArrayList<Message<?>>();
final CountDownLatch latch = new CountDownLatch(1);