cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r702684 - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ rt/databind...
Date Wed, 08 Oct 2008 03:16:08 GMT
Author: ningjiang
Date: Tue Oct  7 20:16:07 2008
New Revision: 702684

URL: http://svn.apache.org/viewvc?rev=702684&view=rev
Log:
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.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
      - copied unchanged from r702663, cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ByteType.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
      - copied unchanged from r702663, cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/byteBeans.xml
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/XMLSchemaQNames.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
    cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java

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

Modified: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/XMLSchemaQNames.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/XMLSchemaQNames.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/XMLSchemaQNames.java
(original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/XMLSchemaQNames.java
Tue Oct  7 20:16:07 2008
@@ -31,6 +31,7 @@
     public static final QName XSD_DOUBLE = new QName(SOAPConstants.XSD, "double", SOAPConstants.XSD_PREFIX);
     public static final QName XSD_INT = new QName(SOAPConstants.XSD, "int", SOAPConstants.XSD_PREFIX);
     public static final QName XSD_SHORT = new QName(SOAPConstants.XSD, "short", SOAPConstants.XSD_PREFIX);
+    public static final QName XSD_BYTE = new QName(SOAPConstants.XSD, "byte", SOAPConstants.XSD_PREFIX);
     public static final QName XSD_BOOLEAN = new QName(SOAPConstants.XSD,
                                                          "boolean", SOAPConstants.XSD_PREFIX);
     public static final QName XSD_DATETIME = new QName(SOAPConstants.XSD, "dateTime",

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/DefaultTypeMapping.java
Tue Oct  7 20:16:07 2008
@@ -43,6 +43,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.CharacterAsStringType;
 import org.apache.cxf.aegis.type.basic.CharacterType;
@@ -241,6 +242,7 @@
         defaultRegister(tm, defaultNillable, Integer.class, XMLSchemaQNames.XSD_INT, new
IntType());
         defaultRegister(tm, defaultNillable, Long.class, XMLSchemaQNames.XSD_LONG, new LongType());
         defaultRegister(tm, defaultNillable, Object.class, XMLSchemaQNames.XSD_ANY, new ObjectType());
+        defaultRegister(tm, defaultNillable, Byte.class, XMLSchemaQNames.XSD_BYTE, new ByteType());
         defaultRegister(tm, defaultNillable, Short.class, XMLSchemaQNames.XSD_SHORT, new
ShortType());
         defaultRegister(tm, defaultNillable, Source.class, XMLSchemaQNames.XSD_ANY, new SourceType());
         defaultRegister(tm, defaultNillable, String.class, XMLSchemaQNames.XSD_STRING, new
StringType());
@@ -258,6 +260,7 @@
         defaultRegister(tm, defaultNillable, float.class, XMLSchemaQNames.XSD_FLOAT, new
FloatType());
         defaultRegister(tm, defaultNillable, int.class, XMLSchemaQNames.XSD_INT, new IntType());
         defaultRegister(tm, defaultNillable, short.class, XMLSchemaQNames.XSD_SHORT, new
ShortType());
+        defaultRegister(tm, defaultNillable, byte.class, XMLSchemaQNames.XSD_BYTE, new ByteType());
         defaultRegister(tm, defaultNillable, long.class, XMLSchemaQNames.XSD_LONG, new LongType());
 
         defaultRegister(tm, defaultNillable, java.sql.Date.class, XMLSchemaQNames.XSD_DATETIME,

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/AbstractMessageWriter.java
Tue Oct  7 20:16:07 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.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/MessageWriter.java
Tue Oct  7 20:16:07 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.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/SimpleBean.java
Tue Oct  7 20:16:07 2008
@@ -32,6 +32,8 @@
     
     private Character character;
     private char primitiveCharacter;
+    private byte littleByte;
+    private Byte bigByte;
 
     public int[] getNumbers() {
         return numbers;
@@ -82,4 +84,20 @@
     public void setPrimitiveChar(char pchar) {
         this.primitiveCharacter = pchar;
     }
+
+    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.1.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.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=702684&r1=702683&r2=702684&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Tue Oct  7 20:16:07 2008
@@ -53,6 +53,7 @@
         super.setUp();
     
         addNamespace("b", "urn:Bean");
+        addNamespace("bz", "urn:beanz");
         addNamespace("a", "urn:anotherns");
         addNamespace("xsi", SOAPConstants.XSI_NS);
 
@@ -364,6 +365,66 @@
     }
     
     @Test
+    public void testByteMappings() throws Exception {
+        context = new AegisContext();
+        context.initialize();
+        mapping = context.getTypeMapping();
+
+        BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
+        type.setTypeClass(SimpleBean.class);
+        type.setTypeMapping(mapping);
+
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
+        type.writeSchema(schema);
+
+        NodeList typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='littleByte']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        Attr typeAttr = (Attr)typeAttrNode.item(0);
+        String typeQnameString = typeAttr.getValue();
+        String[] pieces = typeQnameString.split(":");
+        assertEquals("xsd", pieces[0]);
+        assertEquals("byte", pieces[1]);
+        
+        typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='bigByte']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        typeAttr = (Attr)typeAttrNode.item(0);
+        typeQnameString = typeAttr.getValue();
+        pieces = typeQnameString.split(":");
+        assertEquals("xsd", pieces[0]);
+        assertEquals("byte", pieces[1]);
+        
+        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), getContext());
+        Byte bb = new Byte((byte)0xfe);
+        String bbs = bb.toString();
+        assertValid("/b:root/bz:bigByte[text()='" + bbs + "']", element);
+        
+        // Test reading
+        ElementReader reader = new ElementReader(getResourceAsStream("byteBeans.xml"));
+        bean = (SimpleBean)type.readObject(reader, getContext());
+        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);
@@ -397,7 +458,7 @@
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
         PropertyDescriptor[] pds = info.getPropertyDescriptors();
-        assertEquals(6, pds.length);
+        assertEquals(8, pds.length);
 
         ExtendedBean bean = new ExtendedBean();
         bean.setHowdy("howdy");



Mime
View raw message