Search in sources :

Example 11 with SyslogMessageLogDTO

use of org.opennms.netmgt.syslogd.api.SyslogMessageLogDTO in project opennms by OpenNMS.

the class SyslogdEventdLoadIT method testNGSyslog.

@Test(timeout = 120000)
@Transactional
public void testNGSyslog() throws Exception {
    loadSyslogConfiguration("/etc/syslogd-syslogng-configuration.xml");
    startSyslogdGracefully();
    m_eventCounter.anticipate();
    InetAddress address = InetAddress.getLocalHost();
    // handle an invalid packet
    byte[] bytes = "<34>main: 2010-08-19 localhost foo0: load test 0 on tty1\0".getBytes();
    DatagramPacket pkt = new DatagramPacket(bytes, bytes.length, address, SyslogClient.PORT);
    SyslogMessageLogDTO messageLog = m_syslogSinkModule.toMessageLog(new SyslogConnection(pkt, false));
    m_syslogSinkConsumer.handleMessage(messageLog);
    // handle a valid packet
    bytes = "<34>monkeysatemybrain!\0".getBytes();
    pkt = new DatagramPacket(bytes, bytes.length, address, SyslogClient.PORT);
    messageLog = m_syslogSinkModule.toMessageLog(new SyslogConnection(pkt, false));
    m_syslogSinkConsumer.handleMessage(messageLog);
    m_eventCounter.waitForFinish(120000);
    assertEquals(1, m_eventCounter.getCount());
}
Also used : SyslogMessageLogDTO(org.opennms.netmgt.syslogd.api.SyslogMessageLogDTO) DatagramPacket(java.net.DatagramPacket) SyslogConnection(org.opennms.netmgt.syslogd.api.SyslogConnection) InetAddress(java.net.InetAddress) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SyslogMessageLogDTO (org.opennms.netmgt.syslogd.api.SyslogMessageLogDTO)11 SyslogConnection (org.opennms.netmgt.syslogd.api.SyslogConnection)10 DatagramPacket (java.net.DatagramPacket)8 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)6 InetAddress (java.net.InetAddress)4 Event (org.opennms.netmgt.xml.event.Event)3 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 EventBuilder (org.opennms.netmgt.model.events.EventBuilder)2 SyslogMessageDTO (org.opennms.netmgt.syslogd.api.SyslogMessageDTO)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 AggregationPolicy (org.opennms.core.ipc.sink.api.AggregationPolicy)1