コード例 #1
0
  protected StreamRuleMatcher getMatcher(StreamRule rule) {
    StreamRuleMatcher matcher = super.getMatcher(rule);

    assertEquals(matcher.getClass(), RegexMatcher.class);

    return matcher;
  }
コード例 #2
0
  @Test
  public void testMissedMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("^foo");

    Message msg = getSampleMessage();
    msg.addField("something", "zomg");

    StreamRuleMatcher matcher = getMatcher(rule);
    assertFalse(matcher.match(msg, rule));
  }
コード例 #3
0
  @Test
  public void testSuccessfulMatch() {
    StreamRule rule = getSampleRule();
    rule.setValue("^foo");

    Message msg = getSampleMessage();
    msg.addField("something", "foobar");

    StreamRuleMatcher matcher = getMatcher(rule);
    assertTrue(matcher.match(msg, rule));
  }
コード例 #4
0
  @Test
  public void testSuccessfulComplexRegexMatch() {
    StreamRule rule = getSampleRule();
    rule.setField("some_field");
    rule.setValue("foo=^foo|bar\\d.+wat");

    Message msg = getSampleMessage();
    msg.addField("some_field", "bar1foowat");

    StreamRuleMatcher matcher = getMatcher(rule);
    assertTrue(matcher.match(msg, rule));
  }