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