Source Code Cross Referenced for XmlTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » org » kuali » core » 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 » org.kuali.core.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * Licensed under the Educational Community License, Version 1.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/ecl1.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.core.xml;
018:
019:        import org.kuali.core.document.MaintenanceDocumentBase;
020:        import org.kuali.core.maintenance.KualiMaintainableImpl;
021:        import org.kuali.core.service.XmlObjectSerializerService;
022:        import org.kuali.kfs.KFSConstants;
023:        import org.kuali.kfs.context.KualiTestBase;
024:        import org.kuali.kfs.context.SpringContext;
025:        import org.kuali.module.chart.bo.ProjectCode;
026:        import org.kuali.test.ConfigureContext;
027:
028:        /**
029:         * This class tests the Xml representation of objects.
030:         */
031:        @ConfigureContext
032:        public class XmlTest extends KualiTestBase {
033:
034:            private static final String PROJECT_CODE_MAINTENANCE_DOCUMENT_TYPENAME = "ProjectCodeMaintenanceDocument";
035:
036:            private String PROJECT1_EDIT_XML;
037:            private String PROJECT1_NEW_XML;
038:            private String BAD_PROJECT_XML;
039:
040:            private ProjectCode project1;
041:
042:            @Override
043:            protected void setUp() throws Exception {
044:                super .setUp();
045:
046:                // userSession is set by superclass
047:
048:                project1 = new ProjectCode();
049:                project1.setActive(true);
050:                project1.setCode("BOB");
051:                project1.setChartOfAccountsCode("UA");
052:                project1.setProjectDescription("test");
053:                project1.setName("test");
054:                project1.setOrganizationCode("FMOP");
055:                project1.setProjectManagerUniversalId("111111111");
056:                project1.setVersionNumber(new Long(1));
057:
058:                PROJECT1_EDIT_XML = SpringContext.getBean(
059:                        XmlObjectSerializerService.class).toXml(project1);
060:            }
061:
062:            public void testCreateXmlFromProjectAndBack() throws Exception {
063:                ProjectCode project2 = (ProjectCode) SpringContext.getBean(
064:                        XmlObjectSerializerService.class).fromXml(
065:                        PROJECT1_EDIT_XML);
066:
067:                assertEquals(project2.isActive(), project1.isActive());
068:                assertEquals(project2.getCode(), project1.getCode());
069:                assertEquals(project2.getChartOfAccountsCode(), project1
070:                        .getChartOfAccountsCode());
071:                assertEquals(project2.getProjectDescription(), project1
072:                        .getProjectDescription());
073:                assertEquals(project2.getName(), project1.getName());
074:                assertEquals(project2.getProjectManagerUniversalId(), project1
075:                        .getProjectManagerUniversalId());
076:                assertEquals(project2.getVersionNumber(), project1
077:                        .getVersionNumber());
078:                assertEquals(project2.getOrganizationCode(), project1
079:                        .getOrganizationCode());
080:                assertEquals(project2.getChartOfAccountsCode(), project1
081:                        .getChartOfAccountsCode());
082:            }
083:
084:            public void testMaintDocEditDissemination() throws Exception {
085:                MaintenanceDocumentBase doc = new MaintenanceDocumentBase(
086:                        PROJECT_CODE_MAINTENANCE_DOCUMENT_TYPENAME);
087:                doc.getOldMaintainableObject().setBusinessObject(project1);
088:                doc.getNewMaintainableObject().setBusinessObject(project1);
089:                doc.getNewMaintainableObject().setMaintenanceAction(
090:                        KFSConstants.MAINTENANCE_EDIT_ACTION);
091:
092:                String projectXml = doc.getXmlDocumentContents();
093:                doc.setXmlDocumentContents(projectXml);
094:                doc.populateMaintainablesFromXmlDocumentContents();
095:
096:                assertEquals(((ProjectCode) doc.getNewMaintainableObject()
097:                        .getBusinessObject()).getChartOfAccountsCode(), "UA");
098:                assertEquals(((ProjectCode) doc.getOldMaintainableObject()
099:                        .getBusinessObject()).getChartOfAccountsCode(), "UA");
100:                assertEquals(KFSConstants.MAINTENANCE_EDIT_ACTION, doc
101:                        .getNewMaintainableObject().getMaintenanceAction());
102:            }
103:
104:            public void testMaintDocNewDissemination() throws Exception {
105:                MaintenanceDocumentBase doc = new MaintenanceDocumentBase(
106:                        PROJECT_CODE_MAINTENANCE_DOCUMENT_TYPENAME);
107:                doc.getNewMaintainableObject().setBusinessObject(project1);
108:                doc.getNewMaintainableObject().setMaintenanceAction(
109:                        KFSConstants.MAINTENANCE_NEW_ACTION);
110:
111:                String projectXml = doc.getXmlDocumentContents();
112:                doc.setXmlDocumentContents(projectXml);
113:                doc.populateMaintainablesFromXmlDocumentContents();
114:
115:                assertEquals(((ProjectCode) doc.getNewMaintainableObject()
116:                        .getBusinessObject()).getChartOfAccountsCode(), "UA");
117:                assertEquals(KFSConstants.MAINTENANCE_NEW_ACTION, doc
118:                        .getNewMaintainableObject().getMaintenanceAction());
119:            }
120:
121:            public void testMaintDocEditInsemination() throws Exception {
122:                MaintenanceDocumentBase doc = new MaintenanceDocumentBase();
123:                doc
124:                        .setNewMaintainableObject(new KualiMaintainableImpl(
125:                                project1));
126:                doc
127:                        .setOldMaintainableObject(new KualiMaintainableImpl(
128:                                project1));
129:                doc.populateXmlDocumentContentsFromMaintainables();
130:                assertNotNull(doc.getXmlDocumentContents());
131:                assertTrue(doc
132:                        .getXmlDocumentContents()
133:                        .startsWith(
134:                                "<maintainableDocumentContents maintainableImplClass=\"org.kuali.core.maintenance.KualiMaintainableImpl\">"));
135:                assertTrue(doc.getXmlDocumentContents().indexOf(
136:                        "<oldMaintainableObject>") > 0);
137:                assertTrue(doc.getXmlDocumentContents().indexOf(
138:                        "<newMaintainableObject>") > 0);
139:            }
140:
141:            public void testMaintDocNewInsemination() throws Exception {
142:                MaintenanceDocumentBase doc = new MaintenanceDocumentBase();
143:                doc
144:                        .setNewMaintainableObject(new KualiMaintainableImpl(
145:                                project1));
146:                doc.populateXmlDocumentContentsFromMaintainables();
147:                assertNotNull(doc.getXmlDocumentContents());
148:                assertTrue(doc
149:                        .getXmlDocumentContents()
150:                        .startsWith(
151:                                "<maintainableDocumentContents maintainableImplClass=\"org.kuali.core.maintenance.KualiMaintainableImpl\">"));
152:                assertFalse(doc.getXmlDocumentContents().indexOf(
153:                        "<oldMaintainableObject>") > 0);
154:                assertTrue(doc.getXmlDocumentContents().indexOf(
155:                        "<newMaintainableObject>") > 0);
156:            }
157:
158:            public void testMaintDocEditXmlRoundTrip() {
159:
160:                // create a new maint doc, set the old & new, set the action to EDIT
161:                MaintenanceDocumentBase doc1 = new MaintenanceDocumentBase(
162:                        PROJECT_CODE_MAINTENANCE_DOCUMENT_TYPENAME);
163:                doc1.getOldMaintainableObject().setBusinessObject(project1);
164:                doc1.getNewMaintainableObject().setBusinessObject(project1);
165:                doc1.getNewMaintainableObject().setMaintenanceAction(
166:                        KFSConstants.MAINTENANCE_EDIT_ACTION);
167:
168:                // have the object generate XML, and get that XML
169:                doc1.populateXmlDocumentContentsFromMaintainables();
170:                String projectXml = doc1.getXmlDocumentContents();
171:
172:                // create a new object
173:                MaintenanceDocumentBase doc2 = new MaintenanceDocumentBase(
174:                        PROJECT_CODE_MAINTENANCE_DOCUMENT_TYPENAME);
175:
176:                // insert the XML, and try to re-constitute the maintainables from the XML
177:                doc2.setXmlDocumentContents(projectXml);
178:                doc2.populateMaintainablesFromXmlDocumentContents();
179:
180:                assertEquals(((ProjectCode) doc1.getNewMaintainableObject()
181:                        .getBusinessObject()).getChartOfAccountsCode(),
182:                        ((ProjectCode) doc2.getNewMaintainableObject()
183:                                .getBusinessObject()).getChartOfAccountsCode());
184:                assertEquals(((ProjectCode) doc1.getOldMaintainableObject()
185:                        .getBusinessObject()).getChartOfAccountsCode(),
186:                        ((ProjectCode) doc2.getOldMaintainableObject()
187:                                .getBusinessObject()).getChartOfAccountsCode());
188:                assertEquals(doc1.getNewMaintainableObject()
189:                        .getMaintenanceAction(), doc2
190:                        .getNewMaintainableObject().getMaintenanceAction());
191:            }
192:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.