Source Code Cross Referenced for DocumentTypeXmlParserTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » xml » 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.xml 
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:        // Created on Jun 16, 2006
018:        package edu.iu.uis.eden.xml;
019:
020:        import java.util.ArrayList;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import org.junit.Test;
025:        import org.kuali.workflow.test.WorkflowTestCase;
026:
027:        import edu.iu.uis.eden.EdenConstants;
028:        import edu.iu.uis.eden.KEWServiceLocator;
029:        import edu.iu.uis.eden.clientapp.WorkflowDocument;
030:        import edu.iu.uis.eden.clientapp.vo.NetworkIdVO;
031:        import edu.iu.uis.eden.doctype.DocumentType;
032:        import edu.iu.uis.eden.doctype.DocumentTypeAttribute;
033:        import edu.iu.uis.eden.exception.InvalidWorkgroupException;
034:        import edu.iu.uis.eden.exception.InvalidXmlException;
035:
036:        public class DocumentTypeXmlParserTest extends WorkflowTestCase {
037:            private List testDoc(String docName, Class expectedException)
038:                    throws Exception {
039:                DocumentTypeXmlParser parser = new DocumentTypeXmlParser();
040:                try {
041:                    List docTypes = parser.parseDocumentTypes(getClass()
042:                            .getResourceAsStream(docName + ".xml"));
043:                    if (expectedException != null) {
044:                        fail(docName + " successfully loaded");
045:                    }
046:                    return docTypes;
047:                } catch (Exception e) {
048:                    if (expectedException == null
049:                            || !(expectedException.isAssignableFrom(e
050:                                    .getClass()))) {
051:                        throw e;
052:                    } else {
053:                        log.error(docName + " exception: " + e);
054:                        return new ArrayList();
055:                    }
056:                }
057:            }
058:
059:            @Test
060:            public void testLoadDocWithVariousActivationTypes()
061:                    throws Exception {
062:                testDoc("ValidActivationTypes", null);
063:            }
064:
065:            @Test
066:            public void testLoadDocWithInvalidActivationType() throws Exception {
067:                testDoc("BadActivationType", IllegalArgumentException.class);
068:            }
069:
070:            @Test
071:            public void testLoadDocWithValidPolicyNames() throws Exception {
072:                testDoc("ValidPolicyNames", null);
073:            }
074:
075:            @Test
076:            public void testLoadDocWithDuplicatePolicyName() throws Exception {
077:                testDoc("DuplicatePolicyName", InvalidXmlException.class);
078:            }
079:
080:            @Test
081:            public void testLoadDocWithBadPolicyName() throws Exception {
082:                testDoc("BadPolicyName", IllegalArgumentException.class);
083:            }
084:
085:            @Test
086:            public void testLoadDocWithBadNextNode() throws Exception {
087:                testDoc("BadNextNode", InvalidXmlException.class);
088:            }
089:
090:            @Test
091:            public void testLoadDocWithNoDocHandler() throws Exception {
092:                testDoc("NoDocHandler", InvalidXmlException.class);
093:            }
094:
095:            @Test
096:            public void testLoadDocWithBadExceptionWG() throws Exception {
097:                testDoc("BadExceptionWorkgroup",
098:                        InvalidWorkgroupException.class);
099:            }
100:
101:            @Test
102:            public void testLoadDocWithBadSuperUserWG() throws Exception {
103:                testDoc("BadSuperUserWorkgroup",
104:                        InvalidWorkgroupException.class);
105:            }
106:
107:            @Test
108:            public void testLoadDocWithBadBlanketApproveWG() throws Exception {
109:                testDoc("BadBlanketApproveWorkgroup",
110:                        InvalidWorkgroupException.class);
111:            }
112:
113:            @Test
114:            public void testLoadDocWithBadRuleTemplate() throws Exception {
115:                testDoc("BadRuleTemplate", InvalidXmlException.class);
116:            }
117:
118:            @Test
119:            public void testLoadDocWithInvalidParent() throws Exception {
120:                testDoc("InvalidParent", InvalidXmlException.class);
121:            }
122:
123:            @Test
124:            public void testLoadDocWithOrphanedNodes() throws Exception {
125:                testDoc("OrphanedNodes", InvalidXmlException.class);
126:            }
127:
128:            @Test
129:            public void testBlanketApprovePolicy() throws Exception {
130:                testDoc("BlanketApprovePolicy", null);
131:
132:                // on BlanketApprovePolicy1 anyone can blanket approve
133:                WorkflowDocument document = new WorkflowDocument(
134:                        new NetworkIdVO("pzhang"), "BlanketApprovePolicy1");
135:                document.saveRoutingData();
136:                assertTrue(document
137:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
138:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
139:                        document.getRouteHeaderId());
140:                assertFalse(document
141:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
142:
143:                // on BlanketApprovePolicy2 no-one can blanket approve
144:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
145:                        "BlanketApprovePolicy2");
146:                document.saveRoutingData();
147:                assertFalse(document
148:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
149:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
150:                        document.getRouteHeaderId());
151:                assertFalse(document
152:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
153:
154:                // on BlanketApprovePolicy3 no-one can blanket approve
155:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
156:                        "BlanketApprovePolicy3");
157:                document.saveRoutingData();
158:                assertFalse(document
159:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
160:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
161:                        document.getRouteHeaderId());
162:                assertFalse(document
163:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
164:
165:                // on BlanketApprovePolicy4 TestWorkgroup can blanket approve
166:                /*document = new WorkflowDocument(new NetworkIdVO("ewestfal"), "BlanketApprovePolicy4");
167:                document.saveRoutingData();
168:                assertFalse(document.isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));*/
169:
170:                // on Blanket ApprovePolicy 5, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
171:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
172:                        "BlanketApprovePolicy5");
173:                document.saveRoutingData();
174:                assertFalse(document
175:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
176:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
177:                        document.getRouteHeaderId());
178:                assertFalse(document
179:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
180:
181:                //   	 on Blanket ApprovePolicy 6, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
182:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
183:                        "BlanketApprovePolicy6");
184:                document.saveRoutingData();
185:                assertFalse(document
186:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
187:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
188:                        document.getRouteHeaderId());
189:                assertFalse(document
190:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
191:
192:                //   	 on Blanket ApprovePolicy 7, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
193:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
194:                        "BlanketApprovePolicy7");
195:                document.saveRoutingData();
196:                assertTrue(document
197:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
198:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
199:                        document.getRouteHeaderId());
200:                assertTrue(document
201:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
202:
203:                //   	 on BlanketApprovePolicy_Override_NONE, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
204:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
205:                        "BlanketApprovePolicy_Override_NONE");
206:                document.saveRoutingData();
207:                assertFalse(document
208:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
209:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
210:                        document.getRouteHeaderId());
211:                assertFalse(document
212:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
213:
214:                //   	 on BlanketApprovePolicy_Override_ANY, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
215:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
216:                        "BlanketApprovePolicy_Override_ANY");
217:                document.saveRoutingData();
218:                assertTrue(document
219:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
220:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
221:                        document.getRouteHeaderId());
222:                assertTrue(document
223:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
224:
225:                //  	 on BlanketApprovePolicy_Override_ANY, BlanketApprovePolicy is not allowed since no elements are defined on any document types in the hierarchy
226:                document = new WorkflowDocument(new NetworkIdVO("pzhang"),
227:                        "BlanketApprovePolicy_NoOverride");
228:                document.saveRoutingData();
229:                assertFalse(document
230:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
231:                document = new WorkflowDocument(new NetworkIdVO("ewestfal"),
232:                        document.getRouteHeaderId());
233:                assertTrue(document
234:                        .isActionCodeValidForDocument(EdenConstants.ACTION_TAKEN_BLANKET_APPROVE_CD));
235:            }
236:
237:            @Test
238:            public void testLoadDocWithOrderedAttributes() throws Exception {
239:                List documentTypes = testDoc("ValidActivationTypes", null);
240:                assertEquals("Should only be one doc type parsed", 1,
241:                        documentTypes.size());
242:                DocumentType docType = (DocumentType) documentTypes.get(0);
243:                for (int i = 0; i < docType.getDocumentTypeAttributes().size(); i++) {
244:                    DocumentTypeAttribute attribute = docType
245:                            .getDocumentTypeAttributes().get(i);
246:                    assertEquals("Invalid Index Number", i + 1, attribute
247:                            .getOrderIndex());
248:                }
249:
250:                DocumentType docTypeFresh = KEWServiceLocator
251:                        .getDocumentTypeService()
252:                        .findByName(
253:                                "DocumentTypeXmlParserTestDoc_ValidActivationTypes");
254:                assertEquals("Should be 3 doc type attributes", 3, docTypeFresh
255:                        .getDocumentTypeAttributes().size());
256:                int index = 0;
257:                DocumentTypeAttribute attribute = docTypeFresh
258:                        .getDocumentTypeAttributes().get(index);
259:                assertEquals("Invalid Index Number", index + 1, attribute
260:                        .getOrderIndex());
261:                assertEquals("Invalid attribute name for order value " + index
262:                        + 1, "TestRuleAttribute2", attribute.getRuleAttribute()
263:                        .getName());
264:
265:                index = 1;
266:                attribute = docTypeFresh.getDocumentTypeAttributes().get(index);
267:                assertEquals("Invalid Index Number", index + 1, attribute
268:                        .getOrderIndex());
269:                assertEquals("Invalid attribute name for order value " + index
270:                        + 1, "TestRuleAttribute3", attribute.getRuleAttribute()
271:                        .getName());
272:
273:                index = 2;
274:                attribute = docTypeFresh.getDocumentTypeAttributes().get(index);
275:                assertEquals("Invalid Index Number", index + 1, attribute
276:                        .getOrderIndex());
277:                assertEquals("Invalid attribute name for order value " + index
278:                        + 1, "TestRuleAttribute", attribute.getRuleAttribute()
279:                        .getName());
280:            }
281:
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.