use of org.jgroups.fork.ForkChannel in project JGroups by belaban.
the class ForkChannelTest method testLifecycle.
public void testLifecycle() throws Exception {
fc1 = new ForkChannel(a, "stack", "fc1");
assert fc1.isOpen() && !fc1.isConnected() && !fc1.isClosed() : "state=" + fc1.getState();
a.connect(CLUSTER);
assert fc1.isOpen() && !fc1.isConnected() && !fc1.isClosed() : "state=" + fc1.getState();
fc1.connect("bla");
assert fc1.isOpen() && fc1.isConnected() && !fc1.isClosed() : "state=" + fc1.getState();
assert a.getAddress().equals(fc1.getAddress());
assert a.getClusterName().equals(fc1.getClusterName());
assert a.getView().equals(fc1.getView());
fc1.disconnect();
assert fc1.isOpen() && !fc1.isConnected() && !fc1.isClosed() : "state=" + fc1.getState();
fc1.connect("foobar");
assert fc1.isOpen() && fc1.isConnected() && !fc1.isClosed() : "state=" + fc1.getState();
Util.close(fc1);
assert !fc1.isOpen() && !fc1.isConnected() && fc1.isClosed() : "state=" + fc1.getState();
try {
fc1.connect("whocares");
assert false : "a closed fork channel cannot be reconnected";
} catch (Exception ex) {
assert ex instanceof IllegalStateException;
}
assert !fc1.isOpen() && !fc1.isConnected() && fc1.isClosed() : "state=" + fc1.getState();
Util.close(a);
assert !fc1.isOpen() && !fc1.isConnected() && fc1.isClosed() : "state=" + fc1.getState();
try {
fc1.send(null, "hello");
assert false : "sending on a fork-channel with a disconnected main-channel should throw an exception";
} catch (Throwable t) {
System.out.println("got an exception (as expected) sending on a fork-channel where the main-channel is disconnected: " + t);
}
}
use of org.jgroups.fork.ForkChannel in project JGroups by belaban.
the class ForkChannelTest method createForkChannel.
protected ForkChannel createForkChannel(JChannel main, String stack_name, String ch_name) throws Exception {
ForkChannel fork_ch = new ForkChannel(main, stack_name, ch_name);
fork_ch.connect(ch_name);
return fork_ch;
}
use of org.jgroups.fork.ForkChannel in project JGroups by belaban.
the class ForkChannelTest method testCreateForkIfAbsent.
@Test
public void testCreateForkIfAbsent() throws Exception {
JChannel c = new JChannel(Util.getTestStack(new STATE())).name("C");
ForkChannel fc = new ForkChannel(c, "hijack-stack", "lead-hijacker", true, ProtocolStack.Position.ABOVE, FRAG2.class);
assert fc.isOpen() && !fc.isConnected() && !fc.isClosed() : "state=" + fc.getState();
Util.close(fc, c);
}
Aggregations