Package org.apache.openejb.test.entity.cmr.onetomany

Examples of org.apache.openejb.test.entity.cmr.onetomany.SongLocal


    public void test09_BSetAExistingANewB() throws Exception {
        resetDB();
        beginTransaction();
        try {
            ArtistLocal artist = findArtist(1);
            SongLocal song = createSong(33);
            song.setPerformer(artist);
        } finally {
            completeTransaction();
        }

        assertLinked(1, 11, 22, 33);
View Full Code Here


    public void test10_RemoveRelationships() throws Exception {
        resetDB();
        beginTransaction();
        try {
            SongLocal song = findSong(11);
            ArtistLocal artist = song.getPerformer();
            Set<SongLocal> songs = artist.getPerformed();
            assertTrue(songs.contains(song));
            song.remove();
            assertFalse(songs.contains(song));
        } finally {
            completeTransaction();
        }
        assertLinked(1, 22);
View Full Code Here

    // uncomment when cmp to cmr is supported
    public void TODO_testCMPMappedToForeignKeyColumn() throws Exception {
        resetDB();
        beginTransaction();
        try {
            SongLocal song = findSong(11);

            Integer field3 = song.getBpm();
            assertEquals(song.getPerformer().getPrimaryKey(), field3);
        } finally {
            completeTransaction();
        }
    }
View Full Code Here

    // uncomment when cmp to cmr is supported
    public void TODO_testSetCMPMappedToForeignKeyColumn() throws Exception {
        resetDB();
        beginTransaction();
        try {
            SongLocal song = findSong(11);

            song.setBpm(2);

            ArtistLocal artist = song.getPerformer();
            assertEquals(new Integer(2), artist.getId());
            assertEquals("value2", artist.getName());
        } finally {
            completeTransaction();
        }
View Full Code Here

    public void testModifyCmrCollectionOusideTx() throws Exception {
        resetDB();
        beginTransaction();
        Set songs;
        SongLocal newSong;
        try {
            ArtistLocal artist = findArtist(new Integer(1));
            newSong = createSong(new Integer(33));
            songs = artist.getComposed();
        } finally {
            completeTransaction();
        }

        // CMR collections should still be readable
        assertFalse(songs.isEmpty());
        assertEquals(2, songs.size());
        for (Iterator iter = songs.iterator(); iter.hasNext();) {
            SongLocal song = (SongLocal) iter.next();
            if (song.getId().equals(new Integer(11))) {
                assertEquals("value11", song.getName());
            } else if (song.getId().equals(new Integer(22))) {
                assertEquals("value22", song.getName());
            } else {
                fail();
            }
        }
View Full Code Here

    public void testModifyCmrCollectionInNewTx() throws Exception {
        resetDB();
        beginTransaction();
        Set songs;
        SongLocal newSong;
        try {
            ArtistLocal artist = findArtist(new Integer(1));
            newSong = createSong(new Integer(33));
            songs = artist.getComposed();
        } finally {
            completeTransaction();
        }

        beginTransaction();
        try {
            // CMR collections should still be readable
            assertFalse(songs.isEmpty());
            assertEquals(2, songs.size());
            for (Iterator iter = songs.iterator(); iter.hasNext();) {
                SongLocal song = (SongLocal) iter.next();
                if (song.getId().equals(new Integer(11))) {
                    assertEquals("value11", song.getName());
                } else if (song.getId().equals(new Integer(22))) {
                    assertEquals("value22", song.getName());
                } else {
                    fail();
                }
            }
View Full Code Here

    public void testIteratorConcurrentModification() throws Exception {
        resetDB();
        beginTransaction();
        try {
            ArtistLocal artist = findArtist(new Integer(1));
            SongLocal song = findSong(new Integer(11));
            Set songs = artist.getComposed();
            assertFalse(songs.isEmpty());
            assertEquals(2, songs.size());

            Iterator iterator = songs.iterator();
View Full Code Here

    public void testIteratorAndRemove() throws Exception {
        resetDB();
        beginTransaction();
        try {
            ArtistLocal artist = findArtist(new Integer(1));
            SongLocal song = findSong(new Integer(11));
            Set games = artist.getComposed();
            assertFalse(games.isEmpty());
            assertEquals(2, games.size());

            Iterator iterator = games.iterator();
View Full Code Here

    private ArtistLocal findArtist(int artistId) throws FinderException {
        return artistLocalHome.findByPrimaryKey(artistId);
    }

    private SongLocal createSong(int songId) throws CreateException {
        SongLocal song = songLocalHome.create(songId);
        song.setName("value" + songId);
        return song;
    }
View Full Code Here

        }

        ArtistLocal artist1 = createArtist(1);
        createArtist(2);

        SongLocal song1 = createSong(11);
        SongLocal song2 = createSong(22);

        song1.setPerformer(artist1);
        song2.setPerformer(artist1);

        song1.setComposer(artist1);
        song2.setComposer(artist1);
    }
View Full Code Here

TOP

Related Classes of org.apache.openejb.test.entity.cmr.onetomany.SongLocal

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.