public static BinaryOperatorWithParameterTest
      getNumericParameterDivideTestWithBracketsAfterComparison() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Divide with parameter test with brackets after comparison");

    String parameterName = "amountToDivide";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionBuilder.fromConstant(new Integer(20000), builder)
            .greaterThan(
                ExpressionMath.divide(
                    builder.get("salary"), (builder.getParameter(parameterName))));
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE 20000 > (emp.salary / ?1)";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
  public static BinaryOperatorWithParameterTest getNumericParameterDivideTest() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Divide with parameter test");

    String parameterName = "amountToDivide";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionMath.divide(builder.get("salary"), (builder.getParameter(parameterName)))
            .lessThanEqual(20000);
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE emp.salary / ?1 <= 20000";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
  public static BinaryOperatorWithParameterTest
      getNumericParameterMultiplyTestWithBracketsBeforeComparison() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Multiply with parameter test with brackets before comparison");

    String parameterName = "amountToMultiply";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionMath.multiply(builder.get("salary"), (builder.getParameter(parameterName)))
            .lessThanEqual(100000);
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE (emp.salary * ?1) <= 100000";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));

    return theTest;
  }
 /** getObject. */
 public void test() throws Exception {
   PreparedStatement statement = connection.prepareStatement(sql);
   ResultSet result = statement.executeQuery();
   int size = result.getMetaData().getColumnCount();
   Vector rows = new Vector();
   while (result.next()) {
     Vector row = new Vector(size);
     for (int column = 1; column <= size; column++) {
       Object value = result.getObject(column);
       value = ConversionManager.getDefaultManager().convertObject(value, ClassConstants.SQLDATE);
       row.add(value);
     }
     rows.add(row);
   }
   result.close();
   statement.close();
 }
 public static Vector testInstancesWithBindingAndNoCalendarPrinting() {
   Vector tests = new Vector(calendarStrings.length);
   for (int i = 0; i < calendarStrings.length; i++) {
     tests.add(
         new CalendarToTSTZWithBindingTest(
             i + (calendarStrings.length + 1), calendarStrings[i], false));
   }
   return tests;
 }
 /** Vector. */
 public void test() throws Exception {
   Vector vector = new Vector(10);
   for (int index = 0; index < size; index++) {
     vector.add(new Integer(index));
   }
   for (int index = 0; index < size; index++) {
     Object result = vector.get(index);
   }
 }
  protected void test() {
    for (int i = 0; i <= 1; i++) {
      getSession().getPlatform().setShouldBindAllParameters(i != 0);
      for (int j = 0; j <= 2; j++) {
        query = new ReadAllQuery(Employee.class);
        ExpressionBuilder builder = new ExpressionBuilder();
        Vector vExp = new Vector(2);
        vExp.add(builder.getParameter("p1"));
        query.addArgument("p1");
        vExp.add(builder.getParameter("p2"));
        query.addArgument("p2");
        Expression exp = builder.get("id").in(vExp);
        query.setSelectionCriteria(exp);

        switch (j) {
          case 0:
            // nothing to do - just test the default:
            // query.bindAllParameters == Undefined
            break;
          case 1:
            // query.bindAllParameters == False
            query.setShouldBindAllParameters(false);
            break;
          case 2:
            // query.bindAllParameters == True
            query.setShouldBindAllParameters(true);
            break;
        }

        // clear the writer's buffer
        ((StringWriter) getSession().getLog()).getBuffer().setLength(0);
        try {
          getSession().executeQuery(query, v);
        } catch (DatabaseException e) {
          throw new TestProblemException("executeQuery threw DatabaseException");
        }
        if (shouldBind() != wasBound()) {
          return;
        }
      }
    }
  }
  public void test() {
    int size = getCacheIdentityMap().getMaxSize() * factor;

    for (int i = 0; i < size; i++) {
      BigDecimal id = new java.math.BigDecimal(i);
      Employee employee = new Employee();
      Vector pk = new Vector(1);
      employee.setId(id);
      employee.setFirstName("Joe");
      employee.setLastName("Blow");
      pk.add(id);
      getPrimaryKeys().add(pk);
      getCacheIdentityMap().put(primaryKeys, employee, null, 0);
    }
  }
 /**
  * Verify that the query ran successfully, and that the number of objects returned matches the
  * number of managed employees.
  */
 protected void verify() throws Exception {
   Vector params = new Vector();
   params.add(someManager.getId()); // numberOfManagedEmployees
   try {
     Vector results = (Vector) getSession().executeQuery(query, params);
     if (!(numberOfManagedEmployees == results.size())) {
       throw new TestErrorException(
           results.size()
               + " objects were read from the database, but originially there were, "
               + numberOfManagedEmployees
               + ".");
     }
   } catch (org.eclipse.persistence.exceptions.DatabaseException e) {
     throw new TestErrorException(
         "Custom SQL subquery with parameters failed with a DatabaseException.");
   }
 }
  public static BinaryOperatorWithParameterTest
      getNumericTwoParameterMultipleOperatorsWithBracketsAroundMultiply() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Multiple operators with two parameters with brackets around multiply");

    String parameterNameForDivide = "amountToDivide";
    String parameterNameForMultiply = "amountToMultiply";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterNameForDivide);
    theTest.getExpressionParameters().add(parameterNameForMultiply);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        builder
            .get("salary")
            .greaterThan(
                ExpressionMath.subtract(
                    ExpressionMath.add(
                        ExpressionBuilder.fromConstant(new Integer(50000), builder), 10000),
                    ExpressionMath.divide(
                        ExpressionBuilder.fromConstant(new Integer(10000), builder),
                        ExpressionMath.multiply(
                            builder.getParameter(parameterNameForMultiply),
                            builder.getParameter(parameterNameForDivide)))));
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString =
        "SELECT OBJECT(emp) FROM Employee emp WHERE emp.salary > (50000 + 10000 - 10000 / (?1 * ?2))";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    myArgumentNames.add("2");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));
    theTest.getArguments().addElement(new Integer(5));

    return theTest;
  }
  public void test() {
    Vector primaryKeys = new Vector();
    primaryKeys.add(new java.math.BigDecimal(4));
    CacheKey cacheKey =
        getAbstractSession()
            .getIdentityMapAccessorInstance()
            .acquireDeferredLock(
                primaryKeys, Employee.class, getSession().getDescriptor(Employee.class), false);
    CacheKey cacheKey2 =
        getAbstractSession()
            .getIdentityMapAccessorInstance()
            .acquireDeferredLock(
                primaryKeys, Employee.class, getSession().getDescriptor(Employee.class), false);
    if (cacheKey != cacheKey2) {
      throw new TestErrorException(
          "WeakIdentityMap failed to return same cachkey for successive calls for same primary key and class");
    }

    // must release because the deferred lock is not removed on an initialize identity map
    cacheKey.releaseDeferredLock();
    cacheKey2.releaseDeferredLock();
  }
  public static BinaryOperatorWithParameterTest getNumericParameterLessThanEqualTest() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Less than equal to with parameter test");

    String parameterName = "id";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterName);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause = builder.get("id").lessThanEqual(builder.getParameter(parameterName));
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
    ejbqlString = ejbqlString + "emp.id <= ?1 ";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    theTest.setArgumentNames(myArgumentNames);

    return theTest;
  }
  public static BinaryOperatorWithParameterTest
      getNumericTwoParameterMultipleOperatorsWithBracketsAroundPlusMinus() {
    BinaryOperatorWithParameterTest theTest = new BinaryOperatorWithParameterTest();
    theTest.setName("Multiple operators with two parameters with brackets around plus/minus");

    String parameterNameForDivide = "amountToDivide";
    String parameterNameForMultiply = "amountToMultiply";
    theTest.setExpressionParameters(new Vector());
    theTest.getExpressionParameters().add(parameterNameForDivide);
    theTest.getExpressionParameters().add(parameterNameForMultiply);

    ExpressionBuilder builder = new ExpressionBuilder();
    Expression whereClause =
        ExpressionMath.multiply(
                ExpressionMath.divide(
                    ExpressionMath.subtract(ExpressionMath.add(builder.get("salary"), 10), 20),
                    builder.getParameter(parameterNameForDivide)),
                builder.getParameter(parameterNameForMultiply))
            .greaterThanEqual(70000);
    theTest.setOriginalObjectExpression(whereClause);

    String ejbqlString =
        "SELECT OBJECT(emp) FROM Employee emp WHERE (emp.salary + 10 - 20) / ?1 * ?2 >= 70000";

    theTest.setEjbqlString(ejbqlString);
    Vector myArgumentNames = new Vector();
    myArgumentNames.add("1");
    myArgumentNames.add("2");
    theTest.setArgumentNames(myArgumentNames);

    theTest.setArguments(new Vector());
    theTest.getArguments().addElement(new Integer(2));
    theTest.getArguments().addElement(new Integer(3));

    return theTest;
  }