1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.messaging.exceptionhandling;
17
18 import static org.junit.Assert.assertTrue;
19 import static org.junit.Assert.fail;
20
21 import org.junit.Test;
22 import org.kuali.rice.kew.api.WorkflowDocument;
23 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
24 import org.kuali.rice.kew.test.KEWTestCase;
25 import org.kuali.rice.kew.test.TestUtilities;
26 import org.kuali.rice.test.BaselineTestCase;
27
28
29
30
31
32
33 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
34 public class ExceptionRoutingServiceTest extends KEWTestCase {
35
36
37
38
39
40 @Test public void testKimExceptionRouting() throws Exception {
41 loadXmlFile("RouteExceptionTestDoc.xml");
42 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), "TestFinalApproverDocumentType");
43 document.setTitle("");
44 document.route("");
45 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
46 try {
47 document.approve("");
48 fail("document should have thrown routing exception");
49 } catch (Exception e) {
50
51 TestUtilities.getExceptionThreader().join();
52 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
53 assertTrue("Document should be in exception routing", document.isException());
54 }
55 }
56
57
58
59
60
61 @Test public void testKimExceptionRoutingWithDocHierarchy() throws Exception {
62 loadXmlFile("RouteExceptionTestDoc.xml");
63 String[] docNames = {"TestFinalApproverDocumentType_Child", "TestFinalApproverDocumentType_GrandChild"};
64
65 for (int i = 0; i < docNames.length; i++) {
66
67 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), docNames[i]);
68 document.setTitle("");
69 document.route("");
70 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
71 try {
72 document.approve("");
73 fail("document should have thrown routing exception");
74 } catch (Exception e) {
75
76 TestUtilities.getExceptionThreader().join();
77 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
78 assertTrue("Document should be in exception routing", document.isException());
79 }
80 }
81 }
82
83
84
85
86
87 @Test public void testKimExceptionRoutingWithRiceDocumentChild() throws Exception {
88 loadXmlFile("RouteExceptionTestDoc.xml");
89 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), "DocumentTypeDocument_New");
90 document.setTitle("");
91 document.route("");
92 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
93 try {
94 document.approve("");
95 fail("document should have thrown routing exception");
96 } catch (Exception e) {
97
98 TestUtilities.getExceptionThreader().join();
99 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
100 assertTrue("Document should be in exception routing", document.isException());
101 }
102 }
103 }