use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.
the class MessagingACLTest method configureACL.
private void configureACL(String... rules) throws Exception {
EventLoggerProvider eventLoggerProvider = mock(EventLoggerProvider.class);
EventLogger eventLogger = mock(EventLogger.class);
when(eventLoggerProvider.getEventLogger()).thenReturn(eventLogger);
List<AclRule> aclRules = new ArrayList<>();
try (StringReader stringReader = new StringReader(Arrays.stream(rules).collect(Collectors.joining(LINE_SEPARATOR)))) {
RuleSet ruleSet = AclFileParser.parse(stringReader, eventLoggerProvider);
final List<Rule> parsedRules = ruleSet.getAllRules();
for (final Rule rule : parsedRules) {
aclRules.add(new AclRule() {
@Override
public String getIdentity() {
return rule.getIdentity();
}
@Override
public ObjectType getObjectType() {
return rule.getAction().getObjectType();
}
@Override
public LegacyOperation getOperation() {
return rule.getAction().getOperation();
}
@Override
public Map<ObjectProperties.Property, String> getAttributes() {
Map<ObjectProperties.Property, String> attributes = new HashMap<>(rule.getAction().getProperties().asPropertyMap());
FirewallRule firewallRule = rule.getAclAction().getFirewallRule();
if (firewallRule != null) {
if (firewallRule instanceof HostnameFirewallRule) {
attributes.put(ObjectProperties.Property.FROM_HOSTNAME, "127.0.0.1");
} else if (firewallRule instanceof NetworkFirewallRule) {
// tests use only 127.0.0.1 at the moment
attributes.put(ObjectProperties.Property.FROM_NETWORK, "127.0.0.1");
}
}
return attributes;
}
@Override
public RuleOutcome getOutcome() {
return rule.getRuleOutcome();
}
});
}
}
configureACL(aclRules.toArray(new AclRule[aclRules.size()]));
}
use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.
the class BDBHAVirtualHostNodeOperationalLoggingTest method resetEventLogger.
private EventLogger resetEventLogger() {
EventLogger eventLogger = mock(EventLogger.class);
SystemConfig<?> context = (SystemConfig<?>) _helper.getBroker().getParent();
when(context.getEventLogger()).thenReturn(eventLogger);
return eventLogger;
}
use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.
the class AbstractSystemConfig method initiateStartupLogging.
private EventLogger initiateStartupLogging() {
final EventLogger eventLogger = _eventLogger;
final EventLogger startupLogger;
if (isStartupLoggedToSystemOut()) {
// Create the composite (logging+SystemOut MessageLogger to be used during startup
MessageLogger[] messageLoggers = { new SystemOutMessageLogger(), eventLogger.getMessageLogger() };
CompositeStartupMessageLogger startupMessageLogger = new CompositeStartupMessageLogger(messageLoggers);
startupLogger = new EventLogger(startupMessageLogger);
} else {
startupLogger = eventLogger;
}
return startupLogger;
}
use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.
the class VirtualHostCreationTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
EventLogger eventLogger = mock(EventLogger.class);
TaskExecutor executor = CurrentThreadTaskExecutor.newStartedInstance();
SystemConfig systemConfig = mock(SystemConfig.class);
ConfiguredObjectFactory objectFactory = new ConfiguredObjectFactoryImpl(BrokerModel.getInstance());
when(systemConfig.getObjectFactory()).thenReturn(objectFactory);
when(systemConfig.getModel()).thenReturn(objectFactory.getModel());
when(systemConfig.getEventLogger()).thenReturn(eventLogger);
when(systemConfig.getTaskExecutor()).thenReturn(executor);
when(systemConfig.getChildExecutor()).thenReturn(executor);
Broker broker = mock(Broker.class);
when(broker.getObjectFactory()).thenReturn(objectFactory);
when(broker.getModel()).thenReturn(objectFactory.getModel());
when(broker.getCategoryClass()).thenReturn(Broker.class);
when(broker.getParent()).thenReturn(systemConfig);
when(broker.getTaskExecutor()).thenReturn(executor);
when(broker.getChildExecutor()).thenReturn(executor);
_virtualHostNode = BrokerTestHelper.mockWithSystemPrincipal(VirtualHostNode.class, mock(Principal.class));
when(_virtualHostNode.getParent()).thenReturn(broker);
when(_virtualHostNode.getObjectFactory()).thenReturn(objectFactory);
when(_virtualHostNode.getConfigurationStore()).thenReturn(mock(DurableConfigurationStore.class));
when(_virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
when(_virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
when(_virtualHostNode.getTaskExecutor()).thenReturn(executor);
when(_virtualHostNode.getChildExecutor()).thenReturn(executor);
}
use of org.apache.qpid.server.logging.EventLogger in project qpid-broker-j by apache.
the class HeadersBindingTest method setUp.
@Override
protected void setUp() {
_count++;
_queue = mock(Queue.class);
TaskExecutor executor = new CurrentThreadTaskExecutor();
executor.start();
QueueManagingVirtualHost vhost = mock(QueueManagingVirtualHost.class);
when(_queue.getVirtualHost()).thenReturn(vhost);
when(_queue.getModel()).thenReturn(BrokerModel.getInstance());
when(_queue.getTaskExecutor()).thenReturn(executor);
when(_queue.getChildExecutor()).thenReturn(executor);
final EventLogger eventLogger = new EventLogger();
when(vhost.getEventLogger()).thenReturn(eventLogger);
when(vhost.getTaskExecutor()).thenReturn(executor);
when(vhost.getChildExecutor()).thenReturn(executor);
_exchange = mock(Exchange.class);
when(_exchange.getType()).thenReturn(ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
when(_exchange.getEventLogger()).thenReturn(eventLogger);
when(_exchange.getModel()).thenReturn(BrokerModel.getInstance());
when(_exchange.getTaskExecutor()).thenReturn(executor);
when(_exchange.getChildExecutor()).thenReturn(executor);
}
Aggregations