Source Code Cross Referenced for TestChartElement.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:
007:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
008:        import edu.iu.uis.eden.exception.InvalidXmlException;
009:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
010:
011:        public class TestChartElement extends TestCase {
012:            private ChartElement chartElement;
013:
014:            public TestChartElement(String s) {
015:                super (s);
016:            }
017:
018:            protected void setUp() {
019:                chartElement = new ChartElement();
020:                chartElement.setChart("BL");
021:                chartElement.setRouteControl(true);
022:            }
023:
024:            protected void tearDown() {
025:            }
026:
027:            /**
028:             * given a proper value does ChartElement make correct XML
029:             */
030:            public void testGetXMLContent() {
031:                //for now just test not null we can do better later
032:                chartElement.setChart("chart");
033:                assertNotNull("Returned null when loaded", chartElement
034:                        .getXMLContent());
035:            }
036:
037:            /**
038:             * given a jdom element of the correct type it should load itself to the value
039:             * of the given jdom element
040:             *
041:             * if the jdom element is null and allowBlanks true it should return
042:             *
043:             * if the jdom element is null and allowBlanks is false its should throw
044:             * an InconsistentDocElementStateException
045:             *
046:             * if the element is of the incorrect type it should throw an
047:             * InvalidXmlException
048:             */
049:            public void testLoadFromXMLContent() {
050:                //make a new chartElement with clear values
051:                ChartElement chart = new ChartElement();
052:
053:                //make a jdom docs with the content
054:                Element chartRootEl = new Element(
055:                        "financial_chart_of_accounts_eok");
056:                chartRootEl.setAttribute("route-control", "yes");
057:
058:                Element chartEl = new Element("fin_coa_cd");
059:                chartEl.setAttribute("value", "BL");
060:                chartRootEl.addContent(chartEl);
061:
062:                try {
063:                    chart.loadFromXMLContent(chartRootEl, false);
064:                    assertEquals("Didn't properly load from a valid element",
065:                            "BL", chart.getChart());
066:                } catch (InvalidXmlException ex) {
067:                    fail("loadFromXMLContent threw an InvalidXmlException when using a "
068:                            + "good Element");
069:                } catch (InconsistentDocElementStateException ex) {
070:                    fail("loadFromXMLContent threw an InconsistentDocElementStateException "
071:                            + "when using a good Element");
072:                }
073:
074:                //give a chart a bad element
075:                chart = new ChartElement();
076:                chartEl = new Element("imbad");
077:                chartEl.setAttribute("value", "BL");
078:
079:                try {
080:                    chart.loadFromXMLContent(chartEl, false);
081:                    fail("Didn't throw InvalidXMLContentExcecption when using a bad "
082:                            + "element");
083:                } catch (InvalidXmlException ex) {
084:                } catch (InconsistentDocElementStateException ex) {
085:                    fail("Didn't throw InvalidXMLContentExcecption when using a bad "
086:                            + "element, threw InconsistentDocElementStateException instead");
087:                }
088:
089:                //same thing but allow blanks
090:                chart = new ChartElement();
091:
092:                try {
093:                    chart.loadFromXMLContent(chartEl, true);
094:                    fail("Didn't throw InvalidXMLContentExcecption when using a bad "
095:                            + "element");
096:                } catch (InvalidXmlException ex) {
097:                } catch (InconsistentDocElementStateException ex) {
098:                    fail("Didn't throw InvalidXMLContentExcecption when using a bad "
099:                            + "element, threw InconsistentDocElementStateException instead");
100:                }
101:
102:                //pass null and allow blanks nothing should happen
103:                chart = new ChartElement();
104:
105:                try {
106:                    chart.loadFromXMLContent(null, true);
107:                } catch (InvalidXmlException ex) {
108:                    fail("Threw InvalidXmlException when passed a "
109:                            + "null value and allowBlanks set to true");
110:                } catch (InconsistentDocElementStateException ex) {
111:                    fail("Threw InconsistentDocElementStateException when passed a "
112:                            + "null value and allowBlanks set to true");
113:                }
114:
115:                //pass null and dont allow blanks
116:                chart = new ChartElement();
117:
118:                try {
119:                    chart.loadFromXMLContent(null, false);
120:                    fail("Didn't Throw InconsistentDocElementStateException when passed a "
121:                            + "null value and allowBlanks set to false");
122:                } catch (InvalidXmlException ex) {
123:                    fail("Didn't Throw InconsistentDocElementStateException when passed a "
124:                            + "null value and allowBlanks set to false");
125:                } catch (InconsistentDocElementStateException ex) {
126:                }
127:            }
128:
129:            /**
130:             * test that validate returns null when chart is set and that a
131:             * DocElementError is returned when nothing is set
132:             */
133:            public void testValidate() {
134:                try {
135:                    //validate the default chart should be true
136:                    assertNull(
137:                            "Valid ChartElement didn't return null from validate",
138:                            chartElement.validate());
139:
140:                    //make a new BAD ChartElement
141:                    ChartElement chart = new ChartElement();
142:                    WorkflowServiceErrorImpl error = (WorkflowServiceErrorImpl) chart
143:                            .validate();
144:
145:                    assertNotNull(
146:                            "Invalid CharElement returned null on validate",
147:                            error);
148:                } catch (Exception ex) {
149:                    fail("threw exception validating");
150:                }
151:            }
152:
153:            /**
154:             * can this guy populate himself w/ xml he made.
155:             */
156:            public void testCanFeedOnOwnXML() {
157:                ChartElement chart = new ChartElement();
158:                chart.setChart("chart");
159:
160:                Element chartEl = chart.getXMLContent();
161:
162:                ChartElement aChartEl = new ChartElement();
163:
164:                try {
165:                    aChartEl.loadFromXMLContent(chartEl, false);
166:                } catch (InvalidXmlException ex) {
167:                    fail("XML generated invalid could not be loaded "
168:                            + "by itself");
169:                } catch (InconsistentDocElementStateException ex) {
170:                    fail("XML generated invalid could not be loaded "
171:                            + "by itself");
172:                }
173:
174:                assertEquals("Could not find value from XML it generated",
175:                        chart.getChart(), aChartEl.getChart());
176:            }
177:
178:            /**
179:             * this should be a route control according to now business rules
180:             */
181:            public void testIsRouteControl() {
182:                assertEquals("This should be a routeControl", true,
183:                        this .chartElement.isRouteControl());
184:            }
185:        }
186:
187:        /*
188:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
189:         *
190:         * This file is part of the EDEN software package.
191:         * For license information, see the LICENSE file in the top level directory
192:         * of the EDEN source distribution.
193:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.