Examples of captures()


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

    days.add("Sunday");

    int i = 0;
    for(String day : days){
      Match m = grok.match(day);
      m.captures();
      assertNotNull(m.toMap());
      assertEquals(m.toMap().get("DAY"), days.get(i));
      i++;
    }
  }
View Full Code Here

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

    BufferedReader br = new BufferedReader(new FileReader("src/test/resources/ip"));
    String line;
    System.out.println("Starting test with ip");
    while ((line = br.readLine()) != null) {
      Match gm = grok.match(line);
      gm.captures();
      assertNotNull(gm.toJson());
      assertNotEquals("{\"Error\":\"Error\"}", gm.toJson());
      assertEquals(gm.toMap().get("IP"), line);
    }
  }
View Full Code Here

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

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

    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

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

    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

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

        };
    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

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

    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

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

    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

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

    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

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

    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
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.