Search in sources :

Example 41 with SongLocal

use of org.apache.openejb.test.entity.cmr.onetomany.SongLocal in project tomee by apache.

the class OneToManyTests method testIteratorConcurrentModification.

public void testIteratorConcurrentModification() throws Exception {
    resetDB();
    beginTransaction();
    try {
        final ArtistLocal artist = findArtist(new Integer(1));
        final SongLocal song = findSong(new Integer(11));
        final Set songs = artist.getComposed();
        assertFalse(songs.isEmpty());
        assertEquals(2, songs.size());
        final Iterator iterator = songs.iterator();
        songs.remove(song);
        assertEquals(1, songs.size());
        try {
            iterator.next();
            fail("expected iterator.next() to throw an ConcurrentModificationException");
        } catch (final ConcurrentModificationException ignored) {
        }
    } finally {
        completeTransaction();
    }
}
Also used : ArtistLocal(org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal) ConcurrentModificationException(java.util.ConcurrentModificationException) SongLocal(org.apache.openejb.test.entity.cmr.onetomany.SongLocal) Set(java.util.Set) HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) Iterator(java.util.Iterator)

Aggregations

SongLocal (org.apache.openejb.test.entity.cmr.onetomany.SongLocal)41 ArtistLocal (org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal)36 ResultSet (java.sql.ResultSet)14 HashSet (java.util.HashSet)14 Set (java.util.Set)10 ConcurrentModificationException (java.util.ConcurrentModificationException)8 Iterator (java.util.Iterator)8 Connection (java.sql.Connection)6 Statement (java.sql.Statement)6 SQLException (java.sql.SQLException)2