Source Code Cross Referenced for AbstractNodeTester.java in  » Testing » XMLUnit » org » custommonkey » xmlunit » 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 » Testing » XMLUnit » org.custommonkey.xmlunit 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         ******************************************************************
003:        Copyright (c) 2001, Jeff Martin, Tim Bacon
004:        All rights reserved.
005:
006:        Redistribution and use in source and binary forms, with or without
007:        modification, are permitted provided that the following conditions
008:        are met:
009:
010:         * Redistributions of source code must retain the above copyright
011:              notice, this list of conditions and the following disclaimer.
012:         * Redistributions in binary form must reproduce the above
013:              copyright notice, this list of conditions and the following
014:              disclaimer in the documentation and/or other materials provided
015:              with the distribution.
016:         * Neither the name of the xmlunit.sourceforge.net nor the names
017:              of its contributors may be used to endorse or promote products
018:              derived from this software without specific prior written
019:              permission.
020:
021:        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
022:        "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
023:        LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
024:        FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
025:        COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
026:        INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
027:        BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
028:        LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
029:        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
030:        LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
031:        ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
032:        POSSIBILITY OF SUCH DAMAGE.
033:
034:         ******************************************************************
035:         */
036:
037:        package org.custommonkey.xmlunit;
038:
039:        import org.w3c.dom.Attr;
040:        import org.w3c.dom.CDATASection;
041:        import org.w3c.dom.Comment;
042:        import org.w3c.dom.DocumentType;
043:        import org.w3c.dom.Element;
044:        import org.w3c.dom.Entity;
045:        import org.w3c.dom.EntityReference;
046:        import org.w3c.dom.Node;
047:        import org.w3c.dom.Notation;
048:        import org.w3c.dom.ProcessingInstruction;
049:        import org.w3c.dom.Text;
050:
051:        /**
052:         * Helper class.
053:         * Abstract interface implementation that performs Node-type checks and
054:         * delegates testNode() processing to subclass.
055:         * <br />Examples and more at <a href="http://xmlunit.sourceforge.net"/>xmlunit.sourceforge.net</a>
056:         * @see NodeTest
057:         */
058:        public abstract class AbstractNodeTester implements  NodeTester {
059:            /**
060:             * Validate a single Node by delegating to node type specific methods.
061:             * @see #testAttribute(Attr)
062:             * @see #testCDATASection(CDATASection)
063:             * @see #testComment(Comment)
064:             * @see #testDocumentType(DocumentType)
065:             * @see #testElement(Element)
066:             * @see #testEntity(Entity)
067:             * @see #testEntityReference(EntityReference)
068:             * @see #testNotation(Notation)
069:             * @see #testProcessingInstruction(ProcessingInstruction)
070:             * @see #testText(Text)
071:             */
072:            public void testNode(Node aNode, NodeTest forTest)
073:                    throws NodeTestException {
074:                switch (aNode.getNodeType()) {
075:                case Node.ATTRIBUTE_NODE:
076:                    // should not happen as attributes are not exposed by DOM traversal
077:                    testAttribute((Attr) aNode);
078:                    break;
079:                case Node.CDATA_SECTION_NODE:
080:                    testCDATASection((CDATASection) aNode);
081:                    break;
082:                case Node.COMMENT_NODE:
083:                    testComment((Comment) aNode);
084:                    break;
085:                case Node.DOCUMENT_TYPE_NODE:
086:                    testDocumentType((DocumentType) aNode);
087:                    break;
088:                case Node.ELEMENT_NODE:
089:                    testElement((Element) aNode);
090:                    break;
091:                case Node.ENTITY_NODE:
092:                    testEntity((Entity) aNode);
093:                    break;
094:                case Node.ENTITY_REFERENCE_NODE:
095:                    testEntityReference((EntityReference) aNode);
096:                    break;
097:                case Node.NOTATION_NODE:
098:                    testNotation((Notation) aNode);
099:                    break;
100:                case Node.PROCESSING_INSTRUCTION_NODE:
101:                    testProcessingInstruction((ProcessingInstruction) aNode);
102:                    break;
103:                case Node.TEXT_NODE:
104:                    testText((Text) aNode);
105:                    break;
106:                default:
107:                    throw new NodeTestException(
108:                            "No delegate method for Node type", aNode);
109:                }
110:            }
111:
112:            /**
113:             * Template delegator for testNode() method. OVERRIDE to add custom logic
114:             * @param attribute
115:             * @exception NodeTestException always: override if required in subclass
116:             */
117:            public void testAttribute(Attr attribute) throws NodeTestException {
118:                unhandled(attribute);
119:            }
120:
121:            /**
122:             * Template delegator for testNode() method. OVERRIDE to add custom logic
123:             * @param cdata
124:             * @exception NodeTestException always: override if required in subclass
125:             */
126:            public void testCDATASection(CDATASection cdata)
127:                    throws NodeTestException {
128:                unhandled(cdata);
129:            }
130:
131:            /**
132:             * Template delegator for testNode() method. OVERRIDE to add custom logic
133:             * @param comment
134:             * @exception NodeTestException always: override if required in subclass
135:             */
136:            public void testComment(Comment comment) throws NodeTestException {
137:                unhandled(comment);
138:            }
139:
140:            /**
141:             * Template delegator for testNode() method. OVERRIDE to add custom logic
142:             * @param doctype
143:             * @exception NodeTestException always: override if required in subclass
144:             */
145:            public void testDocumentType(DocumentType doctype)
146:                    throws NodeTestException {
147:                unhandled(doctype);
148:            }
149:
150:            /**
151:             * Template delegator for testNode() method. OVERRIDE to add custom logic
152:             * @param element
153:             * @exception NodeTestException always: override if required in subclass
154:             */
155:            public void testElement(Element element) throws NodeTestException {
156:                unhandled(element);
157:            }
158:
159:            /**
160:             * Template delegator for testNode() method. OVERRIDE to add custom logic
161:             * @param entity
162:             * @exception NodeTestException always: override if required in subclass
163:             */
164:            public void testEntity(Entity entity) throws NodeTestException {
165:                unhandled(entity);
166:            }
167:
168:            /**
169:             * Template delegator for testNode() method. OVERRIDE to add custom logic
170:             * @param reference
171:             * @exception NodeTestException always: override if required in subclass
172:             */
173:            public void testEntityReference(EntityReference reference)
174:                    throws NodeTestException {
175:                unhandled(reference);
176:            }
177:
178:            /**
179:             * Template delegator for testNode() method. OVERRIDE to add custom logic
180:             * @param notation
181:             * @exception NodeTestException always: override if required in subclass
182:             */
183:            public void testNotation(Notation notation)
184:                    throws NodeTestException {
185:                unhandled(notation);
186:            }
187:
188:            /**
189:             * Template delegator for testNode() method. OVERRIDE to add custom logic
190:             * @param instr
191:             * @exception NodeTestException always: override if required in subclass
192:             */
193:            public void testProcessingInstruction(ProcessingInstruction instr)
194:                    throws NodeTestException {
195:                unhandled(instr);
196:            }
197:
198:            /**
199:             * Template delegator for testNode() method. OVERRIDE to add custom logic
200:             * @param text
201:             * @exception NodeTestException always: override if required in subclass
202:             */
203:            public void testText(Text text) throws NodeTestException {
204:                unhandled(text);
205:            }
206:
207:            private void unhandled(Node aNode) throws NodeTestException {
208:                throw new NodeTestException(
209:                        "Test fails by default in AbstractNodeTester", aNode);
210:            }
211:
212:            /**
213:             * Validate that the Nodes validated one-by-one in the <code>isValid</code>
214:             * method were all the Nodes expected. By default do nothing: 
215:             * can override to add custom logic
216:             * @exception NodeTestException if mode Nodes were expected
217:             */
218:            public void noMoreNodes(NodeTest forTest) throws NodeTestException {
219:                //by default do nothing
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.