@Override public void setUp() throws Exception { super.setUp(); SystemConfig systemConfig = mock(SystemConfig.class); when(systemConfig.getEventLogger()).thenReturn(mock(EventLogger.class)); Broker<?> broker = mock(Broker.class); when(broker.getParent(SystemConfig.class)).thenReturn(systemConfig); when(broker.getModel()).thenReturn(BrokerModel.getInstance()); when(broker.getSecurityManager()).thenReturn(new SecurityManager(broker, false)); _taskExecutor = new TaskExecutorImpl(); _taskExecutor.start(); when(broker.getTaskExecutor()).thenReturn(_taskExecutor); when(broker.getChildExecutor()).thenReturn(_taskExecutor); _node = mock(VirtualHostNode.class); when(_node.getParent(Broker.class)).thenReturn(broker); when(_node.getModel()).thenReturn(BrokerModel.getInstance()); when(_node.getTaskExecutor()).thenReturn(_taskExecutor); when(_node.getChildExecutor()).thenReturn(_taskExecutor); when(_node.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class)); when(_node.getCategoryClass()).thenReturn(VirtualHostNode.class); _failingStore = mock(MessageStore.class); doThrow(new RuntimeException("Cannot open store")) .when(_failingStore) .openMessageStore(any(ConfiguredObject.class)); }