use of org.jgroups.JChannel in project camel by apache.
the class JGroupsConsumerTest method doPreSetup.
// Fixture setup
@Override
protected void doPreSetup() throws Exception {
super.doPreSetup();
channel = new JChannel();
channel.connect(clusterName);
}
use of org.jgroups.JChannel in project camel by apache.
the class JGroupsProducerTest method doPreSetup.
// Fixture setup
@Override
protected void doPreSetup() throws Exception {
super.doPreSetup();
channel = new JChannel();
channel.setReceiver(new ReceiverAdapter() {
@Override
public void receive(Message msg) {
messageReceived = msg.getObject();
}
});
channel.connect(CLUSTER_NAME);
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testUseOldJChannel.
@Test
public void testUseOldJChannel() throws Exception {
initMocks(false);
JChannel channel = messenger.myChannel;
services.getConfig().getTransport().setOldDSMembershipInfo(channel);
JGroupsMessenger newMessenger = new JGroupsMessenger();
newMessenger.init(services);
newMessenger.start();
newMessenger.started();
newMessenger.stop();
assertTrue(newMessenger.myChannel == messenger.myChannel);
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testSendWhenChannelIsClosed.
@Test
public void testSendWhenChannelIsClosed() throws Exception {
for (int i = 0; i < 2; i++) {
initMocks(false);
JChannel mockChannel = mock(JChannel.class);
when(mockChannel.isConnected()).thenReturn(false);
doThrow(new RuntimeException()).when(mockChannel).send(any(Message.class));
JChannel realChannel = messenger.myChannel;
messenger.myChannel = mockChannel;
try {
InternalDistributedMember mbr = createAddress(8888);
DistributedCacheOperation.CacheOperationMessage msg = mock(DistributedCacheOperation.CacheOperationMessage.class);
when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] { mbr });
when(msg.getMulticast()).thenReturn(false);
when(msg.getProcessorId()).thenReturn(1234);
try {
messenger.send(msg);
fail("expected a failure");
} catch (DistributedSystemDisconnectedException e) {
// success
}
verify(mockChannel, never()).send(isA(Message.class));
} finally {
messenger.myChannel = realChannel;
}
}
}
use of org.jgroups.JChannel in project geode by apache.
the class JGroupsMessengerJUnitTest method testJChannelErrorDuringDisconnect.
@Test
public void testJChannelErrorDuringDisconnect() throws Exception {
for (int i = 0; i < 4; i++) {
System.out.println("loop #" + i);
boolean enableMcast = (i % 2 == 1);
initMocks(enableMcast);
JChannel mockChannel = mock(JChannel.class);
when(mockChannel.isConnected()).thenReturn(true);
Exception ex, shutdownCause;
if (i < 2) {
ex = new RuntimeException("");
shutdownCause = new RuntimeException("shutdownCause");
} else {
shutdownCause = new ForcedDisconnectException("");
ex = new RuntimeException("", shutdownCause);
}
doThrow(ex).when(mockChannel).send(any(Message.class));
JChannel realChannel = messenger.myChannel;
messenger.myChannel = mockChannel;
when(services.getShutdownCause()).thenReturn(shutdownCause);
try {
InternalDistributedMember mbr = createAddress(8888);
DistributedCacheOperation.CacheOperationMessage msg = mock(DistributedCacheOperation.CacheOperationMessage.class);
when(msg.getRecipients()).thenReturn(new InternalDistributedMember[] { mbr });
when(msg.getMulticast()).thenReturn(enableMcast);
when(msg.getProcessorId()).thenReturn(1234);
when(msg.getDSFID()).thenReturn((int) DataSerializableFixedID.PUT_ALL_MESSAGE);
try {
messenger.send(msg);
fail("expected a failure");
} catch (DistributedSystemDisconnectedException e) {
// the ultimate cause should be the shutdownCause returned
// by Services.getShutdownCause()
Throwable cause = e;
while (cause.getCause() != null) {
cause = cause.getCause();
}
assertTrue(cause != e);
assertTrue(cause == shutdownCause);
}
verify(mockChannel).send(isA(Message.class));
} finally {
messenger.myChannel = realChannel;
}
}
}
Aggregations