* @see PersistenceManagerIF#deleteChannel
*/
public void testDeleteChannelCascade() {
ChannelGroupIF group = null;
ChannelIF channel = null;
ItemIF item1 = null;
ItemIF item2 = null;
try {
// Create group and channel with two items
group = manager.createGroup(tuids1);
channel = manager.createChannel(tuids1, url1);
item1 = manager.createItem(channel, tuids1);
item2 = manager.createItem(channel, tuids2);
// Put channel in group
manager.addChannelToGroup(channel, group);
// Delete channel
manager.deleteChannel(channel);
// Check that it was removed from parent group and all of its items gone too
assertEquals("Group still has channels.", 0, group.getAll().size());
assertEquals("Channel still has items.", 0, channel.getItems().size());
assertEquals("Item still has initialized ID.", -1, item1.getId());
assertEquals("Item still has initialized ID.", -1, item2.getId());
} catch (PersistenceManagerException e) {
e.printStackTrace();
fail();
} finally {
// Delete channel, group and items
try {
if (item1 != null && item1.getId() != -1) manager.deleteItem(item1);
if (item2 != null && item2.getId() != -1) manager.deleteItem(item2);
if (channel != null && channel.getId() != -1) manager.deleteChannel(channel);
if (group != null && group.getId() != -1) manager.deleteGroup(group);
} catch (PersistenceManagerException e) {
// We can do nothing here
}