INT-3099 Add IMAP Idle Application Events

Allow an application to be informed of problems on the IMAP idle
thread by emitting an event containing the exception.

Introduce IntegrationApplicationEvent hierarchy for all
events emitted by SI components.

INT-3099 Polishing (PR Comments)

Separate TCP events into discrete subclasses.
This commit is contained in:
Gary Russell
2013-08-11 14:34:47 -04:00
parent 754273b0a0
commit 5cbdfe9e43
30 changed files with 516 additions and 154 deletions

View File

@@ -0,0 +1,36 @@
/*
* Copyright 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.event;
import org.springframework.integration.event.IntegrationEvent;
/**
* @author Gary Russell
* @since 3.0
*
*/
@SuppressWarnings("serial")
public abstract class IpIntegrationEvent extends IntegrationEvent {
public IpIntegrationEvent(Object source) {
super(source);
}
public IpIntegrationEvent(Object source, Throwable cause) {
super(source, cause);
}
}

View File

@@ -0,0 +1,4 @@
/**
* ApplicationEvents generated by the ip module.
*/
package org.springframework.integration.ip.event;

View File

@@ -1,95 +0,0 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp.connection;
import org.springframework.context.ApplicationEvent;
/**
* ApplicationEvent representing certain operations on a {@link TcpConnection}.
* @author Gary Russell
* @since 3.0
*
*/
public class TcpConnectionEvent extends ApplicationEvent {
private static final long serialVersionUID = 5323436446362192129L;
/**
* Valid EventTypes - subclasses should provide similar enums for
* their types.
*
*/
public enum TcpConnectionEventType implements EventType {
OPEN,
CLOSE,
EXCEPTION;
}
private final EventType type;
private final String connectionFactoryName;
private final Throwable throwable;
public TcpConnectionEvent(TcpConnection connection, EventType type,
String connectionFactoryName) {
super(connection);
this.type = type;
this.throwable = null;
this.connectionFactoryName = connectionFactoryName;
}
public TcpConnectionEvent(TcpConnection connection, Throwable t,
String connectionFactoryName) {
super(connection);
this.type = TcpConnectionEventType.EXCEPTION;
this.throwable = t;
this.connectionFactoryName = connectionFactoryName;
}
public EventType getType() {
return this.type;
}
public String getConnectionId() {
return ((TcpConnection) this.getSource()).getConnectionId();
}
public String getConnectionFactoryName() {
return this.connectionFactoryName;
}
public Throwable getThrowable() {
return this.throwable;
}
@Override
public String toString() {
return "TcpConnectionEvent [type=" + this.getType() +
", factory=" + this.connectionFactoryName +
", connectionId=" + this.getConnectionId() +
(this.throwable == null ? "" : ", Exception=" + this.throwable) + "]";
}
/**
* A marker interface allowing the definition of enums for allowed event types.
*
*/
public interface EventType {
}
}

View File

@@ -22,6 +22,7 @@ import org.springframework.context.ApplicationListener;
import org.springframework.integration.Message;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.endpoint.MessageProducerSupport;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

View File

