Source Code Cross Referenced for TestActiveIndicatorElement.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 java.io.StringReader;
004:
005:        import org.jdom.Document;
006:        import org.jdom.Element;
007:
008:        import edu.iu.uis.eden.exception.InvalidXmlException;
009:        import edu.iu.uis.eden.services.IDocElement;
010:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
011:        import edu.iu.uis.eden.util.XmlHelper;
012:
013:        public class TestActiveIndicatorElement extends
014:                IDocInterfaceTestTemplate {
015:            private ActiveIndicatorElement activeInd;
016:
017:            public TestActiveIndicatorElement(String s) {
018:                super (s);
019:            }
020:
021:            protected void setUp() {
022:                activeInd = new ActiveIndicatorElement();
023:            }
024:
025:            protected void tearDown() {
026:            }
027:
028:            public IDocElement getIDocElement() {
029:                return this .activeInd;
030:            }
031:
032:            /**
033:             * true or false should be valid
034:             */
035:            public void testValidate() {
036:                try {
037:                    assertNull("valid object didn't return null", activeInd
038:                            .validate());
039:
040:                    //set activeInd to true and recheck
041:                    assertNull("valid object didn't return null", activeInd
042:                            .validate());
043:                } catch (Exception ex) {
044:                    fail("threw exception validating");
045:                }
046:            }
047:
048:            /**
049:             * should always be false
050:             */
051:            public void testIsRouteControl() {
052:                assertEquals("ActiveIndicator returned true on isRouteControl",
053:                        false, activeInd.isRouteControl());
054:
055:                //set routeControl to true and recheck;
056:                activeInd.setRouteControl(true);
057:                assertEquals("ActiveIndicator returned true on isRouteControl",
058:                        false, activeInd.isRouteControl());
059:            }
060:
061:            /**
062:             * given a jdom element of the correct type it should load itself to the value
063:             * of the given jdom element
064:             *
065:             * if the jdom element is null and allowBlanks true it should return
066:             *
067:             * if the jdom element is null and allowBlanks is false its should throw
068:             * an InconsistentDocElementStateException
069:             *
070:             * if the element is of the incorrect type it should throw an
071:             * InvalidXmlException
072:             */
073:            public void testLoadFromXMLContent() {
074:                String XMLContentActive = "<active_ind value=\"Y\" />";
075:                String XMLContentInActive = "<active_ind value=\"N\" />";
076:
077:                try {
078:                    activeInd.loadFromXMLContent(this 
079:                            .makeStringElement(XMLContentActive), false);
080:                    assertEquals("didn't properly load props from valid xml",
081:                            true, activeInd.getActiveIndicator());
082:                } catch (Exception e) {
083:                    fail("threw exception loading from good xml content");
084:                }
085:
086:                //do same for inactive
087:                try {
088:                    activeInd.loadFromXMLContent(this 
089:                            .makeStringElement(XMLContentInActive), false);
090:                    assertEquals("didn't properly load props from valid xml",
091:                            false, activeInd.getActiveIndicator());
092:                } catch (Exception e) {
093:                    fail("threw exception loading from good xml content");
094:                }
095:
096:                //test implementation of interface
097:                this .nonClassSpecificLoadFromXMLTests(activeInd);
098:            }
099:
100:            /**
101:             * does ActiveIndicator render the correct xml representation when set to
102:             * true and false
103:             */
104:            public void testGetXMLContent() {
105:                //    String XMLContentActive = "<active_ind value=\"Y\" />";
106:                //    String XMLContentInActive = "<active_ind value=\"N\" />";
107:                assertNotNull("Returned null Element when loaded", activeInd
108:                        .getXMLContent());
109:                activeInd.setActiveIndicator(true);
110:                assertNotNull("Returned null Element when loaded", activeInd
111:                        .getXMLContent());
112:            }
113:
114:            /**
115:             * can this guy populate himself w/ xml he made.
116:             */
117:            public void testCanFeedOnOwnXML() {
118:                activeInd.setActiveIndicator(true);
119:
120:                Element activeIndEl = activeInd.getXMLContent();
121:
122:                try {
123:                    activeInd.loadFromXMLContent(activeIndEl, false);
124:                    assertEquals(
125:                            "Didn't properly set properties from self made XML",
126:                            true, activeInd.getActiveIndicator());
127:                } catch (Exception ex) {
128:                    fail("threw exception loading from self generated xml");
129:                }
130:
131:                //try w/ a false value
132:                activeInd.setActiveIndicator(false);
133:                activeIndEl = activeInd.getXMLContent();
134:
135:                try {
136:                    activeInd.loadFromXMLContent(activeIndEl, false);
137:                    assertEquals(
138:                            "Didn't properly set properties from self made XML",
139:                            false, activeInd.getActiveIndicator());
140:                } catch (Exception ex) {
141:                    fail("threw exception loading from self generated xml");
142:                }
143:            }
144:
145:            /**
146:             * utility method that is not object specific
147:             *
148:             * @param docElement the docElement being tested
149:             */
150:            public void nonClassSpecificLoadFromXMLTests(IDocElement docElement) {
151:                //give null allow blanks
152:                try {
153:                    docElement.loadFromXMLContent(null, true);
154:                } catch (Exception ex) {
155:                    fail("threw exception loading null element set to allow blanks");
156:                }
157:
158:                //give null dont allow blanks
159:                try {
160:                    docElement.loadFromXMLContent(null, false);
161:                    fail("didn't throw InconsistentDocElementStateException "
162:                            + "loaded with null element allowBlanks set to false");
163:                } catch (InconsistentDocElementStateException ex) {
164:                } catch (InvalidXmlException ex) {
165:                    fail("didn't throw InconsistentDocElementStateException "
166:                            + "loaded with null element allowBlanks set to false");
167:                }
168:
169:                //give element of wrong type
170:                try {
171:                    docElement.loadFromXMLContent(new Element("Imbad"), false);
172:                    fail("Didn't throw InvalidXmlException when loaded with "
173:                            + "element of the wrong type");
174:                } catch (InconsistentDocElementStateException ex) {
175:                    fail("Didn't throw InvalidXmlException when loaded with "
176:                            + "element of the wrong type");
177:                } catch (InvalidXmlException ex) {
178:                }
179:            }
180:
181:            public Element makeStringElement(String xmlContent) {
182:                Document doc = null;
183:
184:                try {
185:                    doc = new Document(XmlHelper.buildJDocument(
186:                            new StringReader(xmlContent), false)
187:                            .getRootElement());
188:                } catch (InvalidXmlException ex) {
189:                    fail("Generated invalid xml");
190:                }
191:
192:                return doc.getRootElement();
193:            }
194:        }
195:
196:        /*
197:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
198:         *
199:         * This file is part of the EDEN software package.
200:         * For license information, see the LICENSE file in the top level directory
201:         * of the EDEN source distribution.
202:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.