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
}
}
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));
}
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);
}
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;
}
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);
}
Aggregations