Search in sources :

Example 1 with Model

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);
    }
}
Also used : TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) Broker(org.apache.qpid.server.model.Broker) EventLogger(org.apache.qpid.server.logging.EventLogger) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model) File(java.io.File)

Example 2 with Model

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();
}
Also used : Context(ch.qos.logback.core.Context) Appender(ch.qos.logback.core.Appender) ListAppender(ch.qos.logback.core.read.ListAppender) TaskExecutorImpl(org.apache.qpid.server.configuration.updater.TaskExecutorImpl) Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) AbstractBrokerLogger(org.apache.qpid.server.logging.logback.AbstractBrokerLogger) BrokerModel(org.apache.qpid.server.model.BrokerModel) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 3 with Model

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));
}
Also used : Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 4 with Model

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);
}
Also used : HashMap(java.util.HashMap) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine) TestCar(org.apache.qpid.server.model.testmodels.hierarchy.TestCar)

Example 5 with Model

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));
}
Also used : Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Aggregations

Model (org.apache.qpid.server.model.Model)25 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)14 Broker (org.apache.qpid.server.model.Broker)9 HashMap (java.util.HashMap)8 BrokerModel (org.apache.qpid.server.model.BrokerModel)8 TaskExecutorImpl (org.apache.qpid.server.configuration.updater.TaskExecutorImpl)6 Map (java.util.Map)5 EventLogger (org.apache.qpid.server.logging.EventLogger)5 ConfiguredObjectAttribute (org.apache.qpid.server.model.ConfiguredObjectAttribute)5 ConfiguredObjectTypeRegistry (org.apache.qpid.server.model.ConfiguredObjectTypeRegistry)5 ArrayList (java.util.ArrayList)4 SystemConfig (org.apache.qpid.server.model.SystemConfig)3 File (java.io.File)2 Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Set (java.util.Set)2 ConfiguredSettableAttribute (org.apache.qpid.server.model.ConfiguredSettableAttribute)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 Appender (ch.qos.logback.core.Appender)1