Пример #1
0
  @Test
  public void testDeepSuffix() throws Exception {
    srs.addRule(new Pattern("a"), new XAction(1));
    srs.addRule(new Pattern("a/b/*"), new XAction(2));

    for (String s : cc.combinations("a/other")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNull(r);
    }
  }
Пример #2
0
  @Test
  public void testPrefixSuffixInteraction2() throws Exception {
    srs.addRule(new Pattern("tG"), new XAction());
    srs.addRule(new Pattern("tG/tS"), new YAction());
    srs.addRule(new Pattern("tG/tS/test"), new ZAction());
    srs.addRule(new Pattern("tG/tS/test/*"), new XAction(9));

    for (String s : cc.combinations("tG/tS/toto")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNull(r);
    }
  }
Пример #3
0
  @Test
  public void testSuffix() throws Exception {
    srs.addRule(new Pattern("a"), new XAction());
    srs.addRule(new Pattern("a/*"), new YAction());

    for (String s : cc.combinations("a/b")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);
      assertEquals(1, r.size());
      assertTrue(r.get(0) instanceof YAction);
    }
  }
Пример #4
0
  @Test
  public void testTail3() throws Exception {
    srs.addRule(new Pattern("*/b"), new XAction());
    srs.addRule(new Pattern("*/a/b"), new YAction());

    for (String s : cc.combinations("a/b")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);
      assertEquals(1, r.size());

      if (!(r.get(0) instanceof YAction)) {
        fail("Wrong type");
      }
    }
  }
Пример #5
0
  @Test
  public void testPrefixSuffixInteraction1() throws Exception {
    srs.addRule(new Pattern("a"), new ZAction());
    srs.addRule(new Pattern("a/*"), new YAction());
    srs.addRule(new Pattern("*/a/b"), new XAction(3));

    for (String s : cc.combinations("a/b")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);

      assertEquals(1, r.size());

      assertTrue(r.get(0) instanceof XAction);
      XAction xaction = (XAction) r.get(0);
      assertEquals(3, xaction.id);
    }
  }
Пример #6
0
  @Test
  public void testSlashSuffix() throws Exception {
    Pattern pa = new Pattern("a/");
    srs.addRule(pa, new XAction());

    for (String s : cc.combinations("a")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);
      assertEquals(1, r.size());

      if (!(r.get(0) instanceof XAction)) {
        fail("Wrong type");
      }
    }
  }
Пример #7
0
  @Test
  public void smoke() throws Exception {
    srs.addRule(new Pattern("a/b"), new XAction());

    // test for all possible case combinations of "a/b"
    for (String s : cc.combinations("a/b")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);
      assertEquals(1, r.size());

      if (!(r.get(0) instanceof XAction)) {
        fail("Wrong type");
      }
    }
  }
Пример #8
0
  @Test
  public void testTail2() throws Exception {
    SimpleRuleStore srs = new SimpleRuleStore(new ContextBase());
    srs.addRule(new Pattern("*/c"), new XAction());

    for (String s : cc.combinations("a/b/c")) {
      List<Action> r = srs.matchActions(new Pattern(s));
      assertNotNull(r);

      assertEquals(1, r.size());

      if (!(r.get(0) instanceof XAction)) {
        fail("Wrong type");
      }
    }
  }