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.assertEquals;
19 import static org.junit.Assert.assertTrue;
20 import static org.junit.Assert.fail;
21
22 import org.junit.Test;
23 import org.kuali.rice.kew.api.WorkflowDocument;
24 import org.kuali.rice.kew.api.WorkflowDocumentFactory;
25 import org.kuali.rice.kew.api.document.DocumentStatus;
26 import org.kuali.rice.kew.test.KEWTestCase;
27 import org.kuali.rice.kew.test.TestUtilities;
28 import org.kuali.rice.test.BaselineTestCase;
29
30
31
32
33
34
35 @BaselineTestCase.BaselineMode(BaselineTestCase.Mode.NONE)
36 public class ExceptionRoutingServiceTest extends KEWTestCase {
37
38
39
40
41
42 @Test public void testKimExceptionRouting() throws Exception {
43 loadXmlFile("RouteExceptionTestDoc.xml");
44 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), "TestFinalApproverDocumentType");
45 document.setTitle("");
46 document.route("");
47 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
48 try {
49 document.approve("");
50 fail("document should have thrown routing exception");
51 } catch (Exception e) {
52
53 TestUtilities.getExceptionThreader().join();
54 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
55 assertTrue("Document should be in exception routing", document.isException());
56 }
57 }
58
59
60
61
62
63 @Test public void testKimExceptionRoutingWithDocHierarchy() throws Exception {
64 loadXmlFile("RouteExceptionTestDoc.xml");
65 String[] docNames = {"TestFinalApproverDocumentType_Child", "TestFinalApproverDocumentType_GrandChild"};
66
67 for (int i = 0; i < docNames.length; i++) {
68
69 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), docNames[i]);
70 document.setTitle("");
71 document.route("");
72 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
73 try {
74 document.approve("");
75 fail("document should have thrown routing exception");
76 } catch (Exception e) {
77
78 TestUtilities.getExceptionThreader().join();
79 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
80 assertTrue("Document should be in exception routing", document.isException());
81 }
82 }
83 }
84
85
86
87
88
89 @Test public void testKimExceptionRoutingWithRiceDocumentChild() throws Exception {
90 loadXmlFile("RouteExceptionTestDoc.xml");
91 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("admin"), "DocumentTypeDocument_New");
92 document.setTitle("");
93 document.route("");
94 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
95 try {
96 document.approve("");
97 fail("document should have thrown routing exception");
98 } catch (Exception e) {
99
100 TestUtilities.getExceptionThreader().join();
101 document = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), document.getDocumentId());
102 assertTrue("Document should be in exception routing", document.isException());
103 }
104 }
105
106
107
108
109
110
111 @Test public void testExplicitlyPlacingDocumentInException() {
112 loadXmlFile("org/kuali/rice/kew/routeheader/AppDocStatusTestConfig.xml");
113 WorkflowDocument document = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "TestAppDocStatusDoc1");
114 document.setTitle("");
115 document.route("");
116
117 document.placeInExceptionRouting("explicitly placing in exception routing");
118 assertEquals(DocumentStatus.EXCEPTION, document.getStatus());
119 }
120 }