Search in sources :

Example 1 with BrokerLogger

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

the class BrokerMemoryLoggerTest method testCreateDeleteBrokerMemoryLogger.

public void testCreateDeleteBrokerMemoryLogger() {
    final String brokerLoggerName = "TestBrokerLogger";
    ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    Broker broker = _systemConfig.getContainer(Broker.class);
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(ConfiguredObject.NAME, brokerLoggerName);
    attributes.put(ConfiguredObject.TYPE, BrokerMemoryLogger.TYPE);
    BrokerLogger brokerLogger = (BrokerLogger) broker.createChild(BrokerLogger.class, attributes);
    assertEquals("Created BrokerLogger has unexpected name", brokerLoggerName, brokerLogger.getName());
    assertTrue("BrokerLogger has unexpected type", brokerLogger instanceof BrokerMemoryLogger);
    assertNotNull("Appender not attached to root logger after BrokerLogger creation", rootLogger.getAppender(brokerLoggerName));
    brokerLogger.delete();
    assertNull("Appender should be no longer attached to root logger after BrokerLogger deletion", rootLogger.getAppender(brokerLoggerName));
}
Also used : Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) Logger(org.slf4j.Logger) BrokerLogger(org.apache.qpid.server.model.BrokerLogger) EventLogger(org.apache.qpid.server.logging.EventLogger) BrokerLogger(org.apache.qpid.server.model.BrokerLogger) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 2 with BrokerLogger

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

the class BrokerMemoryLoggerTest method doMemoryLoggerLimitsTest.

private void doMemoryLoggerLimitsTest(final int illegalValue, final int legalValue) {
    final String brokerLoggerName = "TestBrokerLogger";
    Broker broker = _systemConfig.getContainer(Broker.class);
    Map<String, Object> attributes = new HashMap<>();
    attributes.put(ConfiguredObject.NAME, brokerLoggerName);
    attributes.put(ConfiguredObject.TYPE, BrokerMemoryLogger.TYPE);
    attributes.put(BrokerMemoryLogger.MAX_RECORDS, illegalValue);
    try {
        broker.createChild(BrokerLogger.class, attributes);
        fail("Exception not thrown");
    } catch (IllegalConfigurationException ice) {
    // PASS
    }
    attributes.put(BrokerMemoryLogger.MAX_RECORDS, legalValue);
    BrokerLogger brokerLogger = (BrokerLogger) broker.createChild(BrokerLogger.class, attributes);
    try {
        brokerLogger.setAttributes(Collections.singletonMap(BrokerMemoryLogger.MAX_RECORDS, illegalValue));
        fail("Exception not thrown");
    } catch (IllegalConfigurationException ice) {
    // PASS
    } finally {
        brokerLogger.delete();
    }
}
Also used : Broker(org.apache.qpid.server.model.Broker) HashMap(java.util.HashMap) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) BrokerLogger(org.apache.qpid.server.model.BrokerLogger) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Aggregations

HashMap (java.util.HashMap)2 Broker (org.apache.qpid.server.model.Broker)2 BrokerLogger (org.apache.qpid.server.model.BrokerLogger)2 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 Logger (org.slf4j.Logger)1