Source Code Cross Referenced for ValidityExceptionTest.java in  » XML » xom » nu » xom » tests » 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 » XML » xom » nu.xom.tests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2003, 2004 Elliotte Rusty Harold
002:           
003:           This library is free software; you can redistribute it and/or modify
004:           it under the terms of version 2.1 of the GNU Lesser General Public 
005:           License as published by the Free Software Foundation.
006:           
007:           This library is distributed in the hope that it will be useful,
008:           but WITHOUT ANY WARRANTY; without even the implied warranty of
009:           MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
010:           GNU Lesser General Public License for more details.
011:           
012:           You should have received a copy of the GNU Lesser General Public
013:           License along with this library; if not, write to the 
014:           Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
015:           Boston, MA 02111-1307  USA
016:           
017:           You can contact Elliotte Rusty Harold by sending e-mail to
018:           elharo@metalab.unc.edu. Please include the word "XOM" in the
019:           subject line. The XOM home page is located at http://www.xom.nu/
020:         */
021:
022:        package nu.xom.tests;
023:
024:        import nu.xom.ParsingException;
025:        import nu.xom.ValidityException;
026:
027:        /**
028:         * <p>
029:         *   Unit tests for the <code>ValidityException</code> class.
030:         * </p>
031:         * 
032:         * @author Elliotte Rusty Harold
033:         * @version 1.0
034:         *
035:         */
036:        public class ValidityExceptionTest extends XOMTestCase {
037:
038:            private ValidityException ex = new ValidityException("message");
039:            private Exception cause = new Exception();
040:            private String message = "testing 1-2-3";
041:
042:            public ValidityExceptionTest(String name) {
043:                super (name);
044:            }
045:
046:            public void testConstructor() {
047:                ParsingException ex = new ValidityException(message, cause);
048:                assertEquals(message, ex.getMessage());
049:                assertEquals(cause, ex.getCause());
050:            }
051:
052:            public void testFourArgumentConstructor() {
053:
054:                ParsingException ex = new ValidityException(message, 10000,
055:                        40000, cause);
056:                assertEquals(message, ex.getMessage());
057:                assertEquals(cause, ex.getCause());
058:                assertEquals(10000, ex.getLineNumber());
059:                assertEquals(40000, ex.getColumnNumber());
060:
061:            }
062:
063:            public void testAnotherFourArgumentConstructor() {
064:
065:                ParsingException ex = new ValidityException(message,
066:                        "http://www.example.com/", 10000, 40000);
067:                assertEquals(message, ex.getMessage());
068:                assertNull(ex.getCause());
069:                assertEquals(10000, ex.getLineNumber());
070:                assertEquals(40000, ex.getColumnNumber());
071:                assertEquals("http://www.example.com/", ex.getURI());
072:
073:            }
074:
075:            public void testLineAndColumnNumbers() {
076:
077:                ValidityException ex = new ValidityException(message, 10, 20);
078:                assertEquals(message, ex.getMessage());
079:                assertNull(ex.getCause());
080:                assertEquals(10, ex.getLineNumber());
081:                assertEquals(20, ex.getColumnNumber());
082:
083:            }
084:
085:            public void testInitCause() {
086:
087:                assertNull(ex.getCause());
088:                ex.initCause(cause);
089:                assertEquals(cause, ex.getCause());
090:
091:                try {
092:                    ex.initCause(null);
093:                    fail("Reinitialized cause over null");
094:                } catch (IllegalStateException success) {
095:                    // success   
096:                }
097:
098:                try {
099:                    ex.initCause(new Exception());
100:                    fail("Reinitialized cause over null");
101:                } catch (IllegalStateException success) {
102:                    // success   
103:                }
104:
105:            }
106:
107:            public void testNullInitCause() {
108:
109:                ValidityException ex = new ValidityException(null, null);
110:                assertNull(ex.getCause());
111:                assertNull(ex.getMessage());
112:                assertEquals(-1, ex.getLineNumber());
113:                assertEquals(-1, ex.getColumnNumber());
114:
115:                try {
116:                    ex.initCause(new Exception());
117:                    fail("Reinitialized cause over null");
118:                } catch (IllegalStateException result) {
119:                    // success   
120:                }
121:
122:                try {
123:                    ex.initCause(null);
124:                    fail("Reinitialized cause over null");
125:                } catch (IllegalStateException result) {
126:                    // success   
127:                }
128:
129:            }
130:
131:            public void testSelfCause() {
132:
133:                try {
134:                    ex.initCause(ex);
135:                    fail("Allowed self-causation");
136:                } catch (IllegalArgumentException result) {
137:                    // success   
138:                }
139:
140:            }
141:
142:            public void testGetMessage() {
143:                Exception ex = new ValidityException("testing");
144:                assertEquals("testing", ex.getMessage());
145:            }
146:
147:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.