Source Code Cross Referenced for BasicTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » test » stress » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.test.stress 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.test.stress;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.List;
022:
023:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
024:        import edu.iu.uis.eden.clientapp.WorkflowInfo;
025:        import edu.iu.uis.eden.clientapp.vo.ActionRequestVO;
026:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
027:        import edu.iu.uis.eden.clientapp.vo.WorkflowAttributeDefinitionVO;
028:
029:        public class BasicTest extends AbstractTest {
030:
031:            static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
032:                    .getLogger(BasicTest.class);
033:
034:            private String initiator;
035:            private String documentTypeName;
036:            private String applicationContent;
037:            private List attributeDefinitions = new ArrayList();
038:            private boolean createIt = true;
039:            private Long documentId;
040:            private int errorsThusFar = 0;
041:            private int maxErrors = 5;
042:
043:            public BasicTest() {
044:            }
045:
046:            public BasicTest(String initiator, String documentTypeName)
047:                    throws Exception {
048:                this (initiator, documentTypeName, null, new ArrayList());
049:            }
050:
051:            public BasicTest(String initiator, String documentTypeName,
052:                    String applicationContent, List attributeDefinitions)
053:                    throws Exception {
054:                LOG.info("Initializing Basic Test with initiator=" + initiator
055:                        + ", documentType=" + documentTypeName
056:                        + ", applicationContent=" + applicationContent);
057:                this .initiator = initiator;
058:                this .documentTypeName = documentTypeName;
059:                if (attributeDefinitions == null)
060:                    attributeDefinitions = new ArrayList();
061:                this .applicationContent = applicationContent;
062:                this .attributeDefinitions = attributeDefinitions;
063:            }
064:
065:            public boolean doWork() throws Exception {
066:                long start = System.currentTimeMillis();
067:                boolean finalized = false;
068:                try {
069:                    if (createIt) {
070:                        long createStart = System.currentTimeMillis();
071:                        WorkflowDocument document = createDocument();
072:                        long createEnd = System.currentTimeMillis();
073:                        LOG.info("Created test document: "
074:                                + (createEnd - createStart) + " ms");
075:                        document.routeDocument("Stress Test route.  initiator="
076:                                + initiator + ", documentType="
077:                                + documentTypeName);
078:                        long routeEnd = System.currentTimeMillis();
079:                        TestInfo.markCallToServer();
080:                        LOG.info("Routed test document: "
081:                                + document.getRouteHeaderId() + " in "
082:                                + (routeEnd - createEnd) + " ms.");
083:                        if (document.getRouteHeaderId() == null) {
084:                            throw new Exception(
085:                                    "Document was not assigned a Document id.");
086:                        }
087:                    }
088:                    createIt = false;
089:                    long finalizeStart = System.currentTimeMillis();
090:                    finalized = finalizeDocument();
091:                    long finalizeEnd = System.currentTimeMillis();
092:                    LOG.info("Time to run finalizeDocument(): "
093:                            + (finalizeEnd - finalizeStart));
094:                } catch (Exception e) {
095:                    errorsThusFar++;
096:                    if (errorsThusFar >= maxErrors) {
097:                        LOG.fatal("Test exceeded its maxium number of errors!",
098:                                e);
099:                        throw e;
100:                    }
101:                    LOG.error(
102:                            "An error occurred when attempting to do work on test, errorsThusFar="
103:                                    + errorsThusFar, e);
104:                }
105:                long end = System.currentTimeMillis();
106:                LOG.info("Total time to doWork(): " + (end - start) + " ms");
107:                return finalized;
108:            }
109:
110:            private WorkflowDocument createDocument() throws Exception {
111:                WorkflowDocument document = new WorkflowDocument(
112:                        new NetworkIdVO(initiator), documentTypeName);
113:                documentId = document.getRouteHeaderId();
114:                TestInfo.markCallToServer();
115:                TestInfo.addRouteHeaderId(document.getRouteHeaderId());
116:                for (Iterator iterator = attributeDefinitions.iterator(); iterator
117:                        .hasNext();) {
118:                    WorkflowAttributeDefinitionVO definition = (WorkflowAttributeDefinitionVO) iterator
119:                            .next();
120:                    document.addAttributeDefinition(definition);
121:                }
122:                if (applicationContent != null
123:                        && !applicationContent.equals("")) {
124:                    document.setApplicationContent(applicationContent);
125:                }
126:                return document;
127:            }
128:
129:            protected boolean finalizeDocument() throws Exception {
130:                LOG.info("Finalizing document " + documentId);
131:                NetworkIdVO initiatorId = new NetworkIdVO(initiator);
132:                //do {
133:                //LOG.info("Sleeping for 10 seconds...");
134:                //Thread.sleep(10000);
135:                long t1 = System.currentTimeMillis();
136:                WorkflowDocument document = new WorkflowDocument(initiatorId,
137:                        documentId);
138:                long t2 = System.currentTimeMillis();
139:                TestInfo.markCallToServer();
140:                if (document.stateIsFinal()) {
141:                    return true;
142:                }
143:                if (document.stateIsException() || document.stateIsCanceled()
144:                        || document.stateIsDisapproved()) {
145:                    String message = "Document ended up in an illegal state: "
146:                            + document.getStatusDisplayValue();
147:                    LOG.error(message);
148:                    throw new Exception(message);
149:                }
150:                long t3 = System.currentTimeMillis();
151:                ActionRequestVO[] requests = new WorkflowInfo()
152:                        .getActionRequests(documentId);
153:                long t4 = System.currentTimeMillis();
154:                TestInfo.markCallToServer();
155:                StressTestUtils.handleRequests(documentId, requests);
156:                long t5 = System.currentTimeMillis();
157:                document = new WorkflowDocument(initiatorId, documentId);
158:                long t6 = System.currentTimeMillis();
159:                TestInfo.markCallToServer();
160:                LOG.info("Time to load initial document: " + (t2 - t1));
161:                LOG.info("Time to do some minor logic: " + (t3 - t2));
162:                LOG.info("Time to load Action Requests: " + (t4 - t3));
163:                LOG.info("Total time to Handle all Requests: " + (t5 - t4));
164:                LOG.info("Time to load document after handling requests: "
165:                        + (t6 - t5));
166:                return document.stateIsFinal();
167:                //} while (!document.stateIsFinal());
168:            }
169:
170:            public String getApplicationContent() {
171:                return applicationContent;
172:            }
173:
174:            public void setApplicationContent(String applicationContent) {
175:                this .applicationContent = applicationContent;
176:            }
177:
178:            public List getAttributeDefinitions() {
179:                return attributeDefinitions;
180:            }
181:
182:            public void setAttributeDefinitions(List attributeDefinitions) {
183:                this .attributeDefinitions = attributeDefinitions;
184:            }
185:
186:            public String getDocumentTypeName() {
187:                return documentTypeName;
188:            }
189:
190:            public void setDocumentTypeName(String documentTypeName) {
191:                this .documentTypeName = documentTypeName;
192:            }
193:
194:            public String getInitiator() {
195:                return initiator;
196:            }
197:
198:            public void setInitiator(String initiator) {
199:                this .initiator = initiator;
200:            }
201:
202:            public Long getDocumentId() {
203:                return documentId;
204:            }
205:
206:            public void setDocumentId(Long documentId) {
207:                this.documentId = documentId;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.