axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dee...@apache.org
Subject svn commit: r783592 - in /webservices/axis2/trunk/java/modules/adb: ./ src/org/apache/axis2/databinding/typemapping/ test/org/apache/axis2/databinding/utils/
Date Thu, 11 Jun 2009 00:48:06 GMT
Author: deepal
Date: Thu Jun 11 00:48:06 2009
New Revision: 783592

URL: http://svn.apache.org/viewvc?rev=783592&view=rev
Log:
applying the patch from the email "Don't treat Object as DataHandler in ADB BeanUtil"

Added:
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
Modified:
    webservices/axis2/trunk/java/modules/adb/pom.xml
    webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java

Modified: webservices/axis2/trunk/java/modules/adb/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/pom.xml?rev=783592&r1=783591&r2=783592&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/adb/pom.xml Thu Jun 11 00:48:06 2009
@@ -105,7 +105,6 @@
                     <skip>false</skip>
                     <excludes>
                         <exclude>**/*Abstract*.java</exclude>
-                        <exclude>**/*Util*.java</exclude>
                         <exclude>**/*PhaseResolvingTest.java</exclude>
                     </excludes>
                     <includes>

Modified: webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java?rev=783592&r1=783591&r2=783592&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/src/org/apache/axis2/databinding/typemapping/SimpleTypeMapper.java
Thu Jun 11 00:48:06 2009
@@ -204,7 +204,7 @@
     }
 
     public static boolean isDataHandler(Class obj) {
-       return obj.isAssignableFrom(DataHandler.class);
+       return obj.isAssignableFrom(DataHandler.class) && !obj.equals(Object.class);
     }
 
     public static boolean isHashSet(Class obj) {

Added: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java?rev=783592&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
(added)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
Thu Jun 11 00:48:06 2009
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.axis2.databinding.utils;
+
+import org.apache.axiom.om.*;
+import org.apache.axis2.engine.DefaultObjectSupplier;
+import org.apache.axis2.engine.ObjectSupplier;
+
+import junit.framework.TestCase;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import java.util.List;
+
+
+public class BeanUtilTest extends TestCase {
+
+    public class ComplexType {
+        private String child;
+
+        public void setChild(String child) {
+            this.child = child;
+        }
+
+        public String getChild() {
+            return child;
+        }
+    }
+    
+    private ObjectSupplier objectSupplier;
+
+    private OMFactory omFactory;
+    private OMElement omElement;
+    private OMNamespace xsiNamespace;
+    
+    @Override
+    protected void setUp() throws Exception {
+        objectSupplier = new DefaultObjectSupplier();
+        
+        omFactory = OMAbstractFactory.getOMFactory();
+        xsiNamespace = omFactory.createOMNamespace(Constants.XSI_NAMESPACE, "xsi");
+        omElement = omFactory.createOMElement(new QName("hello"));
+    }
+    
+    public void testProcessObjectAsSimpleType() throws Exception {
+        omElement.setText("World");
+        
+        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof String);
+        assertEquals("World", result);
+    }
+
+    public void testProcessObjectAsOmElement() throws Exception {
+        omElement.setText("World");
+        
+        Object result = BeanUtil.processObject(omElement, OMElement.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof OMElement);
+        assertEquals(omElement, result);
+    }
+    
+    public void testProcessObjectAsNull() throws Exception {
+        OMAttribute nilAttribute = omFactory.createOMAttribute("nil", xsiNamespace, "true");
+        omElement.addAttribute(nilAttribute);
+        
+        Object result = BeanUtil.processObject(omElement, String.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertNull(result);
+    }
+
+    public void testProcessObjectAsByteArray() throws Exception {
+        omElement.setText("Word");
+        
+        Object result = BeanUtil.processObject(omElement, byte.class, new MultirefHelper(omElement),
true, objectSupplier);
+        assertTrue(result instanceof byte[]);
+        assertEquals(3, ((byte[]) result).length);
+    }
+
+    public void testProcessObjectAsList() throws Exception {
+        OMElement child = omFactory.createOMElement(new QName("child"), omElement);
+        child.setText("World");
+        
+        Object result = BeanUtil.processObject(omElement, List.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof List);
+        assertEquals(1, ((List) result).size());
+    }
+
+    public void testProcessObjectAsDataHandler() throws Exception {
+        omElement.setText("Word");
+        
+        Object result = BeanUtil.processObject(omElement, DataHandler.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof DataHandler);
+    }
+
+    public void testProcessObjectAsComplexType() throws Exception {
+        OMElement child = omFactory.createOMElement(new QName("child"), omElement);
+        child.setText("World");
+        
+        Object result = BeanUtil.processObject(omElement, ComplexType.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof ComplexType);
+        assertEquals("World", ((ComplexType) result).getChild());
+    }
+
+    public void testProcessObjectAsObject() throws Exception {
+        omElement.declareNamespace(omFactory.createOMNamespace(Constants.XSD_NAMESPACE, "xs"));
+
+        omElement.setText("World");
+        omElement.addAttribute(createTypeAttribute("xs:string"));
+        
+        Object result = BeanUtil.processObject(omElement, Object.class, new MultirefHelper(omElement),
false, objectSupplier);
+        assertTrue(result instanceof OMText);
+        assertEquals("World", ((OMText) result).getText());
+    }
+    
+    private OMAttribute createTypeAttribute(String value) {
+        return omFactory.createOMAttribute("type", xsiNamespace, value);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java?rev=783592&r1=783591&r2=783592&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java
(original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/ConverterUtilTest.java
Thu Jun 11 00:48:06 2009
@@ -157,11 +157,15 @@
         System.out.println("calendar ==> " + simpleDateFormat.format(date));
         System.out.println("calendar ==> " + ConverterUtil.convertToString(date));
 
+    }
+
+    public void testConvertCalendarToString() {
+        
         TimeZone timeZone = TimeZone.getTimeZone("Australia/Perth");
         Calendar c = Calendar.getInstance(timeZone);
         c.clear();
         c.set(2008, Calendar.JANUARY, 1);
-        TestCase.assertTrue(ConverterUtil.convertToString(c).endsWith("+08:00"));
+        TestCase.assertTrue(ConverterUtil.convertToString(c).endsWith("+09:00"));
         
     }
 



Mime
View raw message