001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.kew.routing; 017 018 import static org.junit.Assert.assertTrue; 019 import static org.junit.Assert.fail; 020 021 import org.junit.Test; 022 import org.kuali.rice.kew.api.WorkflowDocument; 023 import org.kuali.rice.kew.api.WorkflowDocumentFactory; 024 import org.kuali.rice.kew.api.action.InvalidActionTakenException; 025 import org.kuali.rice.kew.test.KEWTestCase; 026 import org.kuali.rice.kew.test.TestUtilities; 027 import org.kuali.rice.test.BaselineTestCase.BaselineMode; 028 import org.kuali.rice.test.BaselineTestCase.Mode; 029 030 @BaselineMode(Mode.CLEAR_DB) 031 public class RoutingToInactiveWorkgroupTest extends KEWTestCase { 032 033 protected void loadTestData() throws Exception { 034 loadXmlFile("RoutingConfig.xml"); 035 } 036 037 @Test public void testRoutingToInactiveWorkgroup() throws Exception { 038 WorkflowDocument doc = WorkflowDocumentFactory.createDocument(getPrincipalIdForName("rkirkend"), "InactiveWorkgroupDocType"); 039 try { 040 doc.route(""); 041 fail("document should have thrown routing exception"); 042 } catch (Exception e) { 043 e.printStackTrace(); 044 } 045 TestUtilities.getExceptionThreader().join();//wait for doc to go into exception routing 046 doc = WorkflowDocumentFactory.loadDocument(getPrincipalIdForName("rkirkend"), doc.getDocumentId()); 047 assertTrue("Document should be in exception routing because workgroup is inactive", doc.isException()); 048 049 try { 050 doc.route("routing a document that is in exception routing"); 051 fail("Succeeded in routing document that is in exception routing"); 052 } catch (InvalidActionTakenException iate) { 053 log.info("Expected exception occurred: " + iate); 054 } 055 } 056 }