use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyComplexPkTests method test05_BSetANewAB.
public void test05_BSetANewAB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(2);
final SongLocal song = findSong(22);
song.setPerformer(artist);
} finally {
completeTransaction();
}
assertLinked(2, 22);
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyComplexPkTests method test12_CascadeDelete.
public void test12_CascadeDelete() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(1);
final Set<SongLocal> songs = artist.getPerformed();
assertFalse(songs.isEmpty());
artist.remove();
assertTrue(songs.isEmpty());
} finally {
completeTransaction();
}
final Connection c = ds.getConnection();
final Statement s = c.createStatement();
final ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM ComplexSong");
assertTrue(rs.next());
assertEquals(0, rs.getInt(1));
rs.close();
s.close();
c.close();
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyComplexPkTests method testIteratorAndRemove.
public void testIteratorAndRemove() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(new Integer(1));
final SongLocal song = findSong(new Integer(11));
final Set games = artist.getComposed();
assertFalse(games.isEmpty());
assertEquals(2, games.size());
final Iterator iterator = games.iterator();
assertTrue(games.contains(song));
artist.remove();
assertFalse(games.contains(song));
assertEquals(0, games.size());
try {
iterator.next();
fail("expected iterator.next() to throw an ConcurrentModificationException");
} catch (final ConcurrentModificationException expected) {
}
} finally {
completeTransaction();
}
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyComplexPkTests method test08_ASetBExistingANewB.
public void test08_ASetBExistingANewB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(1);
final SongLocal song = createSong(33);
final Set<SongLocal> songSets = artist.getPerformed();
songSets.add(song);
} finally {
completeTransaction();
}
assertLinked(1, 11, 22, 33);
}
use of org.apache.openejb.test.entity.cmr.onetomany.ArtistLocal in project tomee by apache.
the class OneToManyComplexPkTests method test04_ASetBNewAB.
public void test04_ASetBNewAB() throws Exception {
resetDB();
beginTransaction();
try {
final ArtistLocal artist = findArtist(2);
final SongLocal song = findSong(22);
final Set<SongLocal> songSets = new HashSet<SongLocal>();
songSets.add(song);
artist.setPerformed(songSets);
} finally {
completeTransaction();
}
assertLinked(2, 22);
}
Aggregations