use of org.apache.qpid.server.model.Model in project qpid-broker-j by apache.
the class BrokerFileLoggerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
_taskExecutor = new TaskExecutorImpl();
_taskExecutor.start();
Model model = BrokerModel.getInstance();
EventLogger eventLogger = mock(EventLogger.class);
SystemConfig<?> systemConfig = mock(SystemConfig.class);
when(systemConfig.getModel()).thenReturn(model);
when(systemConfig.getChildExecutor()).thenReturn(_taskExecutor);
when(systemConfig.getEventLogger()).thenReturn(eventLogger);
doReturn(SystemConfig.class).when(systemConfig).getCategoryClass();
_broker = mock(Broker.class);
when(_broker.getModel()).thenReturn(model);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
when(_broker.getParent()).thenReturn(systemConfig);
doReturn(Broker.class).when(_broker).getCategoryClass();
_baseFolder = new File(TMP_FOLDER, "test-sub-folder");
_logFile = new File(_baseFolder, "tmp-broker-host.log." + System.currentTimeMillis());
if (_baseFolder.exists()) {
FileUtils.delete(_baseFolder, true);
}
}
use of org.apache.qpid.server.model.Model in project qpid-broker-j by apache.
the class BrokerLoggerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
_taskExecutor = new TaskExecutorImpl();
_taskExecutor.start();
_loggerAppender = new ListAppender<>();
_loggerAppender.setName(APPENDER_NAME);
Model model = BrokerModel.getInstance();
_broker = mock(Broker.class);
when(_broker.getCategoryClass()).thenReturn(Broker.class);
when(_broker.getTypeClass()).thenReturn(Broker.class);
when(_broker.getModel()).thenReturn(model);
when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
doReturn(Broker.class).when(_broker).getCategoryClass();
Map<String, Object> attributes = new HashMap<>();
attributes.put("name", APPENDER_NAME);
_brokerLogger = new AbstractBrokerLogger(attributes, _broker) {
@Override
public Appender<ILoggingEvent> createAppenderInstance(Context context) {
return _loggerAppender;
}
};
_brokerLogger.open();
}
use of org.apache.qpid.server.model.Model in project qpid-broker-j by apache.
the class ConfiguredObjectToMapConverterTest method testConfiguredObjectWithChildAndDepth1.
public void testConfiguredObjectWithChildAndDepth1() {
final String childAttributeName = "childattribute";
final String childAttributeValue = "childvalue";
Model model = createTestModel();
TestChild mockChild = mock(TestChild.class);
when(mockChild.getModel()).thenReturn(model);
when(_configuredObject.getModel()).thenReturn(model);
configureMockToReturnOneAttribute(mockChild, childAttributeName, childAttributeValue);
when(_configuredObject.getChildren(TestChild.class)).thenReturn(Arrays.asList(mockChild));
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, new ConfiguredObjectToMapConverter.ConverterOptions(1, false, 120, false, false));
assertEquals("Unexpected parent map size", 1, resultMap.size());
final List<Map<String, Object>> childList = (List<Map<String, Object>>) resultMap.get("testchilds");
assertEquals("Unexpected number of children", 1, childList.size());
final Map<String, Object> childMap = childList.get(0);
assertEquals("Unexpected child map size", 1, childMap.size());
assertNotNull(childMap);
assertEquals("Unexpected child attribute value", childAttributeValue, childMap.get(childAttributeName));
}
use of org.apache.qpid.server.model.Model in project qpid-broker-j by apache.
the class ConfiguredObjectToMapConverterTest method createEngineWithContext.
private TestEngine createEngineWithContext() {
setTestSystemProperty(TEST_SYSTEM_PROPERTY1_NAME, TEST_SYSTEM_PROPERTY1_ACTUAL_VALUE);
setTestSystemProperty(TEST_SYSTEM_PROPERTY2_NAME, TEST_SYSTEM_PROPERTY2_ACTUAL_VALUE);
Model model = org.apache.qpid.server.model.testmodels.hierarchy.TestModel.getInstance();
final Map<String, Object> carAttributes = new HashMap<>();
carAttributes.put(ConfiguredObject.NAME, "myCar");
Map<String, String> carContext = new HashMap<>();
carContext.put(PARENT_CONTEXT_PROPERTY1_NAME, PARENT_CONTEXT_PROPERTY1_ACTUAL_VALUE);
carContext.put(PARENT_CONTEXT_PROPERTY2_NAME, PARENT_CONTEXT_PROPERTY2_ACTUAL_VALUE);
carAttributes.put(ConfiguredObject.CONTEXT, carContext);
TestCar car = model.getObjectFactory().create(TestCar.class, carAttributes, null);
final Map<String, Object> engineAttributes = new HashMap<>();
engineAttributes.put(ConfiguredObject.NAME, "myEngine");
engineAttributes.put(ConfiguredObject.TYPE, TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
Map<String, String> engineContext = new HashMap<>();
engineContext.put(CHILD_CONTEXT_PROPERTY_NAME, CHILD_CONTEXT_PROPERTY_ACTUAL_VALUE);
engineAttributes.put(ConfiguredObject.CONTEXT, engineContext);
return (TestEngine) car.createChild(TestEngine.class, engineAttributes);
}
use of org.apache.qpid.server.model.Model in project qpid-broker-j by apache.
the class ConfiguredObjectToMapConverterTest method testConfiguredObjectWithSingleNonConfiguredObjectAttribute.
public void testConfiguredObjectWithSingleNonConfiguredObjectAttribute() throws Exception {
final String attributeName = "attribute";
final String attributeValue = "value";
Model model = createTestModel();
when(_configuredObject.getModel()).thenReturn(model);
configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue);
Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, new ConfiguredObjectToMapConverter.ConverterOptions(0, false, 120, false, false));
assertEquals("Unexpected number of attributes", 1, resultMap.size());
assertEquals("Unexpected attribute value", attributeValue, resultMap.get(attributeName));
}
Aggregations