cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r702794 - in /cxf/branches/2.0.x-fixes: ./ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/ rt/dat...
Date Wed, 08 Oct 2008 10:14:21 GMT
Author: ningjiang
Date: Wed Oct  8 03:14:20 2008
New Revision: 702794

URL: http://svn.apache.org/viewvc?rev=702794&view=rev
Log:
Merged revisions 702684 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.1.x-fixes

................
  r702684 | ningjiang | 2008-10-08 11:16:07 +0800 (Wed, 08 Oct 2008) | 9 lines
  
  Merged revisions 702663 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r702663 | bimargulies | 2008-10-08 07:10:11 +0800 (Wed, 08 Oct 2008) | 2 lines
    
    CXF-1844 Add byte binding to aegis.
  ........
................

Added:
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
      - copied, changed from r702684, cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
      - copied, changed from r702684, cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
    cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java?rev=702794&r1=702793&r2=702794&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMappingRegistry.java
Wed Oct  8 03:14:20 2008
@@ -45,6 +45,7 @@
 import org.apache.cxf.aegis.type.basic.BigDecimalType;
 import org.apache.cxf.aegis.type.basic.BigIntegerType;
 import org.apache.cxf.aegis.type.basic.BooleanType;
+import org.apache.cxf.aegis.type.basic.ByteType;
 import org.apache.cxf.aegis.type.basic.CalendarType;
 import org.apache.cxf.aegis.type.basic.CharacterType;
 import org.apache.cxf.aegis.type.basic.DateTimeType;
@@ -74,11 +75,11 @@
 
 /**
  * The default implementation of TypeMappingRegistry.
- * 
+ *
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  * @since Feb 22, 2004
  */
