Source Code Cross Referenced for TestAttributeQNameProblem.java in  » Library » Apache-commons-betwixt-0.8-src » org » apache » commons » betwixt » 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 » Library » Apache commons betwixt 0.8 src » org.apache.commons.betwixt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.commons.betwixt;
018:
019:        import org.apache.commons.betwixt.io.SAXBeanWriter;
020:        import org.xml.sax.Attributes;
021:        import org.xml.sax.ContentHandler;
022:        import org.xml.sax.Locator;
023:        import org.xml.sax.SAXException;
024:
025:        /**
026:         * I would SAX 'start element' event's attributes always expect to have qName
027:         * equal to localName for simple, unprefixed XML tags. But that seems not to be
028:         * true for betwixt output and breaks my application completely. <br>
029:         * For the debugging output to STDOUT I would expect output like:
030:         * 
031:         * <pre>
032:         *   XML: start document event
033:         *   XML: start element qName 'test-class', localName 'test-class', URI:
034:         *        - Attribute qName 'test-prop-1', localName 'test-prop-1' of CDATA: abc
035:         *        - Attribute qName 'test-prop-2', localName 'test-prop-2' of CDATA: 12
036:         *        - Attribute qName 'id', localName 'id' of ID: 1
037:         *   XML: end element 'test-class'
038:         *   XML: end document event
039:         * </pre>
040:         * 
041:         * but I get (the attributes local names differ from the qnames):
042:         * 
043:         * <pre>
044:         *   XML: start document event
045:         *   XML: start element qName 'test-class', localName 'test-class', URI:
046:         *        - Attribute qName 'test-prop-1', localName 'testPropertyOne' of CDATA: abc
047:         * </pre>
048:         * 
049:         * got only the first two lines here beacuase assertEquals fails there.
050:         * 
051:         * @author Christoph Gaffga, cgaffga@triplemind.com
052:         */
053:        public class TestAttributeQNameProblem extends AbstractTestCase {
054:
055:            public TestAttributeQNameProblem(String testName) {
056:                super (testName);
057:            }
058:
059:            public static class StdOutContentHandler implements  ContentHandler {
060:
061:                public void setDocumentLocator(Locator locator) {
062:                }
063:
064:                public void startDocument() throws SAXException {
065:                    System.out.println("XML: start document event");
066:                }
067:
068:                public void endDocument() throws SAXException {
069:                    System.out.println("XML: end document event");
070:                }
071:
072:                public void startPrefixMapping(String prefix, String uri)
073:                        throws SAXException {
074:                    System.out.println("XML: start prefix '" + prefix
075:                            + "' mapping, URI: " + uri);
076:                }
077:
078:                public void endPrefixMapping(String prefix) throws SAXException {
079:                    System.out.println("XML: end prefix '" + prefix
080:                            + "' mapping");
081:                }
082:
083:                public void startElement(String uri, String localName,
084:                        String qName, Attributes atts) throws SAXException {
085:                    System.out.println("XML: start element qName '" + qName
086:                            + "', localName '" + localName + "', URI:" + uri);
087:                    for (int i = 0; i < atts.getLength(); i++) {
088:                        System.out.println("     - Attribute qName '"
089:                                + atts.getQName(i) + "', localName '"
090:                                + atts.getLocalName(i) + "' of "
091:                                + atts.getType(i) + ": " + atts.getValue(i));
092:                        assertEquals(atts.getQName(i), atts.getLocalName(i));
093:                    }
094:                }
095:
096:                public void endElement(String uri, String localName,
097:                        String qName) throws SAXException {
098:                    System.out.println("XML: end element '" + qName + "'");
099:                }
100:
101:                public void characters(char[] ch, int start, int length)
102:                        throws SAXException {
103:                    System.out.println("XML: characters: from " + start
104:                            + ", length " + length);
105:                }
106:
107:                public void ignorableWhitespace(char[] ch, int start, int length)
108:                        throws SAXException {
109:                }
110:
111:                public void processingInstruction(String target, String data)
112:                        throws SAXException {
113:                    System.out.println("XML: processing instruction, target '"
114:                            + target + "': " + data);
115:                }
116:
117:                public void skippedEntity(String name) throws SAXException {
118:                }
119:
120:            }
121:
122:            public void testAttributeOutput() {
123:                try {
124:                    SAXBeanWriter beanWriter = new SAXBeanWriter(
125:                            new StdOutContentHandler());
126:                    Object bean = new SimpleClass();
127:                    beanWriter.write(bean);
128:                } catch (Exception ex) {
129:                    ex.printStackTrace();
130:                }
131:            }
132:
133:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.