Source Code Cross Referenced for RuleTemplateXmlExporterTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » xml » export » 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.export 
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.xml.export;
018:
019:        import java.io.BufferedInputStream;
020:        import java.io.ByteArrayInputStream;
021:        import java.util.Iterator;
022:        import java.util.List;
023:
024:        import org.junit.Test;
025:
026:        import edu.iu.uis.eden.KEWServiceLocator;
027:        import edu.iu.uis.eden.export.ExportDataSet;
028:        import edu.iu.uis.eden.export.ExportFormat;
029:        import edu.iu.uis.eden.routetemplate.RuleTemplate;
030:        import edu.iu.uis.eden.routetemplate.RuleTemplateAttribute;
031:        import edu.iu.uis.eden.routetemplate.RuleTemplateOption;
032:        import edu.iu.uis.eden.test.OldClearDatabaseLifecycle;
033:
034:        public class RuleTemplateXmlExporterTest extends XmlExporterTestCase {
035:
036:            @Test
037:            public void testExport() throws Exception {
038:                loadXmlFile("RuleTemplateExportConfig.xml");
039:                assertExport();
040:            }
041:
042:            protected void assertExport() throws Exception {
043:                // export all existing rule templates and their dependencies (rule attributes)
044:                List oldRuleTemplates = KEWServiceLocator
045:                        .getRuleTemplateService().findAll();
046:                ExportDataSet dataSet = new ExportDataSet(ExportFormat.XML);
047:                dataSet.getRuleTemplates().addAll(oldRuleTemplates);
048:                dataSet.getRuleAttributes().addAll(
049:                        KEWServiceLocator.getRuleAttributeService().findAll());
050:                byte[] xmlBytes = KEWServiceLocator.getXmlExporterService()
051:                        .export(ExportFormat.XML, dataSet);
052:                assertTrue("XML should be non empty.", xmlBytes != null
053:                        && xmlBytes.length > 0);
054:
055:                // now clear the tables
056:                //        TestUtilities.clearDatabase();
057:                new OldClearDatabaseLifecycle().start();
058:
059:                // import the exported xml
060:                loadXmlStream(new BufferedInputStream(new ByteArrayInputStream(
061:                        xmlBytes)));
062:
063:                List newRuleTemplates = KEWServiceLocator
064:                        .getRuleTemplateService().findAll();
065:                assertEquals(
066:                        "Should have same number of old and new RuleTemplates.",
067:                        oldRuleTemplates.size(), newRuleTemplates.size());
068:                for (Iterator iterator = oldRuleTemplates.iterator(); iterator
069:                        .hasNext();) {
070:                    RuleTemplate oldRuleTemplate = (RuleTemplate) iterator
071:                            .next();
072:                    boolean foundTemplate = false;
073:                    for (Iterator iterator2 = newRuleTemplates.iterator(); iterator2
074:                            .hasNext();) {
075:                        RuleTemplate newRuleTemplate = (RuleTemplate) iterator2
076:                                .next();
077:                        if (oldRuleTemplate.getName().equals(
078:                                newRuleTemplate.getName())) {
079:                            assertRuleTemplateExport(oldRuleTemplate,
080:                                    newRuleTemplate);
081:                            foundTemplate = true;
082:                        }
083:                    }
084:                    assertTrue(
085:                            "Could not locate the new rule template for name "
086:                                    + oldRuleTemplate.getName(), foundTemplate);
087:                }
088:            }
089:
090:            private void assertRuleTemplateExport(RuleTemplate oldRuleTemplate,
091:                    RuleTemplate newRuleTemplate) {
092:                assertFalse("Ids should be different.", oldRuleTemplate
093:                        .getRuleTemplateId().equals(
094:                                newRuleTemplate.getRuleTemplateId()));
095:                assertEquals(oldRuleTemplate.getDescription(), newRuleTemplate
096:                        .getDescription());
097:                assertEquals(oldRuleTemplate.getName(), newRuleTemplate
098:                        .getName());
099:                if (oldRuleTemplate.getDelegationTemplate() != null) {
100:                    assertRuleTemplateExport(oldRuleTemplate
101:                            .getDelegationTemplate(), newRuleTemplate
102:                            .getDelegationTemplate());
103:                } else {
104:                    assertNull(newRuleTemplate.getDelegationTemplate());
105:                }
106:                assertAttributes(oldRuleTemplate.getRuleTemplateAttributes(),
107:                        newRuleTemplate.getRuleTemplateAttributes());
108:                assertOptions(oldRuleTemplate.getRuleTemplateOptions(),
109:                        newRuleTemplate.getRuleTemplateOptions());
110:            }
111:
112:            private void assertAttributes(List oldAttributes, List newAttributes) {
113:                assertEquals(oldAttributes.size(), newAttributes.size());
114:                for (Iterator iterator = oldAttributes.iterator(); iterator
115:                        .hasNext();) {
116:                    RuleTemplateAttribute oldAttribute = (RuleTemplateAttribute) iterator
117:                            .next();
118:                    boolean foundAttribute = false;
119:                    for (Iterator iterator2 = newAttributes.iterator(); iterator2
120:                            .hasNext();) {
121:                        RuleTemplateAttribute newAttribute = (RuleTemplateAttribute) iterator2
122:                                .next();
123:                        if (oldAttribute.getRuleAttribute().getName().equals(
124:                                newAttribute.getRuleAttribute().getName())) {
125:                            assertEquals(oldAttribute.getRequired(),
126:                                    newAttribute.getRequired());
127:                            foundAttribute = true;
128:                        }
129:                    }
130:                    assertTrue("Could not locate old attribute with name '"
131:                            + oldAttribute.getRuleAttribute().getName()
132:                            + "' in new attributes list.", foundAttribute);
133:                }
134:            }
135:
136:            private void assertOptions(List oldTemplateOptions,
137:                    List newTemplateOptions) {
138:                assertEquals(oldTemplateOptions.size(), newTemplateOptions
139:                        .size());
140:                for (Iterator iterator = oldTemplateOptions.iterator(); iterator
141:                        .hasNext();) {
142:                    RuleTemplateOption oldOption = (RuleTemplateOption) iterator
143:                            .next();
144:                    boolean foundOption = false;
145:                    for (Iterator iterator2 = newTemplateOptions.iterator(); iterator2
146:                            .hasNext();) {
147:                        RuleTemplateOption newOption = (RuleTemplateOption) iterator2
148:                                .next();
149:                        if (oldOption.getKey().equals(newOption.getKey())) {
150:                            assertEquals(oldOption.getValue(), newOption
151:                                    .getValue());
152:                            foundOption = true;
153:                        }
154:                    }
155:                    assertTrue("Could not locate rule template option.",
156:                            foundOption);
157:                }
158:            }
159:
160:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.