public void testAttributeSet() { notifyBrokerStarted(); Broker broker = mock(Broker.class); when(broker.getCategoryClass()).thenReturn(Broker.class); when(broker.isDurable()).thenReturn(true); _listener.attributeSet(broker, Broker.CONNECTION_SESSION_COUNT_LIMIT, null, 1); verify(_store).update(eq(false), any(ConfiguredObjectRecord.class)); }
public void testChildAdded() { notifyBrokerStarted(); Broker broker = mock(Broker.class); when(broker.getCategoryClass()).thenReturn(Broker.class); when(broker.isDurable()).thenReturn(true); VirtualHost child = mock(VirtualHost.class); when(child.getCategoryClass()).thenReturn(VirtualHost.class); Model model = mock(Model.class); when(model.getChildTypes(any(Class.class))) .thenReturn(Collections.<Class<? extends ConfiguredObject>>emptyList()); when(child.getModel()).thenReturn(model); when(child.isDurable()).thenReturn(true); _listener.childAdded(broker, child); verify(_store).update(eq(true), any(ConfiguredObjectRecord.class)); }
@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)); }