INT-4080: Add TcpConnectionFailedEvent
JIRA: https://jira.spring.io/browse/INT-4080
This commit is contained in:
committed by
Artem Bilan
parent
5d19f380a9
commit
6eba49c625
@@ -39,6 +39,7 @@ import java.io.OutputStream;
|
||||
import java.net.BindException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -325,4 +326,32 @@ public class ConnectionEventTests {
|
||||
ss.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailConnect() {
|
||||
TcpNetClientConnectionFactory ccf = new TcpNetClientConnectionFactory("junkjunk", 1234);
|
||||
final AtomicReference<ApplicationEvent> failEvent = new AtomicReference<ApplicationEvent>();
|
||||
ccf.setApplicationEventPublisher(new ApplicationEventPublisher() {
|
||||
|
||||
@Override
|
||||
public void publishEvent(Object event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishEvent(ApplicationEvent event) {
|
||||
failEvent.set(event);
|
||||
}
|
||||
|
||||
});
|
||||
ccf.start();
|
||||
try {
|
||||
ccf.getConnection();
|
||||
fail("expected exception");
|
||||
}
|
||||
catch (Exception e) {
|
||||
assertThat(e, instanceOf(UnknownHostException.class));
|
||||
TcpConnectionFailedEvent event = (TcpConnectionFailedEvent) failEvent.get();
|
||||
assertSame(e, event.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user