use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SubstringExtractorTest method testDoesNotRunWhenRegexConditionFails.
@Test
public void testDoesNotRunWhenRegexConditionFails() 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(0, 3), "foo", noConverters(), Extractor.ConditionType.REGEX, "^XXX");
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 testBasicExtractionDoesNotFailOnNonMatch.
@Test
public void testBasicExtractionDoesNotFailOnNonMatch() 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(100, 200), "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 testBasicExtractionWithCutStrategyCanOverwriteSameField.
@Test
public void testBasicExtractionWithCutStrategyCanOverwriteSameField() throws Exception {
Message msg = new Message("The short message", "TestUnit", Tools.nowUTC());
SubstringExtractor x = new SubstringExtractor(metricRegistry, "foo", "foo", 0, Extractor.CursorStrategy.CUT, "message", "message", config(4, 17), "foo", noConverters(), Extractor.ConditionType.NONE, null);
x.runExtractor(msg);
assertEquals("short message", msg.getField("message"));
}
use of org.graylog2.plugin.Message in project graylog2-server by Graylog2.
the class SubstringExtractorTest method testDoesNotRunWhenStringConditionFails.
@Test
public void testDoesNotRunWhenStringConditionFails() 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(0, 3), "foo", noConverters(), Extractor.ConditionType.STRING, "FOOBAR");
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 testBasicExtractionDoesNotFailOnNonMatchWithCutStrategy.
@Test
public void testBasicExtractionDoesNotFailOnNonMatchWithCutStrategy() 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.CUT, "somefield", "our_result", config(100, 200), "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"));
}
Aggregations