-public final class DefaultTypeMappingRegistry extends AbstractTypeMappingRegistry 
+public final class DefaultTypeMappingRegistry extends AbstractTypeMappingRegistry
     implements TypeMappingRegistry {
     static final QName XSD_STRING = new QName(XmlConstants.XSD, "string", XmlConstants.XSD_PREFIX);
     static final QName XSD_LONG = new QName(XmlConstants.XSD, "long", XmlConstants.XSD_PREFIX);
@@ -86,6 +87,7 @@
     static final QName XSD_DOUBLE = new QName(XmlConstants.XSD, "double", XmlConstants.XSD_PREFIX);
     static final QName XSD_INT = new QName(XmlConstants.XSD, "int", XmlConstants.XSD_PREFIX);
     static final QName XSD_SHORT = new QName(XmlConstants.XSD, "short", XmlConstants.XSD_PREFIX);
+    static final QName XSD_BYTE = new QName(XmlConstants.XSD, "byte", XmlConstants.XSD_PREFIX);
     static final QName XSD_BOOLEAN = new QName(XmlConstants.XSD,
                                                          "boolean", XmlConstants.XSD_PREFIX);
     static final QName XSD_DATETIME = new QName(XmlConstants.XSD, "dateTime",
@@ -226,12 +228,12 @@
 
     protected TypeCreator createTypeCreator() {
         AbstractTypeCreator xmlCreator = createRootTypeCreator();
-    
+
         Java5TypeCreator j5Creator = new Java5TypeCreator();
         j5Creator.setNextCreator(createDefaultTypeCreator());
         j5Creator.setConfiguration(getConfiguration());
         xmlCreator.setNextCreator(j5Creator);
-        
+
         return xmlCreator;
     }
 
@@ -314,6 +316,7 @@
         register(soapTM, boolean.class, XSD_BOOLEAN, new BooleanType());
         register(soapTM, int.class, XSD_INT, new IntType());
         register(soapTM, short.class, XSD_SHORT, new ShortType());
+        register(soapTM, byte.class, XSD_BYTE, new ByteType());
         register(soapTM, double.class, XSD_DOUBLE, new DoubleType());
         register(soapTM, float.class, XSD_FLOAT, new FloatType());
         register(soapTM, long.class, XSD_LONG, new LongType());
@@ -321,6 +324,7 @@
         register(soapTM, Boolean.class, XSD_BOOLEAN, new BooleanType());
         register(soapTM, Integer.class, XSD_INT, new IntType());
         register(soapTM, Short.class, XSD_SHORT, new ShortType());
+        register(soapTM, Byte.class, XSD_BYTE, new ByteType());
         register(soapTM, Double.class, XSD_DOUBLE, new DoubleType());
         register(soapTM, Float.class, XSD_FLOAT, new FloatType());
         register(soapTM, Long.class, XSD_LONG, new LongType());
@@ -354,6 +358,7 @@
         register(tm, boolean.class, XSD_BOOLEAN, new BooleanType());
         register(tm, int.class, XSD_INT, new IntType());
         register(tm, short.class, XSD_SHORT, new ShortType());
+        register(tm, byte.class, XSD_BYTE, new ByteType());
         register(tm, double.class, XSD_DOUBLE, new DoubleType());
         register(tm, float.class, XSD_FLOAT, new FloatType());
         register(tm, long.class, XSD_LONG, new LongType());
@@ -363,6 +368,8 @@
         register(tm, Boolean.class, XSD_BOOLEAN, new BooleanType());
         register(tm, Integer.class, XSD_INT, new IntType());
         register(tm, Short.class, XSD_SHORT, new ShortType());
+        register(tm, Byte.class, XSD_BYTE, new ByteType());
+        register(tm, Boolean.class, XSD_BOOLEAN, new BooleanType());
         register(tm, Double.class, XSD_DOUBLE, new DoubleType());
         register(tm, Float.class, XSD_FLOAT, new FloatType());
         register(tm, Long.class, XSD_LONG, new LongType());

Copied: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
(from r702684, cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java?p2=cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java&p1=cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java&r1=702684&r2=702794&rev=702794&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
Wed Oct  8 03:14:20 2008
@@ -25,10 +25,14 @@
 
 /**
  * SimpleSerializer
- * 
+ *
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  */
 public class ByteType extends Type {
+    public ByteType() {
+
+    }
+
     @Override
     public Object readObject(MessageReader reader, Context context) {
         return new Byte(reader.getValue());

Modified: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java?rev=702794&r1=702793&r2=702794&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
Wed Oct  8 03:14:20 2008
@@ -68,6 +68,10 @@
     public void writeValueAsInt(Integer i) {
         writeValue(i.toString());
     }
+    
+    public void writeValueAsByte(Byte b) {
+        writeValue(b.toString());
+    }
 
     /**
      * @see org.apache.cxf.aegis.xml.MessageWriter#writeValueAsDouble(java.lang.Double)

Modified: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java?rev=702794&r1=702793&r2=702794&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
Wed Oct  8 03:14:20 2008
@@ -39,6 +39,8 @@
     void writeValueAsFloat(Float f);
 
     void writeValueAsShort(Short short1);
+    
+    void writeValueAsByte(Byte b);
 
     void writeValueAsBoolean(boolean b);
 

Modified: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java?rev=702794&r1=702793&r2=702794&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
Wed Oct  8 03:14:20 2008
@@ -29,6 +29,8 @@
     private String howdy;
     
     private int[] numbers;
+    private byte littleByte;
+    private Byte bigByte;
 
     public int[] getNumbers() {
         return numbers;
@@ -53,4 +55,20 @@
     public void setHowdy(String howdy) {
         this.howdy = howdy;
     }
+
+    public byte getLittleByte() {
+        return littleByte;
+    }
+
+    public void setLittleByte(byte littleByte) {
+        this.littleByte = littleByte;
+    }
+
+    public Byte getBigByte() {
+        return bigByte;
+    }
+
+    public void setBigByte(Byte bigByte) {
+        this.bigByte = bigByte;
+    }
 }

Modified: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=702794&r1=702793&r2=702794&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Wed Oct  8 03:14:20 2008
@@ -51,6 +51,7 @@
         super.setUp();
 
         addNamespace("b", "urn:Bean");
+        addNamespace("bz", "urn:beanz");
         addNamespace("a", "urn:anotherns");
         addNamespace("xsi", XmlConstants.XSI_NS);
 
@@ -100,16 +101,16 @@
 
     private void assertValid(String xpath, Element element) throws Exception {
         org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
-        
+
         assertValid(xpath, doc);
     }
 
     private void assertInvalid(String xpath, Element element) throws Exception {
         org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
-        
+
         assertInvalid(xpath, doc);
     }
-    
+
     @Test
     public void testBeanWithXsiType() throws Exception {
         BeanType type = new BeanType();
@@ -240,7 +241,7 @@
         writer.flush();
 
         bos.close();
-        
+
         StaxBuilder builder = new StaxBuilder();
         Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
         Element element = doc.getRootElement();
@@ -283,7 +284,7 @@
         assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
         assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='bleh']",
schema);
     }
-    
+
     @Test
     public void testNillableInt() throws Exception {
         BeanTypeInfo info = new BeanTypeInfo(IntBean.class, "urn:Bean");
@@ -342,6 +343,54 @@
                       schema);
     }
     @Test
+    public void testByteMappings() throws Exception {
+        reg = new DefaultTypeMappingRegistry();
+        reg.createDefaultMappings();
+        mapping = reg.createTypeMapping(true);
+
+        BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+
+
+        Element types = new Element("types", "xsd", XmlConstants.XSD);
+        Element schema = new Element("schema", "xsd", XmlConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='littleByte']"
+                       + "/@type",
+                       schema);
+
+        assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='bigByte']"
+                       + "/@type",
+                       schema);
+
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        SimpleBean bean = new SimpleBean();
+        bean.setBigByte(new Byte((byte)0xfe));
+        bean.setLittleByte((byte)0xfd);
+        type.writeObject(bean, new JDOMWriter(element), new Context());
+        Byte bb = new Byte((byte)0xfe);
+        String bbs = bb.toString();
+        addNamespace("n1", "http://services.aegis.cxf.apache.org");
+        assertValid("/b:root/n1:bigByte[text()='" + bbs + "']", element);
+
+        // Test reading
+        ElementReader reader = new ElementReader(getResourceAsStream("byteBeans.xml"));
+        bean = (SimpleBean)type.readObject(reader, new Context());
+        assertEquals(-5, bean.getLittleByte());
+        assertEquals(25, bean.getBigByte().byteValue());
+
+        reader.getXMLStreamReader().close();
+
+    }
+
+    @Test
     public void testNullNonNillableWithDate() throws Exception {
         BeanTypeInfo info = new BeanTypeInfo(DateBean.class, "urn:Bean");
         info.setTypeMapping(mapping);
@@ -375,7 +424,8 @@
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
         PropertyDescriptor[] pds = info.getPropertyDescriptors();
-        assertEquals(3, pds.length);
+
+        assertEquals(5, pds.length);
 
         ExtendedBean bean = new ExtendedBean();
         bean.setHowdy("howdy");

Copied: cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
(from r702684, cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml)
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml?p2=cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml&p1=cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml&r1=702684&r2=702794&rev=702794&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
(original)
+++ cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
Wed Oct  8 03:14:20 2008
@@ -17,7 +17,7 @@
   under the License.
 -->
 <b:bean xmlns:b="urn:Bean" xsi:type="b:SimpleBean"
-   xmlns:beanz="urn:beanz"
+   xmlns:beanz="http://services.aegis.cxf.apache.org"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <beanz:littleByte>-5</beanz:littleByte>
   <beanz:bigByte>25</beanz:bigByte>



Mime
View raw message