use of org.apache.camel.component.splunk.event.SplunkEvent in project camel by apache.
the class ConsumerStreamingTest method testSearch.
@Test
public void testSearch() throws Exception {
MockEndpoint searchMock = getMockEndpoint("mock:search-result");
searchMock.expectedMessageCount(3);
JobCollection jobCollection = mock(JobCollection.class);
Job jobMock = mock(Job.class);
when(service.getJobs()).thenReturn(jobCollection);
when(jobCollection.create(anyString(), any(JobArgs.class))).thenReturn(jobMock);
when(jobMock.isDone()).thenReturn(Boolean.TRUE);
InputStream stream = ConsumerTest.class.getResourceAsStream("/resultsreader_test_data.json");
when(jobMock.getResults(any(JobResultsArgs.class))).thenReturn(stream);
assertMockEndpointsSatisfied();
SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
assertNotNull(recieved);
Map<String, String> data = recieved.getEventData();
assertEquals("indexertpool", data.get("name"));
stream.close();
}
use of org.apache.camel.component.splunk.event.SplunkEvent in project camel by apache.
the class ConsumerTest method testSearch.
@Test
public void testSearch() throws Exception {
MockEndpoint searchMock = getMockEndpoint("mock:search-result");
searchMock.expectedMessageCount(3);
searchMock.expectedPropertyReceived(Exchange.BATCH_SIZE, 3);
JobCollection jobCollection = mock(JobCollection.class);
Job jobMock = mock(Job.class);
when(service.getJobs()).thenReturn(jobCollection);
when(jobCollection.create(anyString(), any(JobArgs.class))).thenReturn(jobMock);
when(jobMock.isDone()).thenReturn(Boolean.TRUE);
InputStream stream = ConsumerTest.class.getResourceAsStream("/resultsreader_test_data.json");
when(jobMock.getResults(any(JobResultsArgs.class))).thenReturn(stream);
assertMockEndpointsSatisfied();
SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
assertNotNull(recieved);
Map<String, String> data = recieved.getEventData();
assertEquals("indexertpool", data.get("name"));
assertEquals(true, searchMock.getReceivedExchanges().get(2).getProperty(Exchange.BATCH_COMPLETE, Boolean.class));
stream.close();
}
use of org.apache.camel.component.splunk.event.SplunkEvent in project camel by apache.
the class ProducerTest method testTcpWriter.
@Test
public void testTcpWriter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:tcpresult");
mock.setExpectedMessageCount(1);
SplunkEvent splunkEvent = new SplunkEvent();
splunkEvent.addPair("key1", "value1");
splunkEvent.addPair("key2", "value2");
splunkEvent.addPair("key3", "value3");
template.sendBody("direct:tcp", splunkEvent);
assertMockEndpointsSatisfied();
Producer tcpProducer = tcpEndpoint.createProducer();
assertIsInstanceOf(TcpDataWriter.class, ((SplunkProducer) tcpProducer).getDataWriter());
}
use of org.apache.camel.component.splunk.event.SplunkEvent in project camel by apache.
the class ProducerTest method testStreamWriter.
@Test
public void testStreamWriter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:stream-result");
mock.setExpectedMessageCount(1);
SplunkEvent splunkEvent = new SplunkEvent();
splunkEvent.addPair("key11", "value1");
splunkEvent.addPair("key22", "value2");
splunkEvent.addPair("key33", "value3");
template.sendBody("direct:stream", splunkEvent);
assertMockEndpointsSatisfied();
Producer streamProducer = streamEndpoint.createProducer();
assertIsInstanceOf(StreamDataWriter.class, ((SplunkProducer) streamProducer).getDataWriter());
}
use of org.apache.camel.component.splunk.event.SplunkEvent in project camel by apache.
the class SplunkEventTest method testEventDataWithQuotedValues.
@Test
public void testEventDataWithQuotedValues() {
Date now = new Date();
SplunkEvent event = new SplunkEvent("testevent", "123", false, true);
event.addPair("key1", "value1");
event.addPair("key2", "value2 with whitespace");
event.addPair(SplunkEvent.COMMON_DVC_TIME, now);
assertEquals("Values should be quoted", "name=\"testevent\" event_id=\"123\" key1=\"value1\" key2=\"value2 with whitespace\" dvc_time=\"" + now.toString() + "\"\n", event.toString());
assertEquals(5, event.getEventData().size());
assertTrue(event.getEventData().get("key2").equals("value2 with whitespace"));
}
Aggregations