Source Code Cross Referenced for TestNetworkIdElement.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.exception.InvalidXmlException;
008:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
009:
010:        public class TestNetworkIdElement extends TestCase {
011:            private NetworkIdElement networkId;
012:
013:            public TestNetworkIdElement(String s) {
014:                super (s);
015:            }
016:
017:            protected void setUp() {
018:                networkId = new NetworkIdElement();
019:                networkId.setNetworkId("rkirkend");
020:            }
021:
022:            protected void tearDown() {
023:            }
024:
025:            /**
026:             * if networkId is set null should be returned.
027:             *
028:             * if networkId is null or empty DocElementError should be returned.
029:             */
030:            public void testValidate() {
031:                try {
032:                    //start with the default a known good guy
033:                    assertNull("Correctly Loaded failed validation", networkId
034:                            .validate());
035:
036:                    //make a new trouble maker
037:                    networkId = new NetworkIdElement();
038:
039:                    networkId.validate();
040:
041:                    assertNotNull(
042:                            "Validate on incorrect NetworkIdElement returned null",
043:                            networkId.validate());
044:
045:                    //set networkId blank and verify an error
046:                    networkId.setNetworkId("");
047:                    assertNotNull(
048:                            "Validate on incorrect NetworkIdElement returned null",
049:                            networkId.validate());
050:                } catch (Exception ex) {
051:                    fail("threw exception validating");
052:                }
053:            }
054:
055:            /**
056:             * load the guy from valid element and check that props are set
057:             *
058:             * load the guy w/ null element but allowBlanks and make sure
059:             * exception isn't thrown
060:             *
061:             * load the guy w/ null don't allowBlanks and make sure
062:             * exception is thrown
063:             *
064:             * load with element of wrong type and check that invalidXMLException is thrown
065:             */
066:            public void testLoadFromXMLContent() {
067:                NetworkIdElement networkId = new NetworkIdElement();
068:                String daId = "rkirkend";
069:
070:                Element networkEl = new Element(networkId.getElementName());
071:                networkEl.setAttribute("value", daId);
072:
073:                try {
074:                    networkId.loadFromXMLContent(networkEl, false);
075:                    assertEquals("Did not properly load props from element",
076:                            daId, networkId.getNetworkId());
077:                } catch (Exception ex) {
078:                    fail("threw exception loading from valid element");
079:                }
080:
081:                // give null element allow blanks
082:                try {
083:                    networkId.loadFromXMLContent(null, true);
084:                } catch (Exception ex) {
085:                    fail("threw exception loading from null element with allowBlanks "
086:                            + "set true");
087:                }
088:
089:                //give null element don't allow blanks
090:                try {
091:                    networkId.loadFromXMLContent(null, false);
092:                    fail("didn't throw InconsistentDocElementStateException loaded "
093:                            + "with null element and allowBlanks set false");
094:                } catch (InconsistentDocElementStateException ex) {
095:                } catch (InvalidXmlException ex) {
096:                    fail("didn't throw InconsistentDocElementStateException loaded "
097:                            + "with null element and allowBlanks set false");
098:                }
099:
100:                //give wrong type of element
101:                try {
102:                    networkId.loadFromXMLContent(new Element("imbad"), true);
103:                    fail("didn't throw InvalidXmlException loaded with wrong type "
104:                            + "of element");
105:                } catch (InvalidXmlException ex) {
106:                } catch (InconsistentDocElementStateException ex) {
107:                    fail("didn't throw InvalidXmlException loaded with wrong type "
108:                            + "of element");
109:                }
110:            }
111:
112:            /**
113:             * test that this sucker gives the correct XML.  This is dependent upon the
114:             * object made in setUp();
115:             */
116:            public void testGetXMLContent() {
117:                assertNotNull("Returned null when loaded", networkId
118:                        .getXMLContent());
119:            }
120:
121:            /**
122:             * should not be a routeControl according to the current rules
123:             */
124:            public void testIsRouteControl() {
125:                assertEquals(
126:                        "This should not be a routeControl according to the "
127:                                + "current business rules", false, networkId
128:                                .isRouteControl());
129:            }
130:
131:            /**
132:             * can the object load from the same xml in generates and arrive at the same
133:             * property value
134:             */
135:            public void testFeedFromOwnXML() {
136:                Element xmlContent = networkId.getXMLContent();
137:
138:                NetworkIdElement aNetworkIdEl = new NetworkIdElement();
139:
140:                try {
141:                    aNetworkIdEl.loadFromXMLContent(xmlContent, false);
142:                } catch (InvalidXmlException ex) {
143:                    fail("XML generated invalid could not be loaded "
144:                            + "by itself");
145:                } catch (Exception ex) {
146:                    fail("XML generated invalid could not be loaded "
147:                            + "by itself");
148:                }
149:
150:                assertEquals("Could not find value from XML it generated",
151:                        "rkirkend", aNetworkIdEl.getNetworkId());
152:            }
153:        }
154:
155:        /*
156:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
157:         *
158:         * This file is part of the EDEN software package.
159:         * For license information, see the LICENSE file in the top level directory
160:         * of the EDEN source distribution.
161:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.