use of games.strategy.net.IConnectionChangeListener in project triplea by triplea-game.
the class RemoteMessengerTest method setUp.
@BeforeEach
public void setUp() throws Exception {
// simple set up for non networked testing
final List<IConnectionChangeListener> connectionListeners = new CopyOnWriteArrayList<>();
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) {
connectionListeners.add(invocation.getArgument(0));
return null;
}
}).when(serverMessenger).addConnectionChangeListener(any());
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) {
for (final IConnectionChangeListener listener : connectionListeners) {
listener.connectionRemoved(invocation.getArgument(0));
}
return null;
}
}).when(serverMessenger).removeConnection(any());
final Node dummyNode = new Node("dummy", InetAddress.getLocalHost(), 0);
when(serverMessenger.getLocalNode()).thenReturn(dummyNode);
when(serverMessenger.getServerNode()).thenReturn(dummyNode);
when(serverMessenger.isServer()).thenReturn(true);
remoteMessenger = new RemoteMessenger(new UnifiedMessenger(serverMessenger));
}
Aggregations