/**
* Test basic persistence operations ... Create, Update, Delete
*/
public void testPingTargetCRUD() throws Exception {
PingTargetManager mgr = RollerFactory.getRoller().getPingTargetManager();
PingTargetData ping = null;
// create common ping
mgr.savePingTarget(testCommonPing);
String commonId = testCommonPing.getId();
TestUtils.endSession(true);
// make sure common ping was stored
ping = null;
ping = mgr.getPingTarget(commonId);
assertNotNull(ping);
assertEquals(testCommonPing.getPingUrl(), ping.getPingUrl());
// create custom ping
testCustomPing.setWebsite(testWeblog);
mgr.savePingTarget(testCustomPing);
String customId = testCustomPing.getId();
TestUtils.endSession(true);
// make sure custom ping was stored
ping = null;
ping = mgr.getPingTarget(customId);
assertNotNull(ping);
assertEquals(testCustomPing.getPingUrl(), ping.getPingUrl());
// update common ping
ping = null;
ping = mgr.getPingTarget(commonId);
ping.setName("testtestCommon");
mgr.savePingTarget(ping);
TestUtils.endSession(true);
// make sure common ping was updated
ping = null;
ping = mgr.getPingTarget(commonId);
assertNotNull(ping);
assertEquals("testtestCommon", ping.getName());
// update custom ping
ping = null;
ping = mgr.getPingTarget(customId);
ping.setName("testtestCustom");
mgr.savePingTarget(ping);
TestUtils.endSession(true);
// make sure custom ping was updated
ping = null;
ping = mgr.getPingTarget(customId);
assertNotNull(ping);
assertEquals("testtestCustom", ping.getName());
// delete common ping
ping = null;
ping = mgr.getPingTarget(commonId);
mgr.removePingTarget(ping);
TestUtils.endSession(true);
// make sure common ping was deleted
ping = null;
ping = mgr.getPingTarget(commonId);
assertNull(ping);
// delete custom ping
ping = null;
ping = mgr.getPingTarget(customId);
mgr.removePingTarget(ping);
TestUtils.endSession(true);
// make sure custom ping was deleted
ping = null;
ping = mgr.getPingTarget(customId);
assertNull(ping);
}