Search in sources :

Example 1 with DistributedServer

use of org.eclipse.persistence.testing.tests.distributedservers.DistributedServer in project eclipselink by eclipse-ee4j.

the class DeleteObjectNotSentTest method setup.

@Override
public void setup() {
    super.setup();
    // Create an Employee
    employee = new Employee();
    employee.setFirstName("Dean");
    employee.setLastName("Keaton");
    UnitOfWork uow = getSession().acquireUnitOfWork();
    uow.registerObject(employee);
    uow.commit();
    // Ensure the employee exists in the Distributed Session
    ExpressionBuilder employees = new ExpressionBuilder();
    expression = employees.get("firstName").equal("Dean");
    expression = expression.and(employees.get("lastName").equal("Keaton"));
    // 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);
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) DistributedServer(org.eclipse.persistence.testing.tests.distributedservers.DistributedServer) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 2 with DistributedServer

use of org.eclipse.persistence.testing.tests.distributedservers.DistributedServer in project eclipselink by eclipse-ee4j.

the class IsolatedObjectNotSentTest method setup.

@Override
public void setup() {
    super.setup();
    ExpressionBuilder employees = new ExpressionBuilder();
    this.expression = employees.get("firstName").equal("Andy");
    this.expression = this.expression.and(employees.get("lastName").equal("McDurmont"));
    // ensure our employee is in one of the distributed caches
    DistributedServer server = (DistributedServer) DistributedServersModel.getDistributedServers().get(0);
    this.distributedEmployee = (IsolatedEmployee) server.getDistributedSession().readObject(IsolatedEmployee.class, this.expression);
    this.listener = new SessionEventAdapter() {

        @Override
        public void preMergeUnitOfWorkChangeSet(SessionEvent event) {
            sentChanges = true;
        }
    };
    server.getDistributedSession().getEventManager().addListener(this.listener);
    this.sentChanges = false;
}
Also used : SessionEvent(org.eclipse.persistence.sessions.SessionEvent) DistributedServer(org.eclipse.persistence.testing.tests.distributedservers.DistributedServer) SessionEventAdapter(org.eclipse.persistence.sessions.SessionEventAdapter) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Example 3 with DistributedServer

use of org.eclipse.persistence.testing.tests.distributedservers.DistributedServer in project eclipselink by eclipse-ee4j.

the class IsolatedObjectNotSentTest method reset.

@Override
public void reset() {
    super.reset();
    DistributedServer server = (DistributedServer) DistributedServersModel.getDistributedServers().get(0);
    server.getDistributedSession().getEventManager().removeListener(this.listener);
}
Also used : DistributedServer(org.eclipse.persistence.testing.tests.distributedservers.DistributedServer)

Example 4 with DistributedServer

use of org.eclipse.persistence.testing.tests.distributedservers.DistributedServer in project eclipselink by eclipse-ee4j.

the class NewObjectWithOptimisticLockingTest method test.

@Override
public void test() {
    DistributedServer server = (DistributedServer) DistributedServersModel.getDistributedServers().get(0);
    UnitOfWork uow = server.getDistributedSession().acquireUnitOfWork();
    holder = (ListHolder) uow.readObject(ListHolder.class);
    ListItem item = new ListItem();
    item.setDescription("test2");
    item = (ListItem) uow.registerObject(item);
    holder.getItems().add(item);
    uow.commit();
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) DistributedServer(org.eclipse.persistence.testing.tests.distributedservers.DistributedServer) ListItem(org.eclipse.persistence.testing.models.optimisticlocking.ListItem)

Example 5 with DistributedServer

use of org.eclipse.persistence.testing.tests.distributedservers.DistributedServer in project eclipselink by eclipse-ee4j.

the class RelatedNewObjectCacheSyncTest method setup.

@Override
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();
}
Also used : DistributedServer(org.eclipse.persistence.testing.tests.distributedservers.DistributedServer) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) ExpressionBuilder(org.eclipse.persistence.expressions.ExpressionBuilder)

Aggregations

DistributedServer (org.eclipse.persistence.testing.tests.distributedservers.DistributedServer)12 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)6 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)5 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)4 Enumeration (java.util.Enumeration)2 ListHolder (org.eclipse.persistence.testing.models.optimisticlocking.ListHolder)2 ListItem (org.eclipse.persistence.testing.models.optimisticlocking.ListItem)2 SessionEvent (org.eclipse.persistence.sessions.SessionEvent)1 SessionEventAdapter (org.eclipse.persistence.sessions.SessionEventAdapter)1 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)1