001    /*
002     * Copyright 2006-2012 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    
017    package org.kuali.rice.kew.routeheader;
018    
019    import org.junit.Ignore;
020    import org.junit.Test;
021    import org.kuali.rice.kew.api.WorkflowDocument;
022    import org.kuali.rice.kew.api.WorkflowDocumentFactory;
023    import org.kuali.rice.kew.test.KEWTestCase;
024    import org.kuali.rice.kew.util.PerformanceLogger;
025    
026    /**
027     *
028     */
029    public class WorkflowDocumentServiceTest extends KEWTestCase {
030        protected void loadTestData() throws Exception {
031            
032        }
033    
034        @Ignore @Test
035        public void testCreatePerformanceWithBranches() {
036            testCreatePerformance("DocTypeWithBranches.xml", "Testing.LongRoutePath");
037        }
038    
039        @Ignore @Test
040        public void testCreatePerformanceWithoutBranches() {
041            testCreatePerformance("DocTypeWithoutBranches.xml", "Testing.LongRoutePathWithoutBranches");
042        }
043        
044        protected void testCreatePerformance(String xml, String doctype) {
045            PerformanceLogger logger = new PerformanceLogger();
046            logger.log("Loading " + xml);
047            loadXmlFile(xml);
048            logger.log("Done loading " + xml);
049    
050            System.err.println("Creating and routing " + doctype);
051            WorkflowDocument document = WorkflowDocumentFactory.createDocument("admin", doctype);
052            // There are no rules associated with this so this doc goes to final as soon as it is routed
053            document.route("");
054            // Setting the title so that routing data actually gets saved
055            document.setTitle("Testing");
056            // Sleep to give it a chance to route, may not be needed
057            logger = new PerformanceLogger();
058            logger.log("starting save routing data");
059            document.saveDocumentData();
060            logger.log("finished save routing data");
061        }
062    }