use of org.apache.qpid.server.model.IllegalStateTransitionException in project qpid-broker-j by apache.
the class AbstractConfiguredObjectTest method XtestUnsuccessfulStateTransitionDoesNotInvokesListener.
// TODO - not sure if I want to keep the state transition methods on delete
public void XtestUnsuccessfulStateTransitionDoesNotInvokesListener() throws Exception {
final IllegalStateTransitionException expectedException = new IllegalStateTransitionException("This test fails the state transition.");
TestConfiguredObject parent = new TestConfiguredObject("parent") {
@Override
protected ListenableFuture<Void> doDelete() {
throw expectedException;
}
};
parent.create();
final AtomicInteger callCounter = new AtomicInteger();
parent.addChangeListener(new AbstractConfigurationChangeListener() {
@Override
public void stateChanged(final ConfiguredObject<?> object, final State old, final State state) {
super.stateChanged(object, old, state);
callCounter.incrementAndGet();
}
@Override
public void attributeSet(ConfiguredObject<?> object, String attributeName, Object oldAttributeValue, Object newAttributeValue) {
super.attributeSet(object, attributeName, oldAttributeValue, newAttributeValue);
callCounter.incrementAndGet();
}
});
try {
parent.delete();
fail("Exception not thrown.");
} catch (RuntimeException e) {
assertSame("State transition threw unexpected exception.", expectedException, e);
}
assertEquals(0, callCounter.get());
assertEquals(State.ACTIVE, parent.getDesiredState());
assertEquals(State.ACTIVE, parent.getState());
}
use of org.apache.qpid.server.model.IllegalStateTransitionException in project qpid-broker-j by apache.
the class InternalBrokerHolder method start.
public void start(final Map<String, Object> systemConfig) throws Exception {
if (Thread.getDefaultUncaughtExceptionHandler() == null) {
Thread.setDefaultUncaughtExceptionHandler(UNCAUGHT_EXCEPTION_HANDLER);
}
LOGGER.info("Starting internal broker (same JVM)");
_systemLauncher = new SystemLauncher(new LogbackLoggingSystemLauncherListener(), new SystemLauncherListener.DefaultSystemLauncherListener() {
@Override
public void onShutdown(final int exitCode) {
_systemLauncher = null;
}
@Override
public void exceptionOnShutdown(final Exception e) {
if (e instanceof IllegalStateException || e instanceof IllegalStateTransitionException) {
System.out.println("IllegalStateException occurred on broker shutdown in test " + getClassQualifiedTestName());
}
}
});
_systemLauncher.startup(systemConfig);
}
use of org.apache.qpid.server.model.IllegalStateTransitionException in project qpid-broker-j by apache.
the class BDBHARemoteReplicationNodeImpl method onDelete.
@Override
protected ListenableFuture<Void> onDelete() {
if (!_nodeLeft) {
SettableFuture<Void> future = SettableFuture.create();
String nodeName = getName();
boolean deletionAllowed;
try {
getEventLogger().message(_virtualHostNodeLogSubject, HighAvailabilityMessages.DELETED());
deletionAllowed = _replicatedEnvironmentFacade.removeNodeFromGroup(nodeName);
if (deletionAllowed) {
future.set(null);
} else {
future.setException(new IllegalStateTransitionException(String.format("Node '%s' cannot be deleted when role is a master", nodeName)));
}
} catch (ServerScopedRuntimeException e) {
future.setException(e);
throw e;
} catch (RuntimeException e) {
future.setException(new IllegalStateTransitionException(String.format("Unexpected exception on node '%s' deletion", nodeName), e));
}
return future;
} else {
return super.onDelete();
}
}
Aggregations