Search in sources :

Example 11 with ConfiguredObjectRecord

use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method testSaveCLIHttpPort.

public void testSaveCLIHttpPort() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 1000);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    UUID portId = getOptionsPortId(records);
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Port.NAME, "TEST");
    ConfiguredObjectRecord configurationEntry = new ConfiguredObjectRecordImpl(portId, Port.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), getRootEntry(records).getId()));
    try {
        _handler.update(false, configurationEntry);
        fail("Exception should be thrown on trying to save CLI port");
    } catch (IllegalConfigurationException e) {
    // pass
    }
}
Also used : ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) HashMap(java.util.HashMap) Port(org.apache.qpid.server.model.Port) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 12 with ConfiguredObjectRecord

use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method testHttpPortEntryIsQuiesced.

public void testHttpPortEntryIsQuiesced() {
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(Port.PROTOCOLS, Collections.singleton(Protocol.HTTP));
    when(_portEntry.getAttributes()).thenReturn(attributes);
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 9090);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord portEntry = getEntry(records, _portEntryId);
    assertEquals("Unexpected state", State.QUIESCED, portEntry.getAttributes().get(Port.STATE));
}
Also used : HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord)

Example 13 with ConfiguredObjectRecord

use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method testRemove.

public void testRemove() {
    _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_HTTP_PORT_OVERRIDE, 1000);
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord record = new ConfiguredObjectRecord() {

        @Override
        public UUID getId() {
            return _portEntryId;
        }

        @Override
        public String getType() {
            return Port.class.getSimpleName();
        }

        @Override
        public Map<String, Object> getAttributes() {
            return Collections.emptyMap();
        }

        @Override
        public Map<String, UUID> getParents() {
            return null;
        }
    };
    _handler.remove(record);
    verify(_store).remove(record);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 14 with ConfiguredObjectRecord

use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method getOptionsPortId.

private UUID getOptionsPortId(Collection<ConfiguredObjectRecord> records) {
    ConfiguredObjectRecord root = getRootEntry(records);
    assertEquals("Unexpected root id", _rootId, root.getId());
    Collection<UUID> childrenIds = getChildrenIds(records, root);
    childrenIds.remove(_portEntryId);
    UUID optionsPort = childrenIds.iterator().next();
    return optionsPort;
}
Also used : ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) UUID(java.util.UUID)

Example 15 with ConfiguredObjectRecord

use of org.apache.qpid.server.store.ConfiguredObjectRecord in project qpid-broker-j by apache.

the class ManagementModeStoreHandlerTest method virtualHostEntryQuiescedStatusTestImpl.

private void virtualHostEntryQuiescedStatusTestImpl(boolean mmQuiesceVhosts) {
    UUID virtualHostId = UUID.randomUUID();
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put(VirtualHost.TYPE, "STANDARD");
    final ConfiguredObjectRecord virtualHost = new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), attributes, Collections.singletonMap(Broker.class.getSimpleName(), _root.getId()));
    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);
            recoverer.handle(virtualHost);
            return false;
        }
    }).when(_store).openConfigurationStore(recovererArgumentCaptor.capture());
    State expectedState = mmQuiesceVhosts ? State.QUIESCED : null;
    if (mmQuiesceVhosts) {
        _systemConfigAttributes.put(SystemConfig.MANAGEMENT_MODE_QUIESCE_VIRTUAL_HOSTS, mmQuiesceVhosts);
    }
    _handler = createManagementModeStoreHandler();
    _handler.init(_systemConfig);
    Collection<ConfiguredObjectRecord> records = openAndGetRecords();
    ConfiguredObjectRecord hostEntry = getEntry(records, virtualHostId);
    Map<String, Object> hostAttributes = new HashMap<String, Object>(hostEntry.getAttributes());
    assertEquals("Unexpected state", expectedState, hostAttributes.get(VirtualHost.STATE));
    hostAttributes.remove(VirtualHost.STATE);
    assertEquals("Unexpected attributes", attributes, hostAttributes);
}
Also used : HashMap(java.util.HashMap) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) ConfiguredObjectRecordImpl(org.apache.qpid.server.store.ConfiguredObjectRecordImpl) InvocationOnMock(org.mockito.invocation.InvocationOnMock) State(org.apache.qpid.server.model.State) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) VirtualHost(org.apache.qpid.server.model.VirtualHost) UUID(java.util.UUID) ConfiguredObjectRecordHandler(org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)

Aggregations

ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)58 HashMap (java.util.HashMap)27 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)25 UUID (java.util.UUID)24 ConfiguredObjectRecordImpl (org.apache.qpid.server.store.ConfiguredObjectRecordImpl)14 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)13 ArrayList (java.util.ArrayList)12 ConfiguredObjectRecordHandler (org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler)8 LinkedHashMap (java.util.LinkedHashMap)6 IOException (java.io.IOException)5 Transaction (com.sleepycat.je.Transaction)4 Map (java.util.Map)4 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)4 StoreException (org.apache.qpid.server.store.StoreException)4 Mockito.doAnswer (org.mockito.Mockito.doAnswer)4 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 Answer (org.mockito.stubbing.Answer)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3