use of org.apache.cayenne.event.CayenneEvent in project cayenne by apache.
the class ClientChannelTest method testEventBridgeFailure.
@Test
public void testEventBridgeFailure() throws Exception {
MockClientConnection connection = new MockClientConnection() {
@Override
public EventBridge getServerEventBridge() throws CayenneRuntimeException {
return new EventBridge(Collections.EMPTY_LIST, "ext") {
@Override
protected void sendExternalEvent(CayenneEvent localEvent) throws Exception {
}
@Override
protected void shutdownExternal() throws Exception {
}
@Override
protected void startupExternal() throws Exception {
// intentionally throw an exception
throw new CayenneRuntimeException("Test failure");
}
};
}
};
// default constructor must fail
try {
new ClientChannel(connection, false, new MockEventManager(), false);
fail("Channel didn't throw on broken EventBridge");
} catch (CayenneRuntimeException e) {
// expected
}
try {
DefaultEventManager manager = new DefaultEventManager(2);
managers.add(manager);
new ClientChannel(connection, false, manager, false);
fail("Channel didn't throw on broken EventBridge");
} catch (CayenneRuntimeException e) {
// expected
}
try {
DefaultEventManager manager = new DefaultEventManager(2);
managers.add(manager);
new ClientChannel(connection, false, manager, true);
} catch (CayenneRuntimeException e) {
fail("Channel threw on broken EventBridge");
}
}
Aggregations