Source Code Cross Referenced for TestUniversityOrganizationElement.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » services » docelements » 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.services.docelements 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package edu.iu.uis.eden.services.docelements;
002:
003:        import junit.framework.TestCase;
004:
005:        import org.jdom.Element;
006:        import org.jdom.output.XMLOutputter;
007:
008:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
009:        import edu.iu.uis.eden.exception.InvalidXmlException;
010:        import edu.iu.uis.eden.services.IDocElement;
011:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
012:        import edu.iu.uis.eden.services.ServiceErrorConstants;
013:
014:        public class TestUniversityOrganizationElement extends TestCase {
015:            UniversityOrganizationElement univElement;
016:
017:            public TestUniversityOrganizationElement(String s) {
018:                super (s);
019:            }
020:
021:            protected void setUp() {
022:                univElement = new UniversityOrganizationElement();
023:            }
024:
025:            protected void tearDown() {
026:            }
027:
028:            /**
029:             * this is a route control
030:             */
031:            public void testIsRouteControl() {
032:                assertTrue("UniversityOrganizationElement is a route control",
033:                        univElement.isRouteControl());
034:
035:                //attempt to set it to false
036:                univElement.setRouteControl(false);
037:                assertTrue("UniversityOrganizationElement is a route control",
038:                        univElement.isRouteControl());
039:            }
040:
041:            /**
042:             * test that this guy is returning an Element that contains good xml.
043:             */
044:            public void testGetXMLContent() {
045:                String goodXML = "<university_organization_eok route-control=\"yes\">"
046:                        + "<financial_chart_of_accounts_eok route-control=\"yes\">"
047:                        + "<fin_coa_cd value=\"BL\" />"
048:                        + "</financial_chart_of_accounts_eok>"
049:                        + "<org_cd value=\"ACQU\" />"
050:                        + "</university_organization_eok>";
051:
052:                univElement.setChart("BL");
053:                univElement.setOrgCode("ACQU");
054:                assertEquals("Didn't make element containing correct xml",
055:                        goodXML, this .makeElementXMLString(univElement
056:                                .getXMLContent()));
057:            }
058:
059:            /**
060:             * if chart and org have been set we're valid if one hasn't we're not
061:             */
062:            public void testValidate() {
063:                try {
064:                    //this should error
065:                    WorkflowServiceErrorImpl error = univElement.validate();
066:                    assertNotNull("invalid object returned null on validate",
067:                            error);
068:
069:                    univElement.setChart("BL");
070:                    error = univElement.validate();
071:                    assertNotNull("invalid object returned null on validate",
072:                            error);
073:
074:                    univElement.setOrgCode("ACQU");
075:                    assertNull("valid object didn't return null on validation",
076:                            univElement.validate());
077:
078:                    /* test a bad combo */
079:                    univElement.setChart("imbad");
080:
081:                    WorkflowServiceErrorImpl err = univElement.validate();
082:                    assertNotNull(
083:                            "invalid UniversityOrganizationElement didn't return "
084:                                    + "an error object", err);
085:
086:                    /* test that the correct constant is coming back */
087:                    assertEquals(
088:                            "invalid UniversityOrganizationElement returned "
089:                                    + "DocElementError of the wrong type",
090:                            ServiceErrorConstants.UNIVERSITY_ORGANIZATION_INVALID,
091:                            err.getKey());
092:                } catch (Exception ex) {
093:                    ex.printStackTrace();
094:                    fail("threw exception validating");
095:                }
096:            }
097:
098:            /**
099:             * pass good xml this dudes way and see if the props are loaded correctly
100:             * and the proper exceptions thrown
101:             */
102:            public void testLoadFromXMLContent() {
103:                //make an element representative of just a chart in there
104:                Element element = new Element(univElement.getElementName());
105:                ChartElement chartElement = new ChartElement();
106:                chartElement.setChart("BL");
107:                element.addContent(chartElement.getXMLContent());
108:
109:                //missing org add but allowblanks
110:                try {
111:                    univElement.loadFromXMLContent(element, true);
112:                    assertEquals(
113:                            "didn't properly load props from a good element",
114:                            "BL", univElement.getChart());
115:                } catch (Exception ex) {
116:                    fail("threw exception loading from good element but missing org");
117:                }
118:
119:                //try the same but missing chart
120:                univElement = new UniversityOrganizationElement();
121:                element = new Element(univElement.getElementName());
122:
123:                OrgCodeElement orgCode = new OrgCodeElement();
124:                orgCode.setOrgCode("BL");
125:                element.addContent(orgCode.getXMLContent());
126:
127:                try {
128:                    univElement.loadFromXMLContent(element, true);
129:                    assertEquals(
130:                            "didn't properly load props from a good element",
131:                            "BL", univElement.getOrgCode());
132:                } catch (Exception ex) {
133:                    fail("threw exception loading from good element but missing chart");
134:                }
135:
136:                this .nonClassSpecificLoadFromXMLTests(univElement);
137:            }
138:
139:            /**
140:             * can this guy populate himself w/ xml he made.
141:             */
142:            public void testCanFeedOnOwnXML() {
143:                String chart = "BL";
144:                String org = "BL";
145:
146:                univElement.setChart("BL");
147:                univElement.setOrgCode("BL");
148:
149:                Element element = univElement.getXMLContent();
150:                UniversityOrganizationElement aUnivElement = new UniversityOrganizationElement();
151:
152:                try {
153:                    aUnivElement.loadFromXMLContent(element, false);
154:                } catch (Exception ex) {
155:                    fail("threw exception loading from self generated xml");
156:                }
157:
158:                assertEquals("Didn't properly load chart from element", chart,
159:                        aUnivElement.getChart());
160:                assertEquals("didn't properly load org from element", org,
161:                        aUnivElement.getChart());
162:            }
163:
164:            /**
165:             * utility method that is not object specific
166:             *
167:             * @param docElement the docElement being tested
168:             */
169:            public void nonClassSpecificLoadFromXMLTests(IDocElement docElement) {
170:                //give null allow blanks
171:                try {
172:                    docElement.loadFromXMLContent(null, true);
173:                } catch (Exception ex) {
174:                    fail("threw exception loading null element set to allow blanks");
175:                }
176:
177:                //give null dont allow blanks
178:                try {
179:                    docElement.loadFromXMLContent(null, false);
180:                    fail("didn't throw InconsistentDocElementStateException "
181:                            + "loaded with null element allowBlanks set to false");
182:                } catch (InconsistentDocElementStateException ex) {
183:                } catch (InvalidXmlException ex) {
184:                    fail("didn't throw InconsistentDocElementStateException "
185:                            + "loaded with null element allowBlanks set to false");
186:                }
187:
188:                //give element of wrong type
189:                try {
190:                    docElement.loadFromXMLContent(new Element("Imbad"), false);
191:                    fail("Didn't throw InvalidXmlException when loaded with "
192:                            + "element of the wrong type");
193:                } catch (InconsistentDocElementStateException ex) {
194:                    fail("Didn't throw InvalidXmlException when loaded with "
195:                            + "element of the wrong type");
196:                } catch (InvalidXmlException ex) {
197:                }
198:            }
199:
200:            public String makeElementXMLString(Element element) {
201:                XMLOutputter outputter = new XMLOutputter();
202:
203:                return outputter.outputString(element);
204:            }
205:        }
206:
207:        /*
208:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
209:         *
210:         * This file is part of the EDEN software package.
211:         * For license information, see the LICENSE file in the top level directory
212:         * of the EDEN source distribution.
213:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.