示例#1
0
文件: QueryJX.java 项目: osi/mulgara
  /**
   * Execute this object. Retrieves a string from the testCase properties and executes it as an iTQL
   * command, returning the results in the testCase object.
   *
   * @param testCase The map object containing the properties.
   * @throws Exception EXCEPTION TO DO
   */
  @SuppressWarnings("unchecked") // JXProperties does not use Generics
  public void eval(JXTestCase testCase) throws Exception {

    JXProperties props = testCase.getProperties();
    String query = (String) props.get(QUERY);

    boolean time = false;
    if (props.getString(TIME) != null) time = Boolean.valueOf(props.getString(TIME)).booleanValue();

    String queryName = query + eol;
    if (props.getString(QUERY_NAME) != null) queryName = props.getString(QUERY_NAME);

    ItqlInterpreterBean iTQL = new ItqlInterpreterBean();

    long start = System.currentTimeMillis();
    String queryResult = "";

    try {
      queryResult = iTQL.executeQueryToString(query);
    } catch (Exception ex) {
      queryResult = ex.getMessage();
    } finally {
      iTQL.close();
    }

    if (time) {
      System.out.println(
          eol
              + "<"
              + queryName
              + "> query has taken "
              + (System.currentTimeMillis() - start)
              + " milliseconds to execute."
              + eol);
    }

    props.put(RESULT, queryResult + eol);
    props.remove(QUERY_NAME);
  }
示例#2
0
文件: QueryJX.java 项目: osi/mulgara
/**
 * Test frame for iTQL queries.
 *
 * @created 2001-12-18
 * @author <a href="http://staff.pisoftware.com/pag">Paul Gearon</a>
 * @company <A href="mailto:[email protected]">Plugged In Software</A>
 * @copyright &copy; 2001-2003 <A href="http://www.PIsoftware.com/">Plugged In Software Pty Ltd</A>
 * @licence <a href="{@docRoot}/../../LICENCE">Mozilla Public License v1.1</a>
 */
public class QueryJX implements JXTestStep {

  /** Get line separator. */
  private static final String eol = System.getProperty("line.separator");

  /** Name of the query command parameter */
  public static final String QUERY = "query";

  /** Parameter name of the results of the command */
  public static final String RESULT = "queryResult";

  /** Parameter name of the time flag */
  public static final String TIME = "time";

  /** Name of the queryName command parameter */
  public static final String QUERY_NAME = "queryName";

  /**
   * Execute this object. Retrieves a string from the testCase properties and executes it as an iTQL
   * command, returning the results in the testCase object.
   *
   * @param testCase The map object containing the properties.
   * @throws Exception EXCEPTION TO DO
   */
  @SuppressWarnings("unchecked") // JXProperties does not use Generics
  public void eval(JXTestCase testCase) throws Exception {

    JXProperties props = testCase.getProperties();
    String query = (String) props.get(QUERY);

    boolean time = false;
    if (props.getString(TIME) != null) time = Boolean.valueOf(props.getString(TIME)).booleanValue();

    String queryName = query + eol;
    if (props.getString(QUERY_NAME) != null) queryName = props.getString(QUERY_NAME);

    ItqlInterpreterBean iTQL = new ItqlInterpreterBean();

    long start = System.currentTimeMillis();
    String queryResult = "";

    try {
      queryResult = iTQL.executeQueryToString(query);
    } catch (Exception ex) {
      queryResult = ex.getMessage();
    } finally {
      iTQL.close();
    }

    if (time) {
      System.out.println(
          eol
              + "<"
              + queryName
              + "> query has taken "
              + (System.currentTimeMillis() - start)
              + " milliseconds to execute."
              + eol);
    }

    props.put(RESULT, queryResult + eol);
    props.remove(QUERY_NAME);
  }
}