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