System.out.println(prop0);
System.out.println("Lookup node 0");
InitialContext ctx0 = new InitialContext(prop0);
BulkOperationsTest tester = (BulkOperationsTest) ctx0.lookup("BulkOperationsTestBean/remote");
try
{
tester.createContacts();
List<Integer> rhContacts = tester.getContactsByCustomer("Red Hat");
assertNotNull("Red Hat contacts exist", rhContacts);
assertEquals("Created expected number of Red Hat contacts", 10, rhContacts.size());
assertEquals("Deleted all Red Hat contacts", 10, tester.deleteContacts());
List<Integer> jbContacts = tester.getContactsByCustomer("JBoss");
assertNotNull("JBoss contacts exist", jbContacts);
assertEquals("JBoss contacts remain", 10, jbContacts.size());
for (Integer id : rhContacts)
{
assertNull("Red Hat contact " + id + " cannot be retrieved",
tester.getContact(id));
}
rhContacts = tester.getContactsByCustomer("Red Hat");
if (rhContacts != null)
{
assertEquals("No Red Hat contacts remain", 0, rhContacts.size());
}
tester.updateContacts("Kabir", "Updated");
for (Integer id : jbContacts)
{
Contact contact = tester.getContact(id);
assertNotNull("JBoss contact " + id + " exists", contact);
String expected = ("Kabir".equals(contact.getName())) ? "Updated" : "2222";
assertEquals("JBoss contact " + id + " has correct TLF",
expected, contact.getTlf());
}
List<Integer> updated = tester.getContactsByTLF("Updated");
assertNotNull("Got updated contacts", updated);
assertEquals("Updated contacts", 5, updated.size());
}
finally
{
// cleanup the db so we can run this test multiple times w/o restarting the cluster
tester.remove();
}
}