final Config config2 = new Config();
// force join failure.
config2.setProperty(GroupProperties.PROP_MAX_JOIN_SECONDS, "-100");
// add lifecycle listener.
final ListenerConfig listenerConfig = new ListenerConfig();
listenerConfig.setImplementation(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
// Only expecting SHUTTING_DOWN & SHUTDOWN.
if (LifecycleEvent.LifecycleState.SHUTTING_DOWN.equals(event.getState())
|| LifecycleEvent.LifecycleState.SHUTDOWN.equals(event.getState())) {