use of org.opennms.netmgt.config.syslogd.ProcessMatch in project opennms by OpenNMS.
the class SyslogdIT method setUp.
@Before
public void setUp() throws Exception {
MockLogAppender.setupLogging();
MockLogAppender.resetState();
InputStream stream = null;
try {
stream = ConfigurationTestUtils.getInputStreamForResource(this, "/etc/syslogd-configuration.xml");
m_config = new SyslogdConfigFactory(stream);
} finally {
if (stream != null) {
IOUtils.closeQuietly(stream);
}
}
// Verify that the test syslogd-configuration.xml file was loaded
boolean foundBeer = false;
boolean foundMalt = false;
assertEquals(10514, m_config.getSyslogPort());
for (final UeiMatch match : m_config.getUeiList()) {
if (match.getProcessMatch().isPresent()) {
final ProcessMatch processMatch = match.getProcessMatch().get();
if (!foundBeer && "beerd".equals(processMatch.getExpression())) {
foundBeer = true;
} else if (!foundMalt && "maltd".equals(processMatch.getExpression())) {
foundMalt = true;
}
}
}
assertTrue(foundBeer);
assertTrue(foundMalt);
m_syslogSinkConsumer = new SyslogSinkConsumer(new MetricRegistry());
m_syslogSinkConsumer.setDistPollerDao(m_distPollerDao);
m_syslogSinkConsumer.setSyslogdConfig(m_config);
m_syslogSinkConsumer.setEventForwarder(m_eventIpcManager);
m_syslogSinkModule = m_syslogSinkConsumer.getModule();
m_messageDispatcherFactory.setConsumer(m_syslogSinkConsumer);
SyslogReceiverJavaNetImpl receiver = new SyslogReceiverJavaNetImpl(m_config);
receiver.setDistPollerDao(m_distPollerDao);
receiver.setMessageDispatcherFactory(m_messageDispatcherFactory);
m_syslogd.setSyslogReceiver(receiver);
m_syslogd.init();
SyslogdTestUtils.startSyslogdGracefully(m_syslogd);
}
Aggregations