Source Code Cross Referenced for TestActionRequestedElement.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 junit.framework.TestCase;
006:
007:        import org.jdom.Document;
008:        import org.jdom.Element;
009:
010:        import edu.iu.uis.eden.EdenConstants;
011:        import edu.iu.uis.eden.WorkflowServiceErrorImpl;
012:        import edu.iu.uis.eden.exception.InvalidXmlException;
013:        import edu.iu.uis.eden.services.IDocElement;
014:        import edu.iu.uis.eden.services.InconsistentDocElementStateException;
015:        import edu.iu.uis.eden.services.ServiceErrorConstants;
016:        import edu.iu.uis.eden.util.XmlHelper;
017:
018:        public class TestActionRequestedElement extends TestCase {
019:            private ActionRequestedElement actionRequested;
020:
021:            public TestActionRequestedElement(String s) {
022:                super (s);
023:            }
024:
025:            protected void setUp() {
026:                actionRequested = new ActionRequestedElement();
027:            }
028:
029:            protected void tearDown() {
030:            }
031:
032:            /**
033:             * is this returning true when the object is empty
034:             */
035:            public void testIsEmpty() {
036:                assertTrue("new object not returning true", actionRequested
037:                        .isEmpty());
038:
039:                //set something and try again
040:                actionRequested.setActionRequested("hello");
041:                assertEquals("set ActionRequested returning true on isEmpty()",
042:                        false, actionRequested.isEmpty());
043:            }
044:
045:            /**
046:             * loaded with an invalid actionrequested (on that's not in EdenConstants
047:             * ActionRequested ActionRequestedElement should give a corrects error msg
048:             */
049:            public void testInvalidActionRequested() {
050:                /* try catch added after api change surrounding all logic might not be
051:                   best approach */
052:                try {
053:                    this .actionRequested.setActionRequested("Z");
054:
055:                    WorkflowServiceErrorImpl error = this .actionRequested
056:                            .validate();
057:                    assertEquals(
058:                            "Didn't give proper error for invalid actionrequested",
059:                            ServiceErrorConstants.ACTION_REQUESTED_INVALID,
060:                            error.getKey());
061:
062:                    /* load it with a valid and retest should be null */
063:                    this .actionRequested
064:                            .setActionRequested(EdenConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ);
065:                    error = this .actionRequested.validate();
066:                    assertNull(
067:                            "valid ActionRequested didn't return null on validation",
068:                            this .actionRequested.validate());
069:                } catch (Exception ex) {
070:                    fail("threw exception validating");
071:                }
072:            }
073:
074:            /**
075:             * this is not a route control
076:             */
077:            public void testIsRouteControl() {
078:                assertEquals(
079:                        "ActionRequested returning true on isRouteControl",
080:                        false, actionRequested.isRouteControl());
081:                actionRequested.setRouteControl(true);
082:                assertEquals(
083:                        "ActionRequested allowing true to set RouteControl",
084:                        false, actionRequested.isRouteControl());
085:            }
086:
087:            /**
088:             * given a jdom element of the correct type it should load itself to the value
089:             * of the given jdom element
090:             *
091:             * if the jdom element is null and allowBlanks true it should return
092:             *
093:             * if the jdom element is null and allowBlanks is false its should throw
094:             * an InconsistentDocElementStateException
095:             *
096:             * if the element is of the incorrect type it should throw an
097:             * InvalidXmlException
098:             */
099:            public void testLoadFromXMLContent() {
100:                //test loading a normal date
101:                String ackRequested = "A";
102:                Element ackRequestedEl = new Element(actionRequested
103:                        .getElementName());
104:                ackRequestedEl.setAttribute("value", ackRequested);
105:
106:                try {
107:                    actionRequested.loadFromXMLContent(ackRequestedEl, false);
108:                    assertEquals(
109:                            "didn't properly load props from valid element",
110:                            ackRequested, actionRequested.getActionRequested());
111:                } catch (Exception ex) {
112:                    fail("threw exception loading from valid element");
113:                }
114:
115:                //test implementation of interface
116:                this .nonClassSpecificLoadFromXMLTests(actionRequested);
117:            }
118:
119:            /**
120:             * is the correct constant coming back for the correct error
121:             */
122:            public void testValidate() {
123:                //check an empty one
124:                try {
125:                    WorkflowServiceErrorImpl error = actionRequested.validate();
126:                    assertEquals(
127:                            "validate returned the wrong constant on the DocElementError "
128:                                    + "object",
129:                            ServiceErrorConstants.ACTION_REQUESTED_BLANK, error
130:                                    .getKey());
131:
132:                    //this should pass
133:                    actionRequested.setActionRequested("A");
134:                    assertNull(
135:                            "validate on good ActionRequested didn't return null",
136:                            actionRequested.validate());
137:                } catch (Exception ex) {
138:                    fail("threw exception validating");
139:                }
140:            }
141:
142:            /**
143:             * does it give back good xml
144:             */
145:            public void testGetXMLContent() {
146:                Element xml = new Element(actionRequested.getElementName());
147:                xml.setAttribute("value", "A");
148:
149:                actionRequested.setActionRequested("a");
150:                assertEquals("Didn't make XMLContent correctly", xml
151:                        .getAttributeValue("value"), actionRequested
152:                        .getXMLContent().getAttributeValue("value"));
153:            }
154:
155:            /**
156:             * he should return caps regardless of what he's set w/
157:             */
158:            public void testGetActionRequested() {
159:                actionRequested.setActionRequested("a");
160:                assertEquals(
161:                        "GetActionRequested not properly capitalizing the "
162:                                + "actionRequested set with", "A",
163:                        actionRequested.getActionRequested());
164:            }
165:
166:            /**
167:             * can this guy populate himself w/ xml he made.
168:             */
169:            public void testCanFeedOnOwnXML() {
170:                String action = "A";
171:                actionRequested.setActionRequested(action);
172:
173:                Element ackReqEl = actionRequested.getXMLContent();
174:
175:                try {
176:                    actionRequested.loadFromXMLContent(ackReqEl, false);
177:                    assertEquals(
178:                            "Didn't properly set properties from self made XML",
179:                            action, actionRequested.getActionRequested());
180:                } catch (Exception ex) {
181:                    fail("threw exception loading from self generated xml");
182:                }
183:            }
184:
185:            /**
186:             * utility method that is not object specific
187:             *
188:             * @param docElement the docElement being tested
189:             */
190:            public void nonClassSpecificLoadFromXMLTests(IDocElement docElement) {
191:                //give null allow blanks
192:                try {
193:                    docElement.loadFromXMLContent(null, true);
194:                } catch (Exception ex) {
195:                    fail("threw exception loading null element set to allow blanks");
196:                }
197:
198:                //give null dont allow blanks
199:                try {
200:                    docElement.loadFromXMLContent(null, false);
201:                    fail("didn't throw InconsistentDocElementStateException "
202:                            + "loaded with null element allowBlanks set to false");
203:                } catch (InconsistentDocElementStateException ex) {
204:                } catch (InvalidXmlException ex) {
205:                    fail("didn't throw InconsistentDocElementStateException "
206:                            + "loaded with null element allowBlanks set to false");
207:                }
208:
209:                //give element of wrong type
210:                try {
211:                    docElement.loadFromXMLContent(new Element("Imbad"), false);
212:                    fail("Didn't throw InvalidXmlException when loaded with "
213:                            + "element of the wrong type");
214:                } catch (InconsistentDocElementStateException ex) {
215:                    fail("Didn't throw InvalidXmlException when loaded with "
216:                            + "element of the wrong type");
217:                } catch (InvalidXmlException ex) {
218:                }
219:            }
220:
221:            public Element makeStringElement(String xmlContent) {
222:                Document doc = null;
223:
224:                try {
225:                    doc = new Document(XmlHelper.buildJDocument(
226:                            new StringReader(xmlContent), false)
227:                            .getRootElement());
228:                } catch (InvalidXmlException ex) {
229:                    fail("Generated invalid xml");
230:                }
231:
232:                return doc.getRootElement();
233:            }
234:        }
235:
236:        /*
237:         * Copyright 2003 The Trustees of Indiana University.  All rights reserved.
238:         *
239:         * This file is part of the EDEN software package.
240:         * For license information, see the LICENSE file in the top level directory
241:         * of the EDEN source distribution.
242:         */
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.