for (Iterator i = oldProcs.iterator(); i.hasNext ();) {
procDir.removeProcess ((Process)i.next());
}
// Create some processes, first with null data item
WfProcess null1 = pmgr.createProcess(req);
WfProcess null2 = pmgr.createProcess(req);
null2.start (); // start one to show it makes no difference
// Now with value item
ProcessData pd = new DefaultProcessData ();
pd.put ("testValue", "Find this");
WfProcess procThis1 = pmgr.createProcess(req);
procThis1.setProcessContext (pd);
WfProcess procThis2 = pmgr.createProcess(req);
procThis2.setProcessContext (pd);
WfProcess procThis3 = pmgr.createProcess(req);
procThis3.setProcessContext (pd);
pd.put ("testValue", "Find that");
WfProcess procThat1 = pmgr.createProcess(req);
procThat1.setProcessContext (pd);
WfProcess procThat2 = pmgr.createProcess(req);
procThat2.setProcessContext (pd);
// very long value item
String dummyText = "Streng dem definierten Wesen des Blindtextes "
+ "folgend, fungiere ich als solcher und gebe mich unverbindlich "
+ "inhaltsleer. In bedr�ckender Enge in vorgefertigte Masken "
+ "gepresst friste ich ein freudloses Dasein auf dem schmalen "
+ "Grat zwischen Nichtbeachtung und Bedeutungslosigkeit und habe "
+ "doch eine Bitte: Handeln Sie Sinn stiftend f�r meine Existenz "
+ "und lesen Sie mich.";
pd.put ("testValue", dummyText);
WfProcess procLong = pmgr.createProcess(req);
procLong.setProcessContext (pd);
// Do tests
Collection c = pmgr.findByDataItem("testValue", null);
assertTrue (c.size () == 2);
c = toKeys (c);
assertTrue (c.contains(null1.key()));
assertTrue (c.contains(null2.key()));
c = pmgr.findByDataItem ("testValue", "Find this");
assertTrue (c.size () == 3);
c = toKeys (c);
assertTrue (c.contains(procThis1.key ()));
assertTrue (c.contains(procThis2.key ()));
assertTrue (c.contains(procThis3.key ()));
c = pmgr.findByDataItem ("testValue", "Find that");
assertTrue (c.size () == 2);
c = toKeys (c);
assertTrue (c.contains(procThat1.key ()));
assertTrue (c.contains(procThat2.key ()));
c = pmgr.findByDataItem ("testValue", dummyText);
assertTrue (c.size () == 1);
c = toKeys (c);
assertTrue (c.contains(procLong.key ()));
// Cleanup
oldProcs = pmgr.processes();
for (Iterator i = oldProcs.iterator(); i.hasNext ();) {
procDir.removeProcess ((Process)i.next());