001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: adrianprice@sourceforge.net.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.test.standalone;
046:
047: import junit.framework.Test;
048: import junit.framework.TestCase;
049: import junit.framework.TestSuite;
050: import org.obe.engine.persistence.memory.BasicActivityInstance;
051: import org.obe.engine.persistence.memory.BasicAttributeInstance;
052: import org.obe.engine.persistence.memory.BasicProcessInstance;
053: import org.obe.engine.persistence.memory.BasicWorkItem;
054: import org.obe.event.*;
055: import org.obe.spi.event.*;
056: import org.obe.spi.model.ActivityInstance;
057: import org.obe.spi.model.AttributeInstance;
058: import org.obe.spi.model.ProcessInstance;
059: import org.obe.spi.model.WorkItem;
060: import org.obe.spi.service.ServiceManager;
061: import org.obe.spi.service.WorkflowEventBroker;
062: import org.obe.xpdl.model.activity.Activity;
063: import org.obe.xpdl.model.data.BasicType;
064: import org.obe.xpdl.model.data.DataField;
065: import org.obe.xpdl.model.data.DataType;
066: import org.obe.xpdl.model.data.Type;
067: import org.obe.xpdl.model.pkg.PackageHeader;
068: import org.obe.xpdl.model.pkg.XPDLPackage;
069: import org.obe.xpdl.model.workflow.ProcessHeader;
070: import org.obe.xpdl.model.workflow.WorkflowProcess;
071: import org.wfmc.wapi.WMActivityInstanceState;
072: import org.wfmc.wapi.WMProcessInstanceState;
073: import org.wfmc.wapi.WMWorkItemState;
074:
075: /**
076: * Tests the engine's event notification framework.
077: *
078: * @author Adrian Price
079: */
080: public class EngineEventTest extends TestCase {
081: private static ServiceManager _svcMgr;
082: private static WorkflowEventBroker _eventBroker;
083: private static final String[] TESTS = { "testInitialize",
084: "testActivityInstanceEvent", "testAttributeInstanceEvent",
085: "testPackageEvent", "testProcessDefinitionEvent",
086: "testProcessInstanceEvent", "testWorkItemEvent",
087: "testUninitialize" };
088:
089: // It is necessary to build the test suite explicitly because JUnit
090: // sometimes changes the order in which the tests are executed. The tests
091: // in this suite depend upon each other, and must therefore be executed in
092: // the correct sequence.
093: public static Test suite() {
094: TestSuite suite = new TestSuite();
095: for (int i = 0; i < TESTS.length; i++) {
096: suite.addTest(new EngineEventTest(TESTS[i]));
097: }
098: return suite;
099: }
100:
101: public EngineEventTest(String name) {
102: super (name);
103: }
104:
105: public void testInitialize() {
106: // Must use the default OBE Service Manager configuration, to avoid any
107: // problems caused, for example, by attempting to initialize J2EE-based
108: // services outside of a J2EE environment.
109: _svcMgr = new ServiceManager(ServiceManager.getDefaults());
110: _eventBroker = _svcMgr.getWorkflowEventBroker();
111: }
112:
113: public void testActivityInstanceEvent() {
114: ProcessInstance processInstance = new BasicProcessInstance(
115: null, null, null);
116: ActivityInstance src = new BasicActivityInstance(null,
117: processInstance, null, null, null, null, null);
118: Activity def = new Activity("0", null, null);
119: ActivityInstanceListenerSupport sup = new ActivityInstanceListenerSupport(
120: _eventBroker);
121:
122: // Test the complete set of events.
123: ActivityInstanceListenerTest listener1 = new ActivityInstanceListenerTest();
124: sup.addListener(listener1,
125: ActivityInstanceListener.ALL_EVENT_MASK);
126: try {
127: sup.addListener(listener1,
128: ActivityInstanceListener.ALL_EVENT_MASK);
129: fail("Duplicate subscription did not throw exception");
130: } catch (IllegalArgumentException e) {
131: }
132:
133: // Test a subset of events.
134: int mask = ActivityInstanceListener.ABORTED_EVENT_MASK
135: | ActivityInstanceListener.TERMINATED_EVENT_MASK;
136: ActivityInstanceListenerTest listener2 = new ActivityInstanceListenerTest(
137: 2, mask);
138: sup.addListener(listener2, mask);
139:
140: // Fire all the events & check that the listeners received only those
141: // to which they subscribed.
142: int previousState = WMActivityInstanceState.OPEN_RUNNING_INT;
143: sup.fireActivityInstanceAborted(src, def, previousState);
144: sup.fireActivityInstanceCompleted(src, def, previousState);
145: sup.fireActivityInstanceCreated(src, def);
146: sup.fireActivityInstanceResumed(src, def, previousState);
147: sup.fireActivityInstanceStarted(src, def, previousState);
148: sup.fireActivityInstanceStopped(src, def, previousState);
149: sup.fireActivityInstanceSuspended(src, def, previousState);
150: sup.fireActivityInstanceTerminated(src, def, previousState);
151: listener1.assertValid();
152: listener2.assertValid();
153:
154: sup.removeListener(listener1);
155: try {
156: sup.removeListener(listener1);
157: fail("Removing invalid subscription did not throw exception");
158: } catch (IllegalArgumentException e) {
159: }
160: sup.removeListener(listener2);
161: sup.clear();
162:
163: System.out.println("testActivityInstanceEvent passed");
164: }
165:
166: public void testAttributeInstanceEvent() {
167: AttributeInstance src = new BasicAttributeInstance(null, null,
168: Type.STRING_TYPE, null);
169: DataField def = new DataField("0", null, new DataType(
170: BasicType.STRING));
171: AttributeInstanceListenerSupport sup = new AttributeInstanceListenerSupport(
172: _eventBroker);
173:
174: // Test the complete set of events.
175: AttributeInstanceListenerTest listener1 = new AttributeInstanceListenerTest();
176: sup.addListener(listener1,
177: AttributeInstanceListener.ALL_EVENT_MASK);
178: try {
179: sup.addListener(listener1,
180: AttributeInstanceListener.ALL_EVENT_MASK);
181: fail("Duplicate subscription did not throw exception");
182: } catch (IllegalArgumentException e) {
183: }
184:
185: // Test a subset of events.
186: int mask = AttributeInstanceListener.CREATED_EVENT_MASK
187: | AttributeInstanceListener.UPDATED_EVENT_MASK;
188: AttributeInstanceListenerTest listener2 = new AttributeInstanceListenerTest(
189: 2, mask);
190: sup.addListener(listener2, mask);
191:
192: // Fire all the events & check that the listeners received only those
193: // to which they subscribed.
194: sup.fireAttributeInstanceCreated(src, def);
195: sup.fireAttributeInstanceDeleted(src, def);
196: sup.fireAttributeInstanceUpdated(src, def, "previous");
197: listener1.assertValid();
198: listener2.assertValid();
199:
200: sup.removeListener(listener1);
201: try {
202: sup.removeListener(listener1);
203: fail("Removing invalid subscription did not throw exception");
204: } catch (IllegalArgumentException e) {
205: }
206: sup.removeListener(listener2);
207: sup.clear();
208:
209: System.out.println("testAttributeInstanceEvent passed");
210: }
211:
212: public void testPackageEvent() {
213: XPDLPackage src = new XPDLPackage("0", null,
214: new PackageHeader());
215: PackageListenerSupport sup = new PackageListenerSupport(
216: _eventBroker);
217:
218: // Test the complete set of events.
219: PackageListenerTest listener1 = new PackageListenerTest();
220: sup.addListener(listener1, PackageListener.ALL_EVENT_MASK);
221: try {
222: sup.addListener(listener1, PackageListener.ALL_EVENT_MASK);
223: fail("Duplicate subscription did not throw exception");
224: } catch (IllegalArgumentException e) {
225: }
226:
227: // Test a subset of events.
228: int mask = PackageListener.CREATED_EVENT_MASK
229: | PackageListener.UPDATED_EVENT_MASK;
230: PackageListenerTest listener2 = new PackageListenerTest(2, mask);
231: sup.addListener(listener2, mask);
232:
233: // Fire all the events & check that the listeners received only those
234: // to which they subscribed.
235: sup.firePackageCreated(src);
236: sup.firePackageDeleted(src);
237: sup.firePackageUpdated(src);
238: listener1.assertValid();
239: listener2.assertValid();
240:
241: sup.removeListener(listener1);
242: try {
243: sup.removeListener(listener1);
244: fail("Removing invalid subscription did not throw exception");
245: } catch (IllegalArgumentException e) {
246: }
247: sup.removeListener(listener2);
248: sup.clear();
249:
250: System.out.println("testPackageEvent passed");
251: }
252:
253: public void testProcessDefinitionEvent() {
254: WorkflowProcess src = new WorkflowProcess("0", null, null,
255: new ProcessHeader());
256: ProcessDefinitionListenerSupport sup = new ProcessDefinitionListenerSupport(
257: _eventBroker);
258:
259: // Test the complete set of events.
260: ProcessDefinitionListenerTest listener1 = new ProcessDefinitionListenerTest();
261: sup.addListener(listener1,
262: ProcessDefinitionListener.ALL_EVENT_MASK);
263: try {
264: sup.addListener(listener1,
265: ProcessDefinitionListener.ALL_EVENT_MASK);
266: fail("Duplicate subscription did not throw exception");
267: } catch (IllegalArgumentException e) {
268: }
269:
270: // Test a subset of events.
271: int mask = ProcessDefinitionListener.CREATED_EVENT_MASK
272: | ProcessDefinitionListener.UPDATED_EVENT_MASK;
273: ProcessDefinitionListenerTest listener2 = new ProcessDefinitionListenerTest(
274: 2, mask);
275: sup.addListener(listener2, mask);
276:
277: // Fire all the events & check that the listeners received only those
278: // to which they subscribed.
279: sup.fireProcessDefinitionCreated(src);
280: sup.fireProcessDefinitionDeleted(src);
281: sup.fireProcessDefinitionDisabled(src);
282: sup.fireProcessDefinitionEnabled(src);
283: sup.fireProcessDefinitionUpdated(src);
284: listener1.assertValid();
285: listener2.assertValid();
286:
287: sup.removeListener(listener1);
288: try {
289: sup.removeListener(listener1);
290: fail("Removing invalid subscription did not throw exception");
291: } catch (IllegalArgumentException e) {
292: }
293: sup.removeListener(listener2);
294: sup.clear();
295:
296: System.out.println("testProcessDefinitionEvent passed");
297: }
298:
299: public void testProcessInstanceEvent() {
300: ProcessInstance src = new BasicProcessInstance(null, null, null);
301: WorkflowProcess def = new WorkflowProcess("0", null, null,
302: new ProcessHeader());
303: ProcessInstanceListenerSupport sup = new ProcessInstanceListenerSupport(
304: _eventBroker);
305:
306: // Test the complete set of events.
307: ProcessInstanceListenerTest listener1 = new ProcessInstanceListenerTest();
308: sup.addListener(listener1,
309: ProcessInstanceListener.ALL_EVENT_MASK);
310: try {
311: sup.addListener(listener1,
312: ProcessInstanceListener.ALL_EVENT_MASK);
313: fail("Duplicate subscription did not throw exception");
314: } catch (IllegalArgumentException e) {
315: }
316:
317: // Test a subset of events.
318: int mask = ProcessInstanceListener.ABORTED_EVENT_MASK
319: | ProcessInstanceListener.TERMINATED_EVENT_MASK;
320: ProcessInstanceListenerTest listener2 = new ProcessInstanceListenerTest(
321: 2, mask);
322: sup.addListener(listener2, mask);
323:
324: // Fire all the events & check that the listeners received only those
325: // to which they subscribed.
326: int previousState = WMProcessInstanceState.OPEN_RUNNING_INT;
327: sup.fireProcessInstanceAborted(src, def, previousState);
328: sup.fireProcessInstanceCompleted(src, def, previousState);
329: sup.fireProcessInstanceCreated(src, def);
330: sup.fireProcessInstanceDeleted(src, def, previousState);
331: sup.fireProcessInstanceResumed(src, def, previousState);
332: sup.fireProcessInstanceStarted(src, def, previousState);
333: sup.fireProcessInstanceSuspended(src, def, previousState);
334: sup.fireProcessInstanceTerminated(src, def, previousState);
335: listener1.assertValid();
336: listener2.assertValid();
337:
338: sup.removeListener(listener1);
339: try {
340: sup.removeListener(listener1);
341: fail("Removing invalid subscription did not throw exception");
342: } catch (IllegalArgumentException e) {
343: }
344: sup.removeListener(listener2);
345: sup.clear();
346:
347: System.out.println("testProcessInstanceEvent passed");
348: }
349:
350: public void testWorkItemEvent() {
351: WorkItem src = new BasicWorkItem(null, null, null,
352: new BasicActivityInstance(null,
353: new BasicProcessInstance(null, null, null),
354: null, null, null, null, null), 0);
355: Activity def = new Activity("0", null, null);
356: WorkItemListenerSupport sup = new WorkItemListenerSupport(
357: _eventBroker);
358:
359: // Test the complete set of events.
360: WorkItemListenerTest listener1 = new WorkItemListenerTest();
361: sup.addListener(listener1, WorkItemListener.ALL_EVENT_MASK);
362: try {
363: sup.addListener(listener1, WorkItemListener.ALL_EVENT_MASK);
364: fail("Duplicate subscription did not throw exception");
365: } catch (IllegalArgumentException e) {
366: }
367:
368: // Test a subset of events.
369: int mask = WorkItemListener.ABORTED_EVENT_MASK
370: | WorkItemListener.TERMINATED_EVENT_MASK;
371: WorkItemListenerTest listener2 = new WorkItemListenerTest(2,
372: mask);
373: sup.addListener(listener2, mask);
374:
375: // Fire all the events & check that the listeners received only those
376: // to which they subscribed.
377: int previousState = WMWorkItemState.OPEN_RUNNING_INT;
378: sup.fireWorkItemAborted(src, def, previousState);
379: sup.fireWorkItemAssigned(src, def);
380: sup.fireWorkItemCompleted(src, def, previousState);
381: sup.fireWorkItemCreated(src, def);
382: sup.fireWorkItemResumed(src, def, previousState);
383: sup.fireWorkItemStarted(src, def, previousState);
384: sup.fireWorkItemStopped(src, def, previousState);
385: sup.fireWorkItemSuspended(src, def, previousState);
386: sup.fireWorkItemTerminated(src, def, previousState);
387: listener1.assertValid();
388: listener2.assertValid();
389:
390: sup.removeListener(listener1);
391: try {
392: sup.removeListener(listener1);
393: fail("Removing invalid subscription did not throw exception");
394: } catch (IllegalArgumentException e) {
395: }
396: sup.removeListener(listener2);
397: sup.clear();
398:
399: System.out.println("testWorkItemEvent passed");
400: }
401:
402: public void testUninitialize() {
403: _svcMgr = null;
404: _eventBroker = null;
405: }
406:
407: private abstract class AbstractEventListener {
408: int _countExpected;
409: int _countActual;
410: int _maskExpected;
411: int _maskActual;
412:
413: // This constructor assumes that all events will be fired.
414: protected AbstractEventListener(int countExpected) {
415: this (countExpected, (1 << countExpected) - 1);
416: }
417:
418: // This constructor assumes that a subset of all events will be fired.
419: protected AbstractEventListener(int countExpected,
420: int maskExpected) {
421: _countExpected = countExpected;
422: _maskExpected = maskExpected;
423: }
424:
425: protected void checkEvent(int expected, WorkflowEvent e) {
426: Object src = e.getSource();
427: assertNotNull("Source is null;", src);
428: assertTrue("Source class is wrong;", getSourceClass()
429: .isAssignableFrom(src.getClass()));
430: assertEquals("Wrong event id;", expected, e.getId());
431: }
432:
433: abstract Class getSourceClass();
434:
435: final void assertValid() {
436: assertEquals("Wrong notification count;", _countExpected,
437: _countActual);
438:
439: // This mask value corresponds to the bitmask required to receive
440: // all possible notifications for this event listener type.
441: assertEquals("Missing notification;", _maskExpected,
442: _maskActual);
443: }
444:
445: final void reset() {
446: _countActual = _maskActual = 0;
447: }
448: }
449:
450: private class ActivityInstanceListenerTest extends
451: AbstractEventListener implements ActivityInstanceListener {
452:
453: ActivityInstanceListenerTest() {
454: super (8);
455: }
456:
457: ActivityInstanceListenerTest(int countExpected, int maskExpected) {
458: super (countExpected, maskExpected);
459: }
460:
461: Class getSourceClass() {
462: return ActivityInstance.class;
463: }
464:
465: public void activityInstanceAborted(ActivityInstanceEvent e) {
466: checkEvent(ActivityInstanceEvent.ABORTED, e);
467: _maskActual |= ActivityInstanceListener.ABORTED_EVENT_MASK;
468: _countActual++;
469: }
470:
471: public void activityInstanceCompleted(ActivityInstanceEvent e) {
472: checkEvent(ActivityInstanceEvent.COMPLETED, e);
473: _maskActual |= ActivityInstanceListener.COMPLETED_EVENT_MASK;
474: _countActual++;
475: }
476:
477: public void activityInstanceCreated(ActivityInstanceEvent e) {
478: checkEvent(ActivityInstanceEvent.CREATED, e);
479: _maskActual |= ActivityInstanceListener.CREATED_EVENT_MASK;
480: _countActual++;
481: }
482:
483: public void activityInstanceResumed(ActivityInstanceEvent e) {
484: checkEvent(ActivityInstanceEvent.RESUMED, e);
485: _maskActual |= ActivityInstanceListener.RESUMED_EVENT_MASK;
486: _countActual++;
487: }
488:
489: public void activityInstanceStarted(ActivityInstanceEvent e) {
490: checkEvent(ActivityInstanceEvent.STARTED, e);
491: _maskActual |= ActivityInstanceListener.STARTED_EVENT_MASK;
492: _countActual++;
493: }
494:
495: public void activityInstanceStopped(ActivityInstanceEvent e) {
496: checkEvent(ActivityInstanceEvent.STOPPED, e);
497: _maskActual |= ActivityInstanceListener.STOPPED_EVENT_MASK;
498: _countActual++;
499: }
500:
501: public void activityInstanceSuspended(ActivityInstanceEvent e) {
502: checkEvent(ActivityInstanceEvent.SUSPENDED, e);
503: _maskActual |= ActivityInstanceListener.SUSPENDED_EVENT_MASK;
504: _countActual++;
505: }
506:
507: public void activityInstanceTerminated(ActivityInstanceEvent e) {
508: checkEvent(ActivityInstanceEvent.TERMINATED, e);
509: _maskActual |= ActivityInstanceListener.TERMINATED_EVENT_MASK;
510: _countActual++;
511: }
512: }
513:
514: private class AttributeInstanceListenerTest extends
515: AbstractEventListener implements AttributeInstanceListener {
516:
517: AttributeInstanceListenerTest() {
518: super (3);
519: }
520:
521: AttributeInstanceListenerTest(int countExpected,
522: int maskExpected) {
523: super (countExpected, maskExpected);
524: }
525:
526: Class getSourceClass() {
527: return AttributeInstance.class;
528: }
529:
530: public void attributeInstanceCreated(AttributeInstanceEvent e) {
531: checkEvent(AttributeInstanceEvent.CREATED, e);
532: _maskActual |= AttributeInstanceListener.CREATED_EVENT_MASK;
533: _countActual++;
534: }
535:
536: public void attributeInstanceDeleted(AttributeInstanceEvent e) {
537: checkEvent(AttributeInstanceEvent.DELETED, e);
538: _maskActual |= AttributeInstanceListener.DELETED_EVENT_MASK;
539: _countActual++;
540: }
541:
542: public void attributeInstanceUpdated(AttributeInstanceEvent e) {
543: checkEvent(AttributeInstanceEvent.UPDATED, e);
544: _maskActual |= AttributeInstanceListener.UPDATED_EVENT_MASK;
545: _countActual++;
546: }
547: }
548:
549: private class PackageListenerTest extends AbstractEventListener
550: implements PackageListener {
551:
552: PackageListenerTest() {
553: super (3);
554: }
555:
556: PackageListenerTest(int countExpected, int maskExpected) {
557: super (countExpected, maskExpected);
558: }
559:
560: Class getSourceClass() {
561: return XPDLPackage.class;
562: }
563:
564: public void packageCreated(PackageEvent e) {
565: checkEvent(PackageEvent.CREATED, e);
566: _maskActual |= PackageListener.CREATED_EVENT_MASK;
567: _countActual++;
568: }
569:
570: public void packageDeleted(PackageEvent e) {
571: checkEvent(PackageEvent.DELETED, e);
572: _maskActual |= PackageListener.DELETED_EVENT_MASK;
573: _countActual++;
574: }
575:
576: public void packageUpdated(PackageEvent e) {
577: checkEvent(PackageEvent.UPDATED, e);
578: _maskActual |= PackageListener.UPDATED_EVENT_MASK;
579: _countActual++;
580: }
581:
582: }
583:
584: private class ProcessDefinitionListenerTest extends
585: AbstractEventListener implements ProcessDefinitionListener {
586:
587: ProcessDefinitionListenerTest() {
588: super (5);
589: }
590:
591: ProcessDefinitionListenerTest(int countExpected,
592: int maskExpected) {
593:
594: super (countExpected, maskExpected);
595: }
596:
597: Class getSourceClass() {
598: return WorkflowProcess.class;
599: }
600:
601: public void processDefinitionCreated(ProcessDefinitionEvent e) {
602: checkEvent(ProcessDefinitionEvent.CREATED, e);
603: _maskActual |= ProcessDefinitionListener.CREATED_EVENT_MASK;
604: _countActual++;
605: }
606:
607: public void processDefinitionDeleted(ProcessDefinitionEvent e) {
608: checkEvent(ProcessDefinitionEvent.DELETED, e);
609: _maskActual |= ProcessDefinitionListener.DELETED_EVENT_MASK;
610: _countActual++;
611: }
612:
613: public void processDefinitionDisabled(ProcessDefinitionEvent e) {
614: checkEvent(ProcessDefinitionEvent.DISABLED, e);
615: _maskActual |= ProcessDefinitionListener.DISABLED_EVENT_MASK;
616: _countActual++;
617: }
618:
619: public void processDefinitionEnabled(ProcessDefinitionEvent e) {
620: checkEvent(ProcessDefinitionEvent.ENABLED, e);
621: _maskActual |= ProcessDefinitionListener.ENABLED_EVENT_MASK;
622: _countActual++;
623: }
624:
625: public void processDefinitionUpdated(ProcessDefinitionEvent e) {
626: checkEvent(ProcessDefinitionEvent.UPDATED, e);
627: _maskActual |= ProcessDefinitionListener.UPDATED_EVENT_MASK;
628: _countActual++;
629: }
630: }
631:
632: private class ProcessInstanceListenerTest extends
633: AbstractEventListener implements ProcessInstanceListener {
634:
635: ProcessInstanceListenerTest() {
636: super (8);
637: }
638:
639: ProcessInstanceListenerTest(int countExpected, int maskExpected) {
640: super (countExpected, maskExpected);
641: }
642:
643: Class getSourceClass() {
644: return ProcessInstance.class;
645: }
646:
647: public void processInstanceAborted(ProcessInstanceEvent e) {
648: checkEvent(ProcessInstanceEvent.ABORTED, e);
649: _maskActual |= ProcessInstanceListener.ABORTED_EVENT_MASK;
650: _countActual++;
651: }
652:
653: public void processInstanceCompleted(ProcessInstanceEvent e) {
654: checkEvent(ProcessInstanceEvent.COMPLETED, e);
655: _maskActual |= ProcessInstanceListener.COMPLETED_EVENT_MASK;
656: _countActual++;
657: }
658:
659: public void processInstanceCreated(ProcessInstanceEvent e) {
660: checkEvent(ProcessInstanceEvent.CREATED, e);
661: _maskActual |= ProcessInstanceListener.CREATED_EVENT_MASK;
662: _countActual++;
663: }
664:
665: public void processInstanceDeleted(ProcessInstanceEvent e) {
666: checkEvent(ProcessInstanceEvent.DELETED, e);
667: _maskActual |= ProcessInstanceListener.DELETED_EVENT_MASK;
668: _countActual++;
669: }
670:
671: public void processInstanceResumed(ProcessInstanceEvent e) {
672: checkEvent(ProcessInstanceEvent.RESUMED, e);
673: _maskActual |= ProcessInstanceListener.RESUMED_EVENT_MASK;
674: _countActual++;
675: }
676:
677: public void processInstanceStarted(ProcessInstanceEvent e) {
678: checkEvent(ProcessInstanceEvent.STARTED, e);
679: _maskActual |= ProcessInstanceListener.STARTED_EVENT_MASK;
680: _countActual++;
681: }
682:
683: public void processInstanceSuspended(ProcessInstanceEvent e) {
684: checkEvent(ProcessInstanceEvent.SUSPENDED, e);
685: _maskActual |= ProcessInstanceListener.SUSPENDED_EVENT_MASK;
686: _countActual++;
687: }
688:
689: public void processInstanceTerminated(ProcessInstanceEvent e) {
690: checkEvent(ProcessInstanceEvent.TERMINATED, e);
691: _maskActual |= ProcessInstanceListener.TERMINATED_EVENT_MASK;
692: _countActual++;
693: }
694: }
695:
696: private class WorkItemListenerTest extends AbstractEventListener
697: implements WorkItemListener {
698:
699: WorkItemListenerTest() {
700: super (9);
701: }
702:
703: WorkItemListenerTest(int countExpected, int maskExpected) {
704: super (countExpected, maskExpected);
705: }
706:
707: Class getSourceClass() {
708: return WorkItem.class;
709: }
710:
711: public void workItemAborted(WorkItemEvent e) {
712: checkEvent(WorkItemEvent.ABORTED, e);
713: _maskActual |= WorkItemListener.ABORTED_EVENT_MASK;
714: _countActual++;
715: }
716:
717: public void workItemAssigned(WorkItemEvent e) {
718: checkEvent(WorkItemEvent.ASSIGNED, e);
719: _maskActual |= WorkItemListener.ASSIGNED_EVENT_MASK;
720: _countActual++;
721: }
722:
723: public void workItemCompleted(WorkItemEvent e) {
724: checkEvent(WorkItemEvent.COMPLETED, e);
725: _maskActual |= WorkItemListener.COMPLETED_EVENT_MASK;
726: _countActual++;
727: }
728:
729: public void workItemCreated(WorkItemEvent e) {
730: checkEvent(WorkItemEvent.CREATED, e);
731: _maskActual |= WorkItemListener.CREATED_EVENT_MASK;
732: _countActual++;
733: }
734:
735: public void workItemResumed(WorkItemEvent e) {
736: checkEvent(WorkItemEvent.RESUMED, e);
737: _maskActual |= WorkItemListener.RESUMED_EVENT_MASK;
738: _countActual++;
739: }
740:
741: public void workItemStarted(WorkItemEvent e) {
742: checkEvent(WorkItemEvent.STARTED, e);
743: _maskActual |= WorkItemListener.STARTED_EVENT_MASK;
744: _countActual++;
745: }
746:
747: public void workItemStopped(WorkItemEvent e) {
748: checkEvent(WorkItemEvent.STOPPED, e);
749: _maskActual |= WorkItemListener.STOPPED_EVENT_MASK;
750: _countActual++;
751: }
752:
753: public void workItemSuspended(WorkItemEvent e) {
754: checkEvent(WorkItemEvent.SUSPENDED, e);
755: _maskActual |= WorkItemListener.SUSPENDED_EVENT_MASK;
756: _countActual++;
757: }
758:
759: public void workItemTerminated(WorkItemEvent e) {
760: checkEvent(WorkItemEvent.TERMINATED, e);
761: _maskActual |= WorkItemListener.TERMINATED_EVENT_MASK;
762: _countActual++;
763: }
764: }
765: }
|