commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r156094 - in jakarta/commons/proper/betwixt/trunk/src: java/org/apache/commons/betwixt/digester/AttributeRule.java test/org/apache/commons/betwixt/SimpleClass.betwixt test/org/apache/commons/betwixt/SimpleClass.java test/org/apache/commons/betwixt/TestAttributeQNameProblem.java
Date Thu, 03 Mar 2005 22:27:14 GMT
Author: rdonkin
Date: Thu Mar  3 14:27:12 2005
New Revision: 156094

URL: http://svn.apache.org/viewcvs?view=rev&rev=156094
Log:
Fixed bug in local names when using dot bwetwixt files. Issue 14377. Test cases contributed
by Christoph Gaffga.

Added:
    jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.betwixt
    jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.java
    jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestAttributeQNameProblem.java
Modified:
    jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AttributeRule.java

Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AttributeRule.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AttributeRule.java?view=diff&r1=156093&r2=156094
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AttributeRule.java
(original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/digester/AttributeRule.java
Thu Mar  3 14:27:12 2005
@@ -198,7 +198,7 @@
             attributeDescriptor.setUpdater( new MethodUpdater( writeMethod ) );
         }
         
-        attributeDescriptor.setLocalName( propertyDescriptor.getName() );
+        attributeDescriptor.setPropertyName( propertyDescriptor.getName() );
         attributeDescriptor.setPropertyType( type );        
         
         // XXX: associate more bean information with the descriptor?

Added: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.betwixt
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.betwixt?view=auto&rev=156094
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.betwixt
(added)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.betwixt
Thu Mar  3 14:27:12 2005
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!-- 
+  Copyright 2001-2004 The Apache Software Foundation.
+  
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<info primitiveTypes="element">
+    <element name="test-class">
+        <attribute name="test-prop-1" property="testPropertyOne"/>
+        <attribute name="test-prop-2" property="testPropertyTwo"/>
+    </element>
+</info>
\ No newline at end of file

Added: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.java?view=auto&rev=156094
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.java
(added)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/SimpleClass.java
Thu Mar  3 14:27:12 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+package org.apache.commons.betwixt;
+
+public class SimpleClass {
+
+    private String testPropertyOne = "abc";
+
+    private Integer testPropertyTwo = new Integer(12);
+
+    public String getTestPropertyOne() {
+        return this.testPropertyOne;
+    }
+
+    public void setTestPropertyOne(String testPropertyOne) {
+        this.testPropertyOne = testPropertyOne;
+    }
+
+    public Integer getTestPropertyTwo() {
+        return this.testPropertyTwo;
+    }
+
+    public void setTestPropertyTwo(Integer testPropertyTwo) {
+        this.testPropertyTwo = testPropertyTwo;
+    }
+}
\ No newline at end of file

Added: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestAttributeQNameProblem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestAttributeQNameProblem.java?view=auto&rev=156094
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestAttributeQNameProblem.java
(added)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/TestAttributeQNameProblem.java
Thu Mar  3 14:27:12 2005
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */ 
+package org.apache.commons.betwixt;
+
+import org.apache.commons.betwixt.io.SAXBeanWriter;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/**
+ * I would SAX 'start element' event's attributes always expect to have qName
+ * equal to localName for simple, unprefixed XML tags. But that seems not to be
+ * true for betwixt output and breaks my application completely. <br>
+ * For the debugging output to STDOUT I would expect output like:
+ * 
+ * <pre>
+ *   XML: start document event
+ *   XML: start element qName 'test-class', localName 'test-class', URI:
+ *        - Attribute qName 'test-prop-1', localName 'test-prop-1' of CDATA: abc
+ *        - Attribute qName 'test-prop-2', localName 'test-prop-2' of CDATA: 12
+ *        - Attribute qName 'id', localName 'id' of ID: 1
+ *   XML: end element 'test-class'
+ *   XML: end document event
+ * </pre>
+ * 
+ * but I get (the attributes local names differ from the qnames):
+ * 
+ * <pre>
+ *   XML: start document event
+ *   XML: start element qName 'test-class', localName 'test-class', URI:
+ *        - Attribute qName 'test-prop-1', localName 'testPropertyOne' of CDATA: abc
+ * </pre>
+ * 
+ * got only the first two lines here beacuase assertEquals fails there.
+ * 
+ * @author Christoph Gaffga, cgaffga@triplemind.com
+ */
+public class TestAttributeQNameProblem extends AbstractTestCase {
+
+    public TestAttributeQNameProblem(String testName) {
+        super(testName);
+    }
+
+    public static class StdOutContentHandler implements ContentHandler {
+
+        public void setDocumentLocator(Locator locator) {}
+
+        public void startDocument() throws SAXException {
+            System.out.println("XML: start document event");
+        }
+
+        public void endDocument() throws SAXException {
+            System.out.println("XML: end document event");
+        }
+
+        public void startPrefixMapping(String prefix, String uri) throws SAXException {
+           System.out.println("XML: start prefix '" + prefix + "' mapping, URI: " + uri);
+        }
+
+        public void endPrefixMapping(String prefix) throws SAXException {
+            System.out.println("XML: end prefix '" + prefix + "' mapping");
+        }
+
+        public void startElement(String uri, String localName, String qName, Attributes atts)
+                throws SAXException {
+            System.out.println("XML: start element qName '" + qName + "', localName '" +
localName
+                    + "', URI:" + uri);
+            for (int i = 0; i < atts.getLength(); i++) {
+                System.out.println("     - Attribute qName '" + atts.getQName(i) + "', localName
'"
+                        + atts.getLocalName(i) + "' of " + atts.getType(i) + ": "
+                        + atts.getValue(i));
+                assertEquals(atts.getQName(i), atts.getLocalName(i));
+            }
+        }
+
+        public void endElement(String uri, String localName, String qName) throws SAXException
{
+            System.out.println("XML: end element '" + qName + "'");
+        }
+
+        public void characters(char[] ch, int start, int length) throws SAXException {
+            System.out.println("XML: characters: from " + start + ", length " + length);
+        }
+
+        public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException
{}
+
+        public void processingInstruction(String target, String data) throws SAXException
{
+            System.out.println("XML: processing instruction, target '" + target + "': " +
data);
+        }
+
+        public void skippedEntity(String name) throws SAXException {}
+
+    }
+
+    public void testAttributeOutput() {
+        try {
+            SAXBeanWriter beanWriter = new SAXBeanWriter(new StdOutContentHandler());
+            Object bean = new SimpleClass();
+            beanWriter.write(bean);
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message