use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SplitAndIndexExtractorTest method testBasicExtraction.
@Test
public void testBasicExtraction() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");
SplitAndIndexExtractor x = new SplitAndIndexExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.COPY, "somefield", "our_result", config(" ", 4), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
assertNotNull(msg.getField("our_result"));
assertEquals("<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001", msg.getField("somefield"));
assertEquals("2013", msg.getField("our_result"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SplitAndIndexExtractorTest method testBasicExtractionDoesNotFailOnTooHighIndex.
@Test
public void testBasicExtractionDoesNotFailOnTooHighIndex() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");
SplitAndIndexExtractor x = new SplitAndIndexExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.COPY, "somefield", "our_result", config(" ", 9001), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
assertNull(msg.getField("our_result"));
assertEquals("<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001", msg.getField("somefield"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SplitAndIndexExtractorTest method testBasicExtractionDoesNotFailOnNonExistentSplitCharWithCutStrategy.
@Test
public void testBasicExtractionDoesNotFailOnNonExistentSplitCharWithCutStrategy() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");
SplitAndIndexExtractor x = new SplitAndIndexExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.CUT, "somefield", "our_result", config("_", 9001), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
assertNull(msg.getField("our_result"));
assertEquals("<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001", msg.getField("somefield"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SubstringExtractorTest method testBasicExtraction.
@Test
public void testBasicExtraction() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
msg.addField("somefield", "<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001");
SubstringExtractor x = new SubstringExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.COPY, "somefield", "our_result", config(17, 30), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
assertNotNull(msg.getField("our_result"));
assertEquals("<10> 07 Aug 2013 somesubsystem: this is my message for username9001 id:9001", msg.getField("somefield"));
assertEquals("somesubsystem", msg.getField("our_result"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SubstringExtractorTest method testDoesNotCutFromStandardFields.
@Test
public void testDoesNotCutFromStandardFields() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
SubstringExtractor x = new SubstringExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.CUT, "message", "our_result", config(0, 3), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
// Would be cut to "short message" if cutting from standard field was allowed.
assertEquals("The short message", msg.getField("message"));
}
Aggregations