Java Doc for XMLTestSupport.java in  » GIS » GeoTools-2.4.1 » org » geotools » xml » test » 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 » GIS » GeoTools 2.4.1 » org.geotools.xml.test 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.geotools.xml.test.XMLTestSupport

All known Subclasses:   org.geotools.filter.v1_1.FilterTestSupport,  org.geotools.sld.bindings.SLDTestSupport,  org.geotools.gml2.bindings.GMLTestSupport,  org.geotools.gml3.GML3TestSupport,  org.geotools.filter.v1_0.FilterTestSupport,
XMLTestSupport
abstract public class XMLTestSupport extends TestCase (Code)
Abstract test class to be used to unit test bindings.

Subclasses must implement the XMLTestSupport.createConfiguration() method. It must return a new instance of Configuration . Example:

 
 public MailTypeBindingTest extends XMLTestSupport {
 protected Configuration createConfiguration() {
 return new MLConfiguration();
 }
 }
 
 

The XMLTestSupport.parse() method is used to test binding parsing. Subclasses should call this from test methods after building up an instance document with XMLTestSupport.document . Example

 
 public void testParsing() throws Exception {
 //build up an instance document
 //the root element
 Element mailElement = document.createElementNS( ML.NAMESPACE, "mail" );
 document.appendChild( mailElement );
 mailElement.setAttribute( "id", "someId" );
 ....
 //call parse
 Mail mail = (Mail) parse();
 //make assertions
 assertEquals( "someId", mail.getId() );
 }
 
 

The XMLTestSupport.encode(Object,QName) method is used to test binding encoding. Subclasses should call this method from test methods after creating an object to be encoded. Example:

 
 public void testEncoding() throws Exception {
 //create the mail object
 Mail mail = new Mail( "someId" );
 mail.setEnvelope( ... );
 ....
 //call encode
 Document document = encode( mail, new QName( ML.NAMESPACE, "mail" );
 //make assertions
 assertEquals( "mail", document.getDocumentElement().getNodeName() );
 assertEquals( "someId", document.getDocumentElement().getAttribute( "id" ) );
 }
 
 

The XMLTestSupport.binding(QName) method is used to obtain an instance of a particular binding. Subclasses should call this method to assert other properties of the binding, such as type mapping and execution mode. Example:

 
 public void testType() {
 //get an instance of the binding
 Binding binding = binding( new QName( ML.NAMESPACE, "MailType" ) );
 //make assertions
 assertEquals( Mail.class, binding.getType() );
 }
 public void testExecutionMode() {
 //get an instance of the binding
 Binding binding = binding( new QName( ML.NAMESPACE, "MailType" ) );
 //make assertions
 assertEquals( Binding.OVERRIDE, binding.getExecutionMode() );
 }
 
 


author:
   Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org


Field Summary
protected  Documentdocument
    
protected static  Loggerlogger
    


Method Summary
protected  Bindingbinding(QName name)
     Convenience method for obtaining an instance of a binding.
Parameters:
  name - The qualified name of the element,attribute,or type the binding "binds" to, the key of the binding in the container.
abstract protected  ConfigurationcreateConfiguration()
     Tempalte method for subclasses to create the configuration to be used by the parser.
protected  Documentencode(Object object, QName element)
     Encodes an object, element name pair.
Parameters:
  object - The object to encode.
Parameters:
  element - The name of the element to encode.
protected  Objectparse()
     Parses the built document.
protected  voidprint(Node dom)
     Convenience method to dump the contents of the document to stdout.
protected  voidregisterNamespaces(Element root)
     Template method for subclasses to register namespace mappings on the root element of an instance document.

Namespace mappings should be set as follows:

 
 root.setAttribute( "xmlns:gml", http://www.opengis.net/gml" );
 
 

Subclasses of this method should register the default namespace, the default namesapce is the one returned by the configuration.

This method is intended to be extended or overiden.

protected  voidsetUp()
     Creates an empty xml document.

Field Detail
document
protected Document document(Code)
the instance document



logger
protected static Logger logger(Code)
Logging instance





Method Detail
binding
protected Binding binding(QName name)(Code)
Convenience method for obtaining an instance of a binding.
Parameters:
  name - The qualified name of the element,attribute,or type the binding "binds" to, the key of the binding in the container. The binding.



createConfiguration
abstract protected Configuration createConfiguration()(Code)
Tempalte method for subclasses to create the configuration to be used by the parser. A parser configuration.



encode
protected Document encode(Object object, QName element) throws Exception(Code)
Encodes an object, element name pair.
Parameters:
  object - The object to encode.
Parameters:
  element - The name of the element to encode. The object encoded.
throws:
  Exception -



parse
protected Object parse() throws Exception(Code)
Parses the built document.

This method should be called after building the entire document.


throws:
  Exception -



print
protected void print(Node dom) throws Exception(Code)
Convenience method to dump the contents of the document to stdout.



registerNamespaces
protected void registerNamespaces(Element root)(Code)
Template method for subclasses to register namespace mappings on the root element of an instance document.

Namespace mappings should be set as follows:

 
 root.setAttribute( "xmlns:gml", http://www.opengis.net/gml" );
 
 

Subclasses of this method should register the default namespace, the default namesapce is the one returned by the configuration.

This method is intended to be extended or overiden. This implementation registers the xsi,http://www.w3.org/2001/XMLSchema-instance namespace.


Parameters:
  root - The root node of the instance document.



setUp
protected void setUp() throws Exception(Code)
Creates an empty xml document.



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.