Skip to main content
pdf?stylesheet=default
Blackboard Help

Sample Code to Start Persistence Testing

Use this code sample as the basis for start persistence testing for event driven APIs.

Event Driven API – start persistance testing

/*********** Begin testing **********/

try

{

 ePersister.insert(enroll);

}

catch(PersistenceException nfe)

{

 System.out.println("insert enrollment without supporting object(s) success!");

}


try

{

 saPersister.insert(staff);

}

catch(PersistenceException nfe)

{

 System.out.println("insert staff student without supporting object(s) success!");

}


try

{

 orgMemPersister.insert(orgmem);

}

catch(PersistenceException nfe)

{

 System.out.println("insert organization membership without supporting object(s) success!");

}

 

try

{

 orgCatMemPersister.insert(org_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("insert organization link without supporting object(s) success!");

}


try

{

 crsCatMemPersister.insert(crs_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("insert course creation wizard without supporting object(s) success!");

}


try

{

 ePersister.save(enroll);

}

catch(PersistenceException nfe)

{

 System.out.println("save enrollment without supporting object(s) success!");

}


try

{

 saPersister.save(staff);

}

catch(PersistenceException nfe)

{

 System.out.println("save staff assignment without supporting object(s) success!");

}


try

{

 orgMemPersister.save(orgmem);

}

catch(PersistenceException nfe)

{

 System.out.println("save organization membership without supporting object(s) success!");

}


try

{

 orgCatMemPersister.save(org_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("save organization link without supporting object(s) success!");

}


try

{

 crsCatMemPersister.save(crs_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("save course creation wizard without supporting object(s) success!");

}


try

{

 pPersister.update(person_1);

 pPersister.update(person_2);

}

catch(PersistenceException nfe)

{

 System.out.println("Update not found success (Person)!");

}


try

{

 cPersister.update(course);

}

catch(PersistenceException nfe)

{

 System.out.println("Update not found success (Course)!");

}


try

{

 orgPersister.update(org);

}

catch(PersistenceException nfe)

{

 System.out.println("Update not found success (Organization)!");

}


try

{

 ePersister.update(enroll);

}

catch(PersistenceException nfe)

{

 System.out.println("update enrollment without supporting object(s) success!");

}


try

{

 saPersister.update(staff);

}

catch(PersistenceException nfe)

{

 System.out.println("update staff assignment without supporting object(s) success!");

}


try

{

 orgMemPersister.update(orgmem);

}

catch(PersistenceException nfe)

{

 System.out.println("update organization membership without supporting object(s) success!");

}


try

{

 crsCatPersister.update(crs_cat);

}

catch(PersistenceException nfe)

{

 System.out.println("Update not found success (course Category)!");

}


try

{

 orgCatPersister.update(org_cat);

}

catch(PersistenceException nfe)

{

 System.out.println("Update not found success (organization Category)!");

}


try

{

 orgCatMemPersister.update(org_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("update organization link without supporting object(s) success!");

}


try

{

 crsCatMemPersister.update(crs_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("update course creation wizard without supporting object(s) success!");

}


cPersister.insert(course);

System.out.println("course insertion succeeded");


orgPersister.insert(org);

System.out.println("organization insertion succeeded");


pPersister.insert(person_1);

System.out.println("person 1 insertion succeeded");


pPersister.insert(person_2);

System.out.println("person 2 insertion succeeded");


orgMemPersister.insert(orgmem);

System.out.println("org membership insertion succeeded");


saPersister.insert(staff);

System.out.println("staff student insertion succeeded");


ePersister.insert(enroll);

System.out.println("enrollment membership insertion succeeded");

 

crsCatPersister.insert(crs_cat);

System.out.println("course category insertion succeeded");


orgCatPersister.insert(org_cat);

System.out.println("organization category insertion succeeded");


crsCatMemPersister.insert(crs_cat_mem);

System.out.println("course creation wizard insertion succeeded");


orgCatMemPersister.insert(org_cat_mem);

System.out.println("organization link insertion succeeded");

 

ePersister.save(enroll);

System.out.println("enroll save succeeded");


saPersister.save(staff);

System.out.println("staff save succeeded");


orgMemPersister.save(orgmem);

System.out.println("org membership save succeeded");


cPersister.save(course);

System.out.println("course save succeeded");


orgPersister.save(org);

System.out.println("organization save succeeded");


pPersister.save(person_1);

System.out.println("person_1 save succeeded");


pPersister.save(person_2);

System.out.println("person_2 save succeeded");


crsCatPersister.save(crs_cat);

System.out.println("course category save succeeded");


orgCatPersister.save(org_cat);

System.out.println("organization category save succeeded");


crsCatMemPersister.save(crs_cat_mem);

System.out.println("course creation wizard save succeeded");


orgCatMemPersister.save(org_cat_mem);

System.out.println("organization link save succeeded");


ePersister.remove(enroll);

System.out.println("enroll remove succeeded");


saPersister.remove(staff);

System.out.println("staff remove succeeded");
 

orgMemPersister.remove(orgmem);

System.out.println("org membership remove succeeded");


pPersister.remove(person_1);

System.out.println("person 1 remove succeeded");

 

pPersister.remove(person_2);

System.out.println("person 2 remove succeeded");


crsCatMemPersister.remove(crs_cat_mem);

System.out.println("course creation wizard remove succeeded");


orgCatMemPersister.remove(org_cat_mem);

System.out.println("organization link remove succeeded");

 

crsCatPersister.remove(crs_cat);

System.out.println("course category remove succeeded");


orgCatPersister.remove(org_cat);

System.out.println("organization category remove succeeded");


cPersister.remove(course);

System.out.println("course remove succeeded");


orgPersister.remove(org);

System.out.println("org remove succeeded");


try

{

 pPersister.remove(person_1);

 pPersister.remove(person_2);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Person)!");

}


try

{

 cPersister.remove(course);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Course)!");

}


try

{

 orgPersister.remove(org);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Organization)!");

}


try

{

 ePersister.remove(enroll);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (enroll)!");

}


try

{

 saPersister.remove(staff);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (staff)!");

}


try

{

 orgMemPersister.remove(orgmem);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Org Membership)!");

}


try

{

 crsCatPersister.remove(crs_cat);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Course Category)!");

}


try

{

 orgCatPersister.remove(org_cat);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (Organization Category)!");

}


try

{

 crsCatMemPersister.remove(crs_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (course creation wizard)!");

}


try

{

 orgCatMemPersister.remove(org_cat_mem);

}

catch(PersistenceException nfe)

{

 System.out.println("Remove not found success (organization link)!");

}


pPersister.save(person_1);

pPersister.save(person_2);

cPersister.save(course);

orgPersister.save(org);

ePersister.save(enroll);

saPersister.save(staff);

orgMemPersister.save(orgmem);

crsCatPersister.save(crs_cat);

orgCatPersister.save(org_cat);

crsCatMemPersister.save(crs_cat_mem);

orgCatMemPersister.save(org_cat_mem);

System.out.println("Save successful (non-existing)");


/******** Now beginning load test ***********************/

java.util.Iterator iter = null;

person_1 = pLoader.load(person_1.getBatchUid());

System.out.println("load of person 1 by batch uid successful");

 
person_2 = pLoader.load(person_2.getBatchUid());

System.out.println("load of person 2 by batch uid successful");


course = cLoader.load(course.getBatchUid());

System.out.println("load of course by batch uid successful");


org = orgLoader.load(org.getBatchUid());

System.out.println("load of org by batch uid successful");


enroll = eLoader.load(enroll.getCourseSiteBatchUid(), enroll.getPersonBatchUid() );

System.out.println("load of enroll by batch uid successful");


staff = saLoader.load( staff.getCourseSiteBatchUid(), staff.getPersonBatchUid() );

System.out.println("load of staff by batch uid successful");

 

orgmem = orgMemLoader.load( orgmem.getOrganizationBatchUid(), orgmem.getPersonBatchUid());

System.out.println("load of orgmem by batch uid successful");


crs_cat = crsCatLoader.load(crs_cat.getBatchUid());

System.out.println("load of crs cat by batch uid successful");


org_cat = orgCatLoader.load(org_cat.getBatchUid());

System.out.println("load of org cat by batch uid successful");


org_cat_mem = orgCatMemLoader.load( org_cat_mem.getOrganizationBatchUid(), org_cat_mem.getCategoryBatchUid());

System.out.println("load of org cat mem by batch uid successful");

 

crs_cat_mem = crsCatMemLoader.load( crs_cat_mem.getCourseBatchUid(), crs_cat_mem.getCategoryBatchUid());

System.out.println("load of crs cat mem by batch uid successful");


BbList list = pLoader.load(person_1);


if ( list.size() == 1)

{

 System.out.println("Load of person_1 successful");

}

else throw new Exception("person 1 load failed with " + list.size() + " count");


list = pLoader.load(person_2);


if ( list.size() == 1)

{

 System.out.println("Load of person 2 successful");

}

else throw new Exception("person 2 load failed with " + list.size() + " count");


list = cLoader.load(course);


if ( list.size() == 1)

{

 System.out.println("Load of course successful");

}

else throw new Exception("course load failed with " + list.size() + " count");


list = orgLoader.load(org);


if ( list.size() == 1)

{

 System.out.println("Load of org successful");

}

else throw new Exception("org load failed with " + list.size() + " count");


list = eLoader.load(enroll);


if ( list.size() == 1)

{

 System.out.println("Load of enrollment successful");

}

else

{

 System.out.println(enroll);

 throw new Exception("enrollment load failed with " + list.size() + " count");

}


list = saLoader.load(staff);

if ( list.size() == 1)

{

 System.out.println("Load of staff successful");

}

else throw new Exception("staff load failed with " + list.size() + " count");


list = orgMemLoader.load(orgmem);

if ( list.size() == 1)

{

 System.out.println("Load of org membership successful");

}

else throw new Exception("org membership load failed with " + list.size() + " count");


list = crsCatMemLoader.load(crs_cat_mem);


if ( list.size() == 1)

{

 System.out.println("Load of course creation wizard successful");

}

else throw new Exception("course link load failed with " + list.size() + " count");


list = orgCatMemLoader.load(org_cat_mem);

 

if ( list.size() == 1)

{

 System.out.println("Load of organization link successful");

}

else throw new Exception("organization link load failed with " + list.size() + " count");


list = crsCatLoader.load(crs_cat);


if ( list.size() == 1)

{

 System.out.println("Load of course category successful");

}

else throw new Exception("course category load failed with " + list.size() + " count");


list = orgCatLoader.load(org_cat);


if ( list.size() == 1)

{

 System.out.println("Load of organization category successful");

}

else throw new Exception("organization category load failed with " + list.size() + " count");


/********************* End load test *************/

crsCatMemPersister.remove(crs_cat_mem);

orgCatMemPersister.remove(org_cat_mem);

crsCatPersister.remove(crs_cat);

orgCatPersister.remove(org_cat);