View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    * 
4    * 
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    * 
9    * http://www.opensource.org/licenses/ecl2.php
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.routing;
18  
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.action.InvalidActionTakenException;
26  import org.kuali.rice.kew.test.KEWTestCase;
27  import org.kuali.rice.kew.test.TestUtilities;
28  import org.kuali.rice.test.BaselineTestCase.BaselineMode;
29  import org.kuali.rice.test.BaselineTestCase.Mode;
30  
31  @BaselineMode(Mode.CLEAR_DB)
32  public class RoutingToInactiveWorkgroupTest extends KEWTestCase {
33  
34      protected void loadTestData() throws Exception {
35          loadXmlFile("RoutingConfig.xml");
36      }
37      
38      @Test public void testRoutingToInactiveWorkgroup() throws Exception {
39          WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "InactiveWorkgroupDocType");
40          try {
41              doc.route("");
42              fail("document should have thrown routing exception");
43          } catch (Exception e) {
44              e.printStackTrace();
45          }
46          TestUtilities.getExceptionThreader().join();//wait for doc to go into exception routing
47          doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), doc.getDocumentId());
48          assertTrue("Document should be in exception routing because workgroup is inactive", doc.isException());
49  
50          try {
51              doc.route("routing a document that is in exception routing");
52              fail("Succeeded in routing document that is in exception routing");
53          } catch (InvalidActionTakenException iate) {
54              log.info("Expected exception occurred: " + iate);
55          }
56      }
57  }