コード例 #1
0
 public void verify() {
   Employee distEmp = (Employee) getObjectFromDistributedSession(this.query);
   Enumeration enumtr = this.numbers.elements();
   while (enumtr.hasMoreElements()) {
     if (distEmp.getPhoneNumbers().contains(enumtr.nextElement())) {
       throw new org.eclipse.persistence.testing.framework.TestErrorException(
           "Failed to delete private owned objects from distributed cache");
     }
   }
 }
コード例 #2
0
  public void test() {
    UnitOfWork uow = getSession().acquireUnitOfWork();
    UnitOfWork uow2 = getSession().acquireUnitOfWork();

    baseEmp = (Employee) uow.readObject(Employee.class);
    for (int count = 20; count > 0; --count) {
      baseEmp.addPhoneNumber(
          new PhoneNumber(String.valueOf(count), String.valueOf(count), "5555555"));
    }
    uow.commit();

    Runnable runnable1 =
        new Runnable() {
          public void run() {}
        };

    Runnable runnable2 =
        new Runnable() {
          public void run() {
            try {
              for (int count = 20; count > 0; --count) {
                UnitOfWork uow = getSession().acquireUnitOfWork();
                Employee emp = (Employee) uow.readObject(baseEmp);
                emp.getPhoneNumbers();
                uow.revertObject(emp);
              }
            } catch (ConcurrentModificationException ex) {
              exception = true;
            }
          }
        };
    Thread thread1 = new Thread(runnable2);
    thread1.start();
    try {
      for (int count = 20; count > 0; --count) {
        uow = getSession().acquireUnitOfWork();
        Employee emp = (Employee) uow.readObject(baseEmp);
        emp.getPhoneNumbers().remove(0);
        uow.commit();
      }
    } catch (ConcurrentModificationException ex) {
      exception = true;
    }
    try {
      thread1.join();
    } catch (InterruptedException ex) {
    }
  }
コード例 #3
0
 public void setup() {
   super.setup();
   ExpressionBuilder employees = new ExpressionBuilder();
   expression = employees.get("firstName").equal("Charles");
   expression = expression.and(employees.get("lastName").equal("Chanley"));
   // ensure our employee is in one of the distributed caches
   DistributedServer server =
       (DistributedServer) DistributedServersModel.getDistributedServers().get(0);
   Object result = server.getDistributedSession().readObject(Employee.class, expression);
   ((Employee) result).getManagedEmployees();
   ((Employee) result).getPhoneNumbers();
   ((Employee) result).getAddress();
   ((Employee) result).getManager();
   ((Employee) result).getProjects();
   ((Employee) result).getResponsibilitiesList();
 }
コード例 #4
0
  public void setup() {
    Employee emp;
    emp = (Employee) getSomeEmployees().firstElement();
    PhoneNumber empPhoneNumbers = (PhoneNumber) emp.getPhoneNumbers().elementAt(0);

    String ejbqlString =
        "SelecT OBJECT(emp) from Employee emp, in (emp.phoneNumbers) phone "
            + "Where phone.areaCode = \""
            + empPhoneNumbers.getAreaCode()
            + "\"";

    setEjbqlString(ejbqlString);
    setOriginalOject(emp);

    super.setup();
  }
コード例 #5
0
 protected void changeObject() {
   Employee employee = (Employee) this.workingCopy;
   // Direct to field
   employee.setFirstName(new String(employee.getFirstName().getBytes()));
   // Object type
   employee.setGender(new String(employee.getGender().getBytes()));
   // Transformation
   employee.setNormalHours(employee.getNormalHours().clone());
   // Aggregate
   employee.setPeriod(
       new EmploymentPeriod(
           employee.getPeriod().getStartDate(), employee.getPeriod().getEndDate()));
   // One to many private/public
   employee.setPhoneNumbers((Vector) employee.getPhoneNumbers().clone());
   employee.setProjects((Vector) employee.getProjects().clone());
   employee.setManagedEmployees((Vector) employee.getManagedEmployees().clone());
   // Direct collection
   employee.setResponsibilitiesList((Vector) employee.getResponsibilitiesList().clone());
   // One to one private/public
   employee.getAddress();
   employee.getManager();
 }
  public void setup() {
    Employee emp = (Employee) getSomeEmployees().firstElement();

    PhoneNumber phone = (PhoneNumber) emp.getPhoneNumbers().firstElement();
    String areaCode = phone.getAreaCode();
    String firstName = emp.getFirstName();

    setReferenceClass(Employee.class);

    ExpressionBuilder employeeBuilder = new ExpressionBuilder();
    Expression phones = employeeBuilder.anyOf("phoneNumbers");
    Expression whereClause =
        phones
            .get("owner")
            .get("firstName")
            .equal(firstName)
            .and(phones.get("areaCode").equal(areaCode));

    ReportQuery rq = new ReportQuery();
    rq.setSelectionCriteria(whereClause);
    rq.addAttribute("number", phones.get("number"));
    rq.setReferenceClass(Employee.class);

    setOriginalOject(getAttributeFromAll("number", (Vector) getSession().executeQuery(rq)));
    getSession().getIdentityMapAccessor().initializeAllIdentityMaps();

    String ejbqlString;
    ejbqlString =
        "SELECT phone.number FROM Employee employee, IN(employee.phoneNumbers) phone "
            + "WHERE phone.owner.firstName = \""
            + firstName
            + "\" AND phone.areaCode = \""
            + areaCode
            + "\"";

    useReportQuery();
    setEjbqlString(ejbqlString);
    super.setup();
  }