diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorSupport.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorSupport.java
index 7ebede2ef1..9a94c4aed0 100644
--- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorSupport.java
+++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionInterceptorSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 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.
@@ -106,6 +106,11 @@ public abstract class TcpConnectionInterceptorSupport extends TcpConnectionSuppo
return this.theConnection.getSocketInfo();
}
+ @Override
+ public String getConnectionFactoryName() {
+ return this.theConnection.getConnectionFactoryName();
+ }
+
@Override
public void run() {
this.theConnection.run();
diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java
index d29f8f13ec..a4ff1f47dc 100644
--- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java
+++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/tcp/connection/TcpConnectionSupport.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2016 the original author or authors.
+ * Copyright 2001-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.
@@ -336,6 +336,10 @@ public abstract class TcpConnectionSupport implements TcpConnection {
return this.socketInfo;
}
+ public String getConnectionFactoryName() {
+ return this.connectionFactoryName;
+ }
+
protected boolean isNoReadErrorOnClose() {
return this.noReadErrorOnClose;
}
@@ -355,19 +359,19 @@ public abstract class TcpConnectionSupport implements TcpConnection {
protected void publishConnectionOpenEvent() {
TcpConnectionEvent event = new TcpConnectionOpenEvent(this,
- this.connectionFactoryName);
+ getConnectionFactoryName());
doPublish(event);
}
protected void publishConnectionCloseEvent() {
TcpConnectionEvent event = new TcpConnectionCloseEvent(this,
- this.connectionFactoryName);
+ getConnectionFactoryName());
doPublish(event);
}
protected void publishConnectionExceptionEvent(Throwable t) {
TcpConnectionEvent event = new TcpConnectionExceptionEvent(this,
- this.connectionFactoryName, t);
+ getConnectionFactoryName(), t);
doPublish(event);
}
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests-context.xml b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests-context.xml
index 92972060e1..4970997583 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests-context.xml
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests-context.xml
@@ -71,4 +71,6 @@
+
+
diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java
index afd2317267..d08d2b09c4 100644
--- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java
+++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/InterceptedSharedConnectionTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2016 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,8 +16,11 @@
package org.springframework.integration.ip.tcp;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import org.apache.log4j.Level;
@@ -29,8 +32,11 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.ApplicationListener;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.integration.channel.QueueChannel;
+import org.springframework.integration.ip.tcp.connection.HelloWorldInterceptor;
+import org.springframework.integration.ip.tcp.connection.TcpConnectionOpenEvent;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -52,6 +58,9 @@ public class InterceptedSharedConnectionTests {
@Qualifier(value = "inboundServer")
TcpReceivingChannelAdapter listener;
+ @Autowired
+ Listener testListener;
+
private static Level existingLogLevel;
// temporary hooks to investigate CI failures
@@ -73,8 +82,6 @@ public class InterceptedSharedConnectionTests {
* for the outbound adapter that's sharing the connections. The response
* comes back to an inbound adapter that is sharing the client's
* connection and we verify we get the echo back as expected.
- *
- * @throws Exception
*/
@Test
public void test1() throws Exception {
@@ -93,6 +100,21 @@ public class InterceptedSharedConnectionTests {
assertNotNull(message);
assertEquals("Test", message.getPayload());
}
+ assertThat(this.testListener.openEvent, notNullValue());
+ assertThat(this.testListener.openEvent.getConnectionFactoryName(), equalTo("client"));
+ }
+
+ public static class Listener implements ApplicationListener {
+
+ private volatile TcpConnectionOpenEvent openEvent;
+
+ @Override
+ public void onApplicationEvent(TcpConnectionOpenEvent event) {
+ if (event.getSource() instanceof HelloWorldInterceptor) {
+ this.openEvent = event;
+ }
+ }
+
}
}