Search in sources :

Example 1 with ClientLifecycles

use of org.apache.cayenne.testdo.lifecycles.ClientLifecycles in project cayenne by apache.

the class RemoteCallbacksIT method testDefault.

@Test
public void testDefault() throws InterruptedException {
    ObjectContext context = createROPContext();
    context.getEntityResolver().getCallbackRegistry().addListener(ClientLifecycles.class, this);
    assertAll(0, 0, 0, 0, 0, 0, 0, 0);
    ClientLifecycles l1 = context.newObject(ClientLifecycles.class);
    assertAll(1, 0, 0, 0, 0, 0, 0, 0);
    l1.setName("x");
    assertAll(1, 0, 0, 0, 0, 0, 0, 0);
    context.commitChanges();
    // until commit
    Thread.sleep(5);
    assertAll(1, 0, 1, 1, 0, 0, 0, 0);
    l1.setName("x2");
    assertAll(1, 0, 1, 1, 0, 0, 0, 0);
    context.commitChanges();
    // until commit
    Thread.sleep(5);
    assertAll(1, 0, 1, 1, 1, 1, 0, 0);
    context.deleteObjects(l1);
    assertAll(1, 0, 1, 1, 1, 1, 1, 0);
    context.commitChanges();
    // until commit
    Thread.sleep(5);
    assertAll(1, 0, 1, 1, 1, 1, 1, 1);
}
Also used : ClientLifecycles(org.apache.cayenne.testdo.lifecycles.ClientLifecycles) ObjectContext(org.apache.cayenne.ObjectContext) Test(org.junit.Test)

Aggregations

ObjectContext (org.apache.cayenne.ObjectContext)1 ClientLifecycles (org.apache.cayenne.testdo.lifecycles.ClientLifecycles)1 Test (org.junit.Test)1