Package oi.thekraken.grok.api

Examples of oi.thekraken.grok.api.Match


  public void test005_captureSubName() throws GrokException {
    String name = "foo";
    String subname = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc:def";
    grok.addPattern(name, "\\w+");
    grok.compile("%{"+name+":"+subname+"}");
    Match m = grok.match("Hello");
    m.captures();
    assertEquals(1, m.toMap().size());
    assertEquals("Hello", m.toMap().get(subname).toString());
    assertEquals("{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_abc:def=Hello}", m.toMap().toString());
  }
View Full Code Here


  }

  @Test
  public void test_002_match_within_instance() {
    // Verify that the instances are equal for the same thread
    Match m1 = Match.getInstance();
    Match m2 = Match.getInstance();
    assertEquals(m1, m2);
  }
View Full Code Here

    BufferedReader br = new BufferedReader(new FileReader(LOG_FILE));
    String line;
    System.out.println("Starting test with linux messages log -- may take a while");
    while ((line = br.readLine()) != null) {
      Match gm = g.match(line);
      gm.captures();
      assertNotNull(gm.toJson());
      assertNotEquals("{\"Error\":\"Error\"}", gm.toJson());
    }
    br.close();
  }
View Full Code Here

    BufferedReader br = new BufferedReader(new FileReader(LOG_FILE));
    String line;
    System.out.println("Starting test with httpd log");
    while ((line = br.readLine()) != null) {
      //System.out.println(line);
      Match gm = g.match(line);
      gm.captures();
      assertNotNull(gm.toJson());
      assertNotEquals("{\"Error\":\"Error\"}", gm.toJson());
    }
    br.close();
  }
View Full Code Here

    File dir = new File(LOG_DIR_NASA);
    for (File child : dir.listFiles()) {
      br = new BufferedReader(new FileReader(LOG_DIR_NASA + child.getName()));
      while ((line = br.readLine()) != null) {
        //System.out.println(child.getName() + " " +line);
        Match gm = g.match(line);
        gm.captures();
        assertNotNull(gm.toJson());
        assertNotEquals("{\"Error\":\"Error\"}", gm.toJson());
      }
      br.close();
    }
  }
View Full Code Here

  @Test
  public void test001_static_metod_factory() throws Throwable {

    Grok staticGrok = Grok.create("patterns/patterns", "%{USERNAME}");
    Match gm = staticGrok.match("root");
    gm.captures();
    assertEquals("{USERNAME=root}", gm.toMap().toString());

    gm = staticGrok.match("r00t");
    gm.captures();
    assertEquals("{USERNAME=r00t}", gm.toMap().toString());

    gm = staticGrok.match("guest");
    gm.captures();
    assertEquals("{USERNAME=guest}", gm.toMap().toString());

    gm = staticGrok.match("guest1234");
    gm.captures();
    assertEquals("{USERNAME=guest1234}", gm.toMap().toString());

    gm = staticGrok.match("john doe");
    gm.captures();
    assertEquals("{USERNAME=john}", gm.toMap().toString());
  }
View Full Code Here

  public void test001_username() throws Throwable {

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{USERNAME}");

    Match gm = g.match("root");
    gm.captures();
    assertEquals("{USERNAME=root}", gm.toMap().toString());

    gm = g.match("r00t");
    gm.captures();
    assertEquals("{USERNAME=r00t}", gm.toMap().toString());

    gm = g.match("guest");
    gm.captures();
    assertEquals("{USERNAME=guest}", gm.toMap().toString());

    gm = g.match("guest1234");
    gm.captures();
    assertEquals("{USERNAME=guest1234}", gm.toMap().toString());

    gm = g.match("john doe");
    gm.captures();
    assertEquals("{USERNAME=john}", gm.toMap().toString());
  }
View Full Code Here

  public void test001_username2() throws Throwable {

    g.addPatternFromFile("patterns/patterns");
    g.compile("%{USER}");

    Match gm = g.match("root");
    gm.captures();
    assertEquals("{USER=root}", gm.toMap().toString());

    gm = g.match("r00t");
    gm.captures();
    assertEquals("{USER=r00t}", gm.toMap().toString());

    gm = g.match("guest");
    gm.captures();
    assertEquals("{USER=guest}", gm.toMap().toString());

    gm = g.match("guest1234");
    gm.captures();
    assertEquals("{USER=guest1234}", gm.toMap().toString());

    gm = g.match("john doe");
    gm.captures();
    assertEquals("{USER=john}", gm.toMap().toString());
  }
View Full Code Here

TOP

Related Classes of oi.thekraken.grok.api.Match

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.