Package org.apache.cayenne.unit.util

Examples of org.apache.cayenne.unit.util.ThreadedTestHelper


        // check peer artist

        // use threaded helper as a barrier, to avoid triggering faults earlier than
        // needed
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                Object value = altArtist.readPropertyDirectly("paintingArray");
                assertTrue("Unexpected: " + value, value instanceof ToManyList);
                assertTrue(((ToManyList) value).isFault());
            }
        };
        helper.assertWithTimeout(2000);
        List list = altArtist.getPaintingArray();
        assertEquals(2, list.size());
    }
View Full Code Here


        assertEquals(PersistenceState.HOLLOW, artist.getPersistenceState());
        assertNull(context.getObjectStore().getDataRowCache().getCachedSnapshot(
                artist.getObjectId()));

        // alternate context
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(PersistenceState.HOLLOW, altArtist.getPersistenceState());
                assertNull(altContext
View Full Code Here

        assertEquals(0, context.getObjectStore().registeredObjectsCount());
        context.performQuery(new SelectQuery(Artist.class));
        assertEquals(1, context.getObjectStore().registeredObjectsCount());

        // allow for slow GC
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                System.gc();
                assertEquals(0, context.getObjectStore().registeredObjectsCount());
View Full Code Here

        a.setArtistName("X");
        a = null;
        assertEquals(1, context.getObjectStore().registeredObjectsCount());

        // allow for slow GC
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                System.gc();
                assertEquals(1, context.getObjectStore().registeredObjectsCount());
            }
        }.assertWithTimeout(2000);

        assertEquals(1, context.getObjectStore().registeredObjectsCount());
        context.commitChanges();
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                System.gc();
                assertEquals(0, context.getObjectStore().registeredObjectsCount());
View Full Code Here

        Artist a = DataObjectUtils.objectForPK(context, Artist.class, 1);
        a.setArtistName("Y");
        a = null;
        assertEquals(1, context.getObjectStore().registeredObjectsCount());

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                System.gc();
                assertEquals(1, context.getObjectStore().registeredObjectsCount());
            }
        }.assertWithTimeout(2000);

        context.commitChanges();
        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                System.gc();
                assertEquals(0, context.getObjectStore().registeredObjectsCount());
View Full Code Here

                .getCachedSnapshot(a2.getObjectId());
        assertNotNull("No snapshot for artist", freshSnapshot);
        assertEquals(NEW_NAME, freshSnapshot.get("ARTIST_NAME"));

        // check peer artist
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(
                        "Snapshot change is not propagated: " + freshSnapshot,
                        NEW_NAME,
                        a2.getArtistName());
            }
        };
        helper.assertWithTimeout(3000);
    }
View Full Code Here

        a1.setArtistName("Y");
        assertEquals("X", a2.getArtistName());
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals("Y", a2.getArtistName());
View Full Code Here

        p1.setToArtist(altA1);
        assertSame(a2, p2.getToArtist());
        assertNotSame(altA2, p2.getToArtist());
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertSame(altA2, p2.getToArtist());
                assertFalse("Peer data context became dirty on event processing", peer2
View Full Code Here

        a1.addToPaintingArray(py1);
        assertEquals(1, a2.getPaintingArray().size());
        assertFalse(a2.getPaintingArray().contains(py2));
        parentPeer.commitChangesToParent();

        new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertEquals(2, a2.getPaintingArray().size());
                assertTrue(a2.getPaintingArray().contains(py2));
View Full Code Here

        artist.setArtistName("version2");
        context.commitChanges();

        // assert that delegate was consulted when an object store
        // was refreshed
        ThreadedTestHelper helper = new ThreadedTestHelper() {

            @Override
            protected void assertResult() throws Exception {
                assertTrue("Delegate was not consulted", methodInvoked[0]);
            }
        };
        helper.assertWithTimeout(3000);
    }
View Full Code Here

TOP

Related Classes of org.apache.cayenne.unit.util.ThreadedTestHelper

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.