public void test() {
    // test readAll
    getSession().readAllObjects(Employee.class);
    getSession().getIdentityMapAccessor().initializeIdentityMap(Employee.class);

    // test readObject
    Employee employee =
        (Employee)
            getSession().readObject(Employee.class, new ExpressionBuilder().get("id").equal(99));

    // test delete with an employee read from the database
    employee = (Employee) getSession().readObject(Employee.class);
    try {
      getAbstractSession().deleteObject(employee);
    } catch (DatabaseException exc) {
      // if we get an integrity exception here, the query went to the DB and was not redirected
      redirectedDeleteObject = false;
    }

    UnitOfWork uow = getSession().acquireUnitOfWork();
    // test update with an employee read from the database
    employee = (Employee) uow.readObject(Employee.class);
    employee.setFirstName(employee.getFirstName() + "-changed");

    // insert an employee to test the insert behavior
    employee = new Employee();
    employee.setFirstName("Paul");
    employee.setLastName("Sheldon");
    uow.registerObject(employee);

    uow.commit();
  }
  /**
   * Return the first employee that has a long enough name for the test. If no match is found throw
   * a warning exception. See bug 223005
   *
   * @param vectorOfEmployees
   * @param minFirstNameLength
   * @param testName
   * @return
   */
  public Employee getEmployeeWithRequiredNameLength(
      Vector vectorOfEmployees, int minFirstNameLength, String testName) {
    Employee empMatch = null;
    Vector<Employee> employees = vectorOfEmployees;
    String firstName;
    StringBuffer partialFirstName;

    // Loop through the collection of employees to find one that matches our test requirements
    for (int i = 0; i < employees.size(); i++) {
      empMatch = employees.get(i);
      firstName = empMatch.getFirstName();
      // Verify length criteria
      if (firstName.length() >= minFirstNameLength) {
        // exit the for loop - return the last empMatch
        i = employees.size();
      }
    }

    // If we could not find a proper employee for testing - throw a warning
    if (null == empMatch) {
      throw new RuntimeException(
          testName
              + " Setup Failed: unable to find an Employee with firstName size of at least  "
              + minFirstNameLength);
    } else {
      return empMatch;
    }
  }
  public static TestSuite getReadObjectTestSuite() {
    TestSuite suite = new TestSuite();
    suite.setName("EmployeeReadObjectTestSuite");
    suite.setDescription("This suite test the reading of each object in the employee demo.");

    Class employeeClass = Employee.class;
    PopulationManager manager = PopulationManager.getDefaultManager();

    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0001")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0002")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0003")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0004")));
    suite.addTest(new ReadObjectTest(manager.getObject(employeeClass, "0005")));

    Employee employee = (Employee) manager.getObject(employeeClass, "0001");
    suite.addTest(
        new ReadObjectCallTest(
            employeeClass,
            new SQLCall(
                "SELECT VERSION, EMP_ID, L_NAME, F_NAME FROM UNIDIR_EMPLOYEE WHERE F_NAME = '"
                    + employee.getFirstName()
                    + "' AND L_NAME = '"
                    + employee.getLastName()
                    + "'")));
    employee = (Employee) manager.getObject(employeeClass, "0002");
    suite.addTest(
        new ReadObjectCallTest(
            employeeClass,
            new SQLCall(
                "SELECT VERSION, EMP_ID, L_NAME, F_NAME FROM UNIDIR_EMPLOYEE WHERE F_NAME = '"
                    + employee.getFirstName()
                    + "' AND L_NAME = '"
                    + employee.getLastName()
                    + "'")));
    employee = (Employee) manager.getObject(employeeClass, "0003");
    suite.addTest(
        new ReadObjectCallTest(
            employeeClass,
            new SQLCall(
                "SELECT VERSION, EMP_ID, L_NAME, F_NAME FROM UNIDIR_EMPLOYEE WHERE F_NAME = '"
                    + employee.getFirstName()
                    + "' AND L_NAME = '"
                    + employee.getLastName()
                    + "'")));

    return suite;
  }
  public void test() {

    ReadObjectQuery query = new ReadObjectQuery();
    query.setReferenceClass(Employee.class);
    query.setExampleObject(employee);
    query.setQueryByExamplePolicy(policy);
    Employee emp = new Employee();
    emp = (Employee) getSession().executeQuery(query);
    if (!(emp.getFirstName().charAt(0) == 'J')
        && (emp.getFirstName().charAt(3) == 'l')
        && (emp.getLastName().charAt(0) == 'M')) {
      throw (new TestErrorException("Error in using specail operators."));
    }
    if (!(emp.getSalary() < 60000)) {
      throw (new TestErrorException("Error is using spcial operators."));
    }
  }
  public void setup() {
    if ((getSession().getLogin().getPlatform().isSQLServer())) {
      throw new TestWarningException(
          "This test is not supported on SQL Server. Because 'LENGTH' is not a recognized function name on SQL Server.");
    }

    Employee emp = (Employee) getSomeEmployees().firstElement();

    String ejbqlString;
    ejbqlString = "SELECT OBJECT(emp) FROM Employee emp WHERE ";
    ejbqlString = ejbqlString + emp.getFirstName().length();
    ejbqlString = ejbqlString + " = LENGTH(emp.firstName)";

    setEjbqlString(ejbqlString);
    setOriginalOject(emp);
    super.setup();
  }
 public void test() {
   UnitOfWork uow = getSession().acquireUnitOfWork();
   employee = (Employee) uow.readObject(Employee.class);
   originalReadTime =
       ((AbstractSession) getSession())
           .getIdentityMapAccessorInstance()
           .getCacheKeyForObject(employee)
           .getReadTime();
   employee.setFirstName(employee.getFirstName() + "-mutated");
   try {
     Thread.sleep(100);
   } catch (InterruptedException exc) {
   }
   uow.commit();
   secondReadTime =
       getAbstractSession()
           .getIdentityMapAccessorInstance()
           .getCacheKeyForObject(employee)
           .getReadTime();
 }
  private void createEmployeeAndSearchExpression() {
    // Create the example employee
    employee =
        (org.eclipse.persistence.testing.models.employee.domain.Employee)
            new org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator()
                .basicEmployeeExample1();
    employee.setFirstName("Timugen");
    employee.setLastName("Singaera");
    employee.addResponsibility("Answer the phones.");

    // Create an expression to retreive the employee from the database
    ExpressionBuilder expressionBuilder = new ExpressionBuilder();
    Expression exp1;
    Expression exp2;
    Expression expression;

    exp1 = expressionBuilder.get("firstName").equal(employee.getFirstName());
    exp2 = expressionBuilder.get("lastName").equal(employee.getLastName());

    searchExpression = exp1.or(exp2);
  }