Package oi.thekraken.grok.api

Examples of oi.thekraken.grok.api.Match.captures()


            "November", "Dec", "December"};
    List<String> months = new ArrayList<String>(Arrays.asList(array));
    int i = 0;
    for (String month : months) {
      Match m = grok.match(month);
      m.captures();
      assertNotNull(m.toMap());
      assertEquals(m.toMap().get("MONTH"), months.get(i));
      i++;
    }
  }
View Full Code Here


    List<String> times = new ArrayList<String>(Arrays.asList(array));
    int i = 0;
    for (String time : times) {
      Match m = grok.match(time);
      m.captures();
      assertNotNull(m.toMap());
      assertEquals(m.toMap().get("TIMESTAMP_ISO8601"), times.get(i));
      i++;
    }
  }
View Full Code Here

    List<String> uris = new ArrayList<String>(Arrays.asList(array));
    int i = 0;
    for (String uri : uris) {
      Match m = grok.match(uri);
      m.captures();
      assertNotNull(m.toMap());
      assertEquals(m.toMap().get("URI"), uris.get(i));
      assertNotNull(m.toMap().get("URIPROTO"));
      i++;
    }
View Full Code Here

        };
    List<String> uris = new ArrayList<String>(Arrays.asList(array));
    int i = 0;
    for (String uri : uris) {
      Match m = grok.match(uri);
      m.captures();
      assertNotNull(m.toMap());
      if (i == 2) {
        assertEquals(Collections.EMPTY_MAP, m.toMap());
      }
      i++;
View Full Code Here

    grok.addPattern("foo", ".*");
    grok.compile("%{foo}");
    Match m = grok.match("Hello World");
    assertEquals("(?<name0>.*)", grok.getNamedRegex());
    assertEquals("Hello World", m.getSubject());
    m.captures();
    assertEquals(1, m.toMap().size());
    assertEquals("Hello World", m.toMap().get("foo"));
    assertEquals("{foo=Hello World}", m.toMap().toString());
  }

View Full Code Here

    grok.addPattern("bar", ".*");
    grok.compile("%{foo} %{bar}");
    Match m = grok.match("Hello World");
    assertEquals("(?<name0>.*) (?<name1>.*)", grok.getNamedRegex());
    assertEquals("Hello World", m.getSubject());
    m.captures();
    assertEquals(2, m.toMap().size());
    assertEquals("Hello", m.toMap().get("foo"));
    assertEquals("World", m.toMap().get("bar"));
    assertEquals("{bar=World, foo=Hello}", m.toMap().toString());
  }
View Full Code Here

    grok.addPattern("bar", "\\w+");
    grok.compile("%{foo}");
    Match m = grok.match("Hello World");
    assertEquals("(?<name0>\\w+ (?<name1>\\w+))", grok.getNamedRegex());
    assertEquals("Hello World", m.getSubject());
    m.captures();
    assertEquals(2, m.toMap().size());
    assertEquals("Hello World", m.toMap().get("foo"));
    assertEquals("World", m.toMap().get("bar"));
    assertEquals("{bar=World, foo=Hello World}", m.toMap().toString());
  }
View Full Code Here

    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

    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

    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

TOP
Copyright © 2018 www.massapi.com. 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.