Exemplo n.º 1
0
  /**
   * search from the table who's name like p%.
   *
   * @throws Exception to Junit
   */
  public void testsearch_accuracy10() throws Exception {
    LikeFilter filter = new LikeFilter("peopleName", "SW:p", '!');

    // search depend the filter
    CustomResultSet result =
        (CustomResultSet) strategy.search(CONTEXT, filter, new ArrayList(), aliasMap);

    List list = new ArrayList();

    // get the result
    while (result.next()) {
      list.add(result.getString("peopleName"));
    }

    assertEquals("There are 9 prople with BetweenFilter", 9, list.size());
  }
Exemplo n.º 2
0
  /**
   * search from the table who's weight < 31.
   *
   * @throws Exception to Junit
   */
  public void testsearch_accuracy5() throws Exception {
    LessThanFilter lessThanFilter = new LessThanFilter("The weight", new Integer(31));

    // search depend the filter
    CustomResultSet result =
        (CustomResultSet) strategy.search(CONTEXT, lessThanFilter, new ArrayList(), aliasMap);

    List list = new ArrayList();

    // get the result
    while (result.next()) {
      list.add(result.getString("peopleName"));
    }

    assertEquals("There are 4 prople with weight < 31", 4, list.size());
  }
Exemplo n.º 3
0
  /**
   * search from the table who's age = 10.
   *
   * @throws Exception to Junit
   */
  public void testsearch_accuracy1() throws Exception {
    EqualToFilter equalToFilter = new EqualToFilter("The age", new Integer(10));

    // search depend the filter
    CustomResultSet result =
        (CustomResultSet) strategy.search(CONTEXT, equalToFilter, new ArrayList(), aliasMap);

    List list = new ArrayList();

    // get the result
    while (result.next()) {
      list.add(result.getString("peopleName"));
    }

    assertEquals("There are 2 prople with age = 10", 2, list.size());
  }
Exemplo n.º 4
0
  /**
   * search from the table who's age = 10 or weight > 30.
   *
   * @throws Exception to Junit
   */
  public void testsearch_accuracy3() throws Exception {
    EqualToFilter equalToFilter = new EqualToFilter("The age", new Integer(10));
    GreaterThanFilter greaterThanFilter = new GreaterThanFilter("The weight", new Integer(30));
    OrFilter orFilter = new OrFilter(equalToFilter, greaterThanFilter);

    // search depend the filter
    CustomResultSet result =
        (CustomResultSet) strategy.search(CONTEXT, orFilter, new ArrayList(), aliasMap);

    List list = new ArrayList();

    // get the result
    while (result.next()) {
      list.add(result.getString("peopleName"));
    }

    assertEquals("There are 6 prople with age = 10 or weight > 30", 6, list.size());
  }
Exemplo n.º 5
0
  /**
   * search from the table who's name in 'p1' or 'p9'.
   *
   * @throws Exception to Junit
   */
  public void testsearch_accuracy8() throws Exception {
    List values = new ArrayList();
    values.add("p1");
    values.add("p9");

    InFilter filter = new InFilter("peopleName", values);

    // search depend the filter
    CustomResultSet result =
        (CustomResultSet) strategy.search(CONTEXT, filter, new ArrayList(), aliasMap);

    List list = new ArrayList();

    // get the result
    while (result.next()) {
      list.add(result.getString("peopleName"));
    }

    assertEquals("There are 2 prople with Infilter", 2, list.size());
  }