Search in sources :

Example 1 with JsonSystemConfigImpl

use of org.apache.qpid.server.model.JsonSystemConfigImpl in project qpid-broker-j by apache.

the class BrokerMemoryLoggerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class), null, new HashMap<String, Object>()) {

        {
            updateModel(BrokerModel.getInstance());
        }
    };
    when(_brokerEntry.getId()).thenReturn(_brokerId);
    when(_brokerEntry.getType()).thenReturn(Broker.class.getSimpleName());
    Map<String, Object> attributesMap = new HashMap<>();
    attributesMap.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
    attributesMap.put(Broker.NAME, getName());
    when(_brokerEntry.getAttributes()).thenReturn(attributesMap);
    when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemConfig.class.getSimpleName(), _systemConfig.getId()));
    GenericRecoverer recoverer = new GenericRecoverer(_systemConfig);
    recoverer.recover(Arrays.asList(_brokerEntry), false);
}
Also used : Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) GenericRecoverer(org.apache.qpid.server.store.GenericRecoverer) JsonSystemConfigImpl(org.apache.qpid.server.model.JsonSystemConfigImpl)

Example 2 with JsonSystemConfigImpl

use of org.apache.qpid.server.model.JsonSystemConfigImpl in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    _rootId = UUID.randomUUID();
    _portEntryId = UUID.randomUUID();
    _store = mock(DurableConfigurationStore.class);
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class), null, new HashMap<String, Object>());
    ConfiguredObjectRecord systemContextRecord = _systemConfig.asObjectRecord();
    _root = new ConfiguredObjectRecordImpl(_rootId, Broker.class.getSimpleName(), Collections.singletonMap(Broker.NAME, (Object) "broker"), Collections.singletonMap(SystemConfig.class.getSimpleName(), systemContextRecord.getId()));
    _portEntry = mock(ConfiguredObjectRecord.class);
    when(_portEntry.getId()).thenReturn(_portEntryId);
    when(_portEntry.getParents()).thenReturn(Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
    when(_portEntry.getType()).thenReturn(Port.class.getSimpleName());
    final ArgumentCaptor<ConfiguredObjectRecordHandler> recovererArgumentCaptor = ArgumentCaptor.forClass(ConfiguredObjectRecordHandler.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(final InvocationOnMock invocation) throws Throwable {
            ConfiguredObjectRecordHandler recoverer = recovererArgumentCaptor.getValue();
            recoverer.handle(_root);
            recoverer.handle(_portEntry);
            return false;
        }
    }).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
    _systemConfigAttributes = new HashMap<>();
    _handler = new ManagementModeStoreHandler(_store, _systemConfig);
    ;
    _handler.init(_systemConfig);
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) AbstractSystemConfig(org.apache.qpid.server.model.AbstractSystemConfig) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) Port(org.apache.qpid.server.model.Port) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) JsonSystemConfigImpl(org.apache.qpid.server.model.JsonSystemConfigImpl) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)

Example 3 with JsonSystemConfigImpl

use of org.apache.qpid.server.model.JsonSystemConfigImpl in project qpid-broker-j by apache.

the class BrokerRecovererTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class), null, new HashMap<String, Object>()) {

        {
            updateModel(BrokerModel.getInstance());
        }
    };
    when(_brokerEntry.getId()).thenReturn(_brokerId);
    when(_brokerEntry.getType()).thenReturn(Broker.class.getSimpleName());
    Map<String, Object> attributesMap = new HashMap<String, Object>();
    attributesMap.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
    attributesMap.put(Broker.NAME, getName());
    when(_brokerEntry.getAttributes()).thenReturn(attributesMap);
    when(_brokerEntry.getParents()).thenReturn(Collections.singletonMap(SystemConfig.class.getSimpleName(), _systemConfig.getId()));
    // Add a base AuthenticationProvider for all tests
    _authenticationProvider1 = mock(AuthenticationProvider.class);
    when(_authenticationProvider1.getName()).thenReturn("authenticationProvider1");
    when(_authenticationProvider1.getId()).thenReturn(_authenticationProvider1Id);
}
Also used : Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) AuthenticationProvider(org.apache.qpid.server.model.AuthenticationProvider) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) JsonSystemConfigImpl(org.apache.qpid.server.model.JsonSystemConfigImpl)

Example 4 with JsonSystemConfigImpl

use of org.apache.qpid.server.model.JsonSystemConfigImpl in project qpid-broker-j by apache.

the class BrokerStoreUpgraderAndRecovererTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    _virtaulHosts = new ArrayList<>();
    _hostId = UUID.randomUUID();
    _brokerId = UUID.randomUUID();
    Map<String, Object> brokerAttributes = new HashMap<>();
    brokerAttributes.put("createdTime", BROKER_CREATE_TIME);
    brokerAttributes.put("defaultVirtualHost", VIRTUALHOST_NAME);
    brokerAttributes.put("modelVersion", "1.3");
    brokerAttributes.put("name", BROKER_NAME);
    brokerAttributes.put("virtualhosts", _virtaulHosts);
    _brokerRecord = mock(ConfiguredObjectRecord.class);
    when(_brokerRecord.getId()).thenReturn(_brokerId);
    when(_brokerRecord.getType()).thenReturn("Broker");
    when(_brokerRecord.getAttributes()).thenReturn(brokerAttributes);
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    _systemConfig = new JsonSystemConfigImpl(_taskExecutor, mock(EventLogger.class), null, new HashMap<String, Object>());
}
Also used : HashMap(java.util.HashMap) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) JsonSystemConfigImpl(org.apache.qpid.server.model.JsonSystemConfigImpl)

Aggregations

HashMap (java.util.HashMap)4 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)4 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)4 JsonSystemConfigImpl (org.apache.qpid.server.model.JsonSystemConfigImpl)4 Broker (org.apache.qpid.server.model.Broker)2 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)1 AuthenticationProvider (org.apache.qpid.server.model.AuthenticationProvider)1 Port (org.apache.qpid.server.model.Port)1 SystemConfig (org.apache.qpid.server.model.SystemConfig)1 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)1 ConfiguredObjectRecordImpl (org.apache.qpid.server.store.ConfiguredObjectRecordImpl)1 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1 GenericRecoverer (org.apache.qpid.server.store.GenericRecoverer)1 ConfiguredObjectRecordHandler (org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1