@@ -30,7 +30,10 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.serializer.Deserializer;
import org.springframework.core.serializer.Serializer;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionCloseEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionExceptionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
import org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer;
import org.springframework.util.Assert;
@@ -304,20 +307,20 @@ public abstract class TcpConnectionSupport implements TcpConnection {
}
protected void publishConnectionOpenEvent() {
TcpConnectionEvent event = new TcpConnectionEvent(this, TcpConnectionEventType.OPEN,
TcpConnectionEvent event = new TcpConnectionOpenEvent(this,
this.connectionFactoryName);
doPublish(event);
}
protected void publishConnectionCloseEvent() {
TcpConnectionEvent event = new TcpConnectionEvent(this, TcpConnectionEventType.CLOSE,
TcpConnectionEvent event = new TcpConnectionCloseEvent(this,
this.connectionFactoryName);
doPublish(event);
}
protected void publishConnectionExceptionEvent(Throwable t) {
TcpConnectionEvent event = new TcpConnectionEvent(this, t,
this.connectionFactoryName);
TcpConnectionEvent event = new TcpConnectionExceptionEvent(this,
this.connectionFactoryName, t);
doPublish(event);
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp.connection.event;
import org.springframework.integration.ip.tcp.connection.TcpConnection;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class TcpConnectionCloseEvent extends TcpConnectionEvent {
private static final long serialVersionUID = 7237316997596598287L;
public TcpConnectionCloseEvent(TcpConnection connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
@Override
public String toString() {
return super.toString() + " **CLOSED**";
}
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2002-2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp.connection.event;
import org.springframework.integration.ip.event.IpIntegrationEvent;
import org.springframework.integration.ip.tcp.connection.TcpConnection;
/**
* ApplicationEvent representing normal operations on a {@link TcpConnection}.
* @author Gary Russell
* @since 3.0
*
*/
@SuppressWarnings("serial")
public abstract class TcpConnectionEvent extends IpIntegrationEvent {
private final String connectionFactoryName;
public TcpConnectionEvent(TcpConnection connection,
String connectionFactoryName) {
super(connection);
this.connectionFactoryName = connectionFactoryName;
}
public TcpConnectionEvent(TcpConnection connection, String connectionFactoryName,
Throwable cause) {
super(connection, cause);
this.connectionFactoryName = connectionFactoryName;
}
public String getConnectionId() {
return ((TcpConnection) this.getSource()).getConnectionId();
}
public String getConnectionFactoryName() {
return this.connectionFactoryName;
}
@Override
public String toString() {
return super.toString() +
", [factory=" + this.connectionFactoryName +
", connectionId=" + this.getConnectionId() + "]";
}
}

View File

@@ -0,0 +1,35 @@
/*
* Copyright 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp.connection.event;
import org.springframework.integration.ip.tcp.connection.TcpConnection;
/**
* ApplicationEvent representing exceptions on a {@link TcpConnection}.
* @author Gary Russell
* @since 3.0
*
*/
public class TcpConnectionExceptionEvent extends TcpConnectionEvent {
private static final long serialVersionUID = 1335560439854592185L;
public TcpConnectionExceptionEvent(TcpConnection connection,
String connectionFactoryName, Throwable cause) {
super(connection, connectionFactoryName, cause);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ip.tcp.connection.event;
import org.springframework.integration.ip.tcp.connection.TcpConnection;
/**
* @author Gary Russell
* @since 3.0
*
*/
public class TcpConnectionOpenEvent extends TcpConnectionEvent {
private static final long serialVersionUID = 7237316997596598287L;
public TcpConnectionOpenEvent(TcpConnection connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
@Override
public String toString() {
return super.toString() + " **OPENED**";
}
}

View File

@@ -0,0 +1,4 @@
/**
* Classes representing TCP connection events.
*/
package org.springframework.integration.ip.tcp.connection.event;

View File

@@ -30,6 +30,7 @@ import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -55,8 +56,6 @@ import org.springframework.integration.ip.tcp.connection.AbstractConnectionFacto
import org.springframework.integration.ip.tcp.connection.DefaultTcpNetSSLSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.DefaultTcpNioSSLConnectionSupport;
import org.springframework.integration.ip.tcp.connection.DefaultTcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEventListeningMessageProducer;
import org.springframework.integration.ip.tcp.connection.TcpConnectionSupport;
import org.springframework.integration.ip.tcp.connection.TcpMessageMapper;
@@ -67,6 +66,8 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF
import org.springframework.integration.ip.tcp.connection.TcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.TcpSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.TcpSocketSupport;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
import org.springframework.integration.ip.udp.DatagramPacketMessageMapper;
import org.springframework.integration.ip.udp.MulticastReceivingChannelAdapter;
import org.springframework.integration.ip.udp.MulticastSendingMessageHandler;
@@ -668,7 +669,7 @@ public class ParserUnitTests {
DirectChannel.class).getComponentName());
TcpConnectionSupport connection = mock(TcpConnectionSupport.class);
TcpConnectionEvent event = new TcpConnectionEvent(connection, TcpConnectionEventType.OPEN, "foo");
TcpConnectionEvent event = new TcpConnectionOpenEvent(connection, "foo");
this.eventAdapter.setEventTypes(new Class[] {TcpConnectionEvent.class});
this.eventAdapter.onApplicationEvent(event);
assertNull(this.eventChannel.receive(0));
@@ -692,16 +693,16 @@ public class ParserUnitTests {
@SuppressWarnings("serial")
public static class EventSubclass1 extends TcpConnectionEvent {
public EventSubclass1(TcpConnectionSupport connection, EventType type, String connectionFactoryName) {
super(connection, type, connectionFactoryName);
public EventSubclass1(TcpConnectionSupport connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
}
@SuppressWarnings("serial")
public static class EventSubclass2 extends TcpConnectionEvent {
public EventSubclass2(TcpConnectionSupport connection, EventType type, String connectionFactoryName) {
super(connection, type, connectionFactoryName);
public EventSubclass2(TcpConnectionSupport connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
}
}

View File

@@ -16,10 +16,10 @@
package org.springframework.integration.ip.tcp;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
@@ -27,6 +27,7 @@ import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.AbstractApplicationContext;
@@ -37,8 +38,10 @@ import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpConnection;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionCloseEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionExceptionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
import org.springframework.integration.ip.tcp.serializer.ByteArrayRawSerializer;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.support.MessageBuilder;
@@ -114,21 +117,21 @@ public class ConnectionToConnectionTests {
while ((eventMessage = (Message<TcpConnectionEvent>) events.receive(1000)) != null) {
TcpConnectionEvent event = eventMessage.getPayload();
if ("client".equals(event.getConnectionFactoryName())) {
if (TcpConnectionEventType.OPEN == event.getType()) {
if (event instanceof TcpConnectionOpenEvent) {
clientOpens++;
}
else if (TcpConnectionEventType.CLOSE == event.getType()) {
else if (event instanceof TcpConnectionCloseEvent) {
clientCloses++;
}
else if (TcpConnectionEventType.EXCEPTION == event.getType()) {
else if (event instanceof TcpConnectionExceptionEvent) {
clientExceptions++;
}
}
else if ("server".equals(event.getConnectionFactoryName())) {
if (TcpConnectionEventType.OPEN == event.getType()) {
if (event instanceof TcpConnectionOpenEvent) {
serverOpens++;
}
else if (TcpConnectionEventType.CLOSE == event.getType()) {
else if (event instanceof TcpConnectionCloseEvent) {
serverCloses++;
}
}

View File

@@ -15,9 +15,9 @@
*/
package org.springframework.integration.ip.tcp.connection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
@@ -28,9 +28,13 @@ import java.util.concurrent.atomic.AtomicReference;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.serializer.Serializer;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionExceptionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
import org.springframework.integration.message.GenericMessage;
/**
@@ -51,7 +55,8 @@ public class ConnectionEventTests {
}
}, "foo");
assertNotNull(theEvent.get());
assertEquals("TcpConnectionEvent [type=OPEN, factory=foo, connectionId=" + conn.getConnectionId() + "]", theEvent.get().toString());
assertTrue(theEvent.get() instanceof TcpConnectionOpenEvent);
assertTrue(theEvent.get().toString().endsWith("[factory=foo, connectionId=" + conn.getConnectionId() + "] **OPENED**"));
@SuppressWarnings("unchecked")
Serializer<Object> serializer = mock(Serializer.class);
RuntimeException toBeThrown = new RuntimeException("foo");
@@ -64,13 +69,15 @@ public class ConnectionEventTests {
}
catch (Exception e) {}
assertNotNull(theEvent.get());
assertEquals("TcpConnectionEvent [type=EXCEPTION, factory=foo, connectionId=" + conn.getConnectionId() +
", Exception=java.lang.RuntimeException: foo]", theEvent.get().toString());
assertNotNull(theEvent.get().getThrowable());
assertSame(toBeThrown, theEvent.get().getThrowable());
assertTrue(theEvent.get() instanceof TcpConnectionExceptionEvent);
assertTrue(theEvent.get().toString().endsWith("[factory=foo, connectionId=" + conn.getConnectionId() + "]"));
assertTrue(theEvent.get().toString().contains("cause=java.lang.RuntimeException: foo]"));
TcpConnectionExceptionEvent event = (TcpConnectionExceptionEvent) theEvent.get();
assertNotNull(event.getCause());
assertSame(toBeThrown, event.getCause());
conn.close();
assertNotNull(theEvent.get());
assertEquals("TcpConnectionEvent [type=CLOSE, factory=foo, connectionId=" + conn.getConnectionId() + "]", theEvent.get().toString());
assertTrue(theEvent.get().toString().endsWith("[factory=foo, connectionId=" + conn.getConnectionId() + "] **CLOSED**"));
}
}

View File

@@ -32,11 +32,13 @@ import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.test.util.SocketUtils;
@@ -98,12 +100,12 @@ public class ConnectionFactoryTests {
assertEquals(0, clients.size());
assertEquals(6, events.size()); // OPEN, CLOSE, EXCEPTION for each side
FooEvent event = new FooEvent(client, TcpConnectionEventType.OPEN, "foo");
FooEvent event = new FooEvent(client, "foo");
client.publishEvent(event);
assertEquals(7, events.size());
try {
event = new FooEvent(mock(TcpConnectionSupport.class), TcpConnectionEventType.OPEN, "foo");
event = new FooEvent(mock(TcpConnectionSupport.class), "foo");
client.publishEvent(event);
fail("Expected exception");
}
@@ -113,10 +115,10 @@ public class ConnectionFactoryTests {
}
@SuppressWarnings("serial")
private class FooEvent extends TcpConnectionEvent {
private class FooEvent extends TcpConnectionOpenEvent {
public FooEvent(TcpConnectionSupport connection, EventType type, String connectionFactoryName) {
super(connection, type, connectionFactoryName);
public FooEvent(TcpConnectionSupport connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
}

View File

@@ -32,7 +32,8 @@ import org.junit.Test;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionCloseEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.SocketUtils;
@@ -261,7 +262,7 @@ public class ConnectionTimeoutTests {
@Override
public void publishEvent(ApplicationEvent event) {
TcpConnectionEvent tcpEvent = (TcpConnectionEvent) event;
if (tcpEvent.getType() == TcpConnectionEventType.CLOSE) {
if (tcpEvent instanceof TcpConnectionCloseEvent) {
clientClosedLatch.countDown();
}
}

View File

@@ -21,9 +21,11 @@ import static org.junit.Assert.assertSame;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.integration.Message;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.ip.tcp.connection.TcpConnectionEvent.TcpConnectionEventType;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionEvent;
import org.springframework.integration.ip.tcp.connection.event.TcpConnectionOpenEvent;
/**
* @author Gary Russell
@@ -40,11 +42,11 @@ public class TcpConnectionEventListenerTests {
eventProducer.afterPropertiesSet();
eventProducer.start();
TcpConnectionSupport connection = Mockito.mock(TcpConnectionSupport.class);
TcpConnectionEvent event1 = new TcpConnectionEvent(connection, TcpConnectionEventType.OPEN, "foo");
TcpConnectionEvent event1 = new TcpConnectionOpenEvent(connection, "foo");
eventProducer.onApplicationEvent(event1);
FooEvent event2 = new FooEvent(connection, TcpConnectionEventType.OPEN, "foo");
FooEvent event2 = new FooEvent(connection, "foo");
eventProducer.onApplicationEvent(event2);
BarEvent event3 = new BarEvent(connection, TcpConnectionEventType.OPEN, "foo");
BarEvent event3 = new BarEvent(connection, "foo");
eventProducer.onApplicationEvent(event3);
Message<?> message = outputChannel.receive(0);
assertNotNull(message);
@@ -69,11 +71,11 @@ public class TcpConnectionEventListenerTests {
eventProducer.afterPropertiesSet();
eventProducer.start();
TcpConnectionSupport connection = Mockito.mock(TcpConnectionSupport.class);
TcpConnectionEvent event1 = new TcpConnectionEvent(connection, TcpConnectionEventType.OPEN, "foo");
TcpConnectionEvent event1 = new TcpConnectionOpenEvent(connection, "foo");
eventProducer.onApplicationEvent(event1);
FooEvent event2 = new FooEvent(connection, TcpConnectionEventType.OPEN, "foo");
FooEvent event2 = new FooEvent(connection, "foo");
eventProducer.onApplicationEvent(event2);
BarEvent event3 = new BarEvent(connection, TcpConnectionEventType.OPEN, "foo");
BarEvent event3 = new BarEvent(connection, "foo");
eventProducer.onApplicationEvent(event3);
Message<?> message = outputChannel.receive(0);
assertNotNull(message);
@@ -86,19 +88,19 @@ public class TcpConnectionEventListenerTests {
}
@SuppressWarnings("serial")
private class FooEvent extends TcpConnectionEvent {
private class FooEvent extends TcpConnectionOpenEvent {
public FooEvent(TcpConnectionSupport connection, EventType type, String connectionFactoryName) {
super(connection, type, connectionFactoryName);
public FooEvent(TcpConnectionSupport connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
}
@SuppressWarnings("serial")
private class BarEvent extends TcpConnectionEvent {
private class BarEvent extends TcpConnectionOpenEvent {
public BarEvent(TcpConnectionSupport connection, EventType type, String connectionFactoryName) {
super(connection, type, connectionFactoryName);
public BarEvent(TcpConnectionSupport connection, String connectionFactoryName) {
super(connection, connectionFactoryName);
}
}