cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r894074 - in /cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/ test/java/org/apache/cxf/aegis/ test/java/org/apache/cxf/aegis/type/java5/
Date Sun, 27 Dec 2009 16:19:12 GMT
Author: bimargulies
Date: Sun Dec 27 16:19:11 2009
New Revision: 894074

URL: http://svn.apache.org/viewvc?rev=894074&view=rev
Log:
CXF-2593. When you have Collection<double[]>, for some crazy reason the JRE represents
this the double[] as a
GenericArrayType and not a Class<double[]>. Add code to concoct and use the later when
presented with the former.

Added:
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java
  (with props)
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java
  (with props)
Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java?rev=894074&r1=894073&r2=894074&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java Sun
Dec 27 16:19:11 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.aegis.type;
 
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.logging.Logger;
@@ -249,6 +251,16 @@
             ParameterizedType pType = (ParameterizedType) type;
             return getTypeRelatedClass(pType.getRawType());
         }
+        
+        if (type instanceof GenericArrayType) {
+            GenericArrayType gat = (GenericArrayType) type;
+            Type compType = gat.getGenericComponentType();
+            Class<?> arrayBaseType = getTypeRelatedClass(compType);
+            // belive it or not, this seems to be the only way to get the
+            // Class object for an array of primitive type.
+            Object instance = Array.newInstance(arrayBaseType, 0);
+            return instance.getClass();
+        }
         return null;
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=894074&r1=894073&r2=894074&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
Sun Dec 27 16:19:11 2009
@@ -56,6 +56,7 @@
 import org.apache.cxf.frontend.ServerFactoryBean;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.MapNamespaceContext;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.service.Service;

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java?rev=894074&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java
Sun Dec 27 16:19:11 2009
@@ -0,0 +1,97 @@
+/**
+ * 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.cxf.aegis.type.java5;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.Stack;
+
+public class CollectionService implements CollectionServiceInterface {
+    
+    private Map<String, Map<String, BeanWithGregorianDate>> lastComplexMap;
+    
+    /** {@inheritDoc}*/
+    public Collection<String> getStrings() {
+        return null;
+    }
+
+    /** {@inheritDoc}*/
+    public void setLongs(Collection<Long> longs) {
+    }
+
+    /** {@inheritDoc}*/
+    public Collection getUnannotatedStrings() {
+        return null;
+    }
+
+    /** {@inheritDoc}*/
+    public Collection<Collection<String>> getStringCollections() {
+        return null;
+    }
+    
+    /** {@inheritDoc}*/
+    public void takeDoubleList(List<Double> doublesList) {
+    }
+    
+    /** {@inheritDoc}*/
+    public String takeSortedStrings(SortedSet<String> strings) {
+        return strings.first();
+    }
+
+    public void method1(List<String> headers1) {
+        // do nothing, this is purely for schema issues.
+    }
+
+    public String takeStack(Stack<String> strings) {
+        return strings.firstElement();
+    }
+
+    //CHECKSTYLE:OFF
+    public String takeUnsortedSet(HashSet<String> strings) {
+        return Integer.toString(strings.size());
+    }
+
+    public String takeArrayList(ArrayList<String> strings) {
+        return strings.get(0);
+    }
+    //CHECKSTYLE:ON
+
+    public void mapOfMapWithStringAndPojo(Map<String, Map<String, BeanWithGregorianDate>>
bigParam) {
+        lastComplexMap = bigParam;
+    }
+
+    protected Map<String, Map<String, BeanWithGregorianDate>> getLastComplexMap()
{
+        return lastComplexMap;
+    }
+
+    public Collection<double[]> returnCollectionOfPrimitiveArrays() {
+        List<double[]> data = new ArrayList<double[]>();
+        double[] dataArray = new double[] {3.14, 2.0, -666.6 };
+        data.add(dataArray);
+        dataArray = new double[] {-666.6, 3.14, 2.0, 0 };
+        data.add(dataArray);
+        return data;
+    }
+
+}
\ No newline at end of file

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java?rev=894074&r1=894073&r2=894074&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionServiceInterface.java
Sun Dec 27 16:19:11 2009
@@ -49,4 +49,6 @@
     void method1(List<String> headers1);
     
     void mapOfMapWithStringAndPojo(Map<String, Map<String, BeanWithGregorianDate>>
bigParam); 
+    
+    Collection<double[]> returnCollectionOfPrimitiveArrays();
 }

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java?rev=894074&r1=894073&r2=894074&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTest.java
Sun Dec 27 16:19:11 2009
@@ -21,24 +21,14 @@
 import java.beans.Introspector;
 import java.beans.PropertyDescriptor;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.SortedSet;
-import java.util.Stack;
-import java.util.TreeSet;
 
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Document;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
-import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration;
 import org.apache.cxf.aegis.type.AegisType;
 import org.apache.cxf.aegis.type.DefaultTypeMapping;
 import org.apache.cxf.aegis.type.TypeCreationOptions;
@@ -48,7 +38,6 @@
 import org.apache.cxf.aegis.type.java5.dto.DTOService;
 import org.apache.cxf.aegis.type.java5.dto.ObjectDTO;
 import org.apache.cxf.common.util.SOAPConstants;
-import org.apache.cxf.frontend.ClientProxyFactoryBean;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -232,32 +221,7 @@
                       doc);
     }
     
-    @Test
-    public void testListTypes() throws Exception {
-        createService(CollectionServiceInterface.class, new CollectionService(), null);
-        
-        ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
-        proxyFac.getServiceFactory().getServiceConfigurations().add(0, 
-                                                              new XFireCompatibilityServiceConfiguration());
-        proxyFac.setServiceClass(CollectionServiceInterface.class);
-        proxyFac.setDataBinding(new AegisDatabinding());
-        proxyFac.setAddress("local://CollectionServiceInterface");
-        proxyFac.setBus(getBus());
-
-        CollectionServiceInterface csi = (CollectionServiceInterface)proxyFac.create();
-        SortedSet<String> strings = new TreeSet<String>();
-        strings.add("Able");
-        strings.add("Baker");
-        String first = csi.takeSortedStrings(strings);
-        assertEquals("Able", first);
-        
-        //CHECKSTYLE:OFF
-        HashSet<String> hashedSet = new HashSet<String>();
-        hashedSet.addAll(strings);
-        String countString = csi.takeUnsortedSet(hashedSet);
-        assertEquals("2", countString);
-        //CHECKSTYLE:ON
-    }
+
     
     @Test
     public void testNestedMapType() throws Exception {
@@ -270,101 +234,4 @@
         AegisType valueType = mapType.getValueType();
         assertFalse(valueType.getSchemaType().getLocalPart().contains("any"));
     }
-    
-    /**
-     * CXF-2017
-     * @throws Exception
-     */
-    @Test
-    public void testNestedMap() throws Exception {
-        CollectionService impl = new CollectionService();
-        createService(CollectionServiceInterface.class, impl, null);
-        
-        ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
-        proxyFac.getServiceFactory().getServiceConfigurations().add(0, 
-                                                              new XFireCompatibilityServiceConfiguration());
-        proxyFac.setServiceClass(CollectionServiceInterface.class);
-        proxyFac.setDataBinding(new AegisDatabinding());
-        proxyFac.setAddress("local://CollectionServiceInterface");
-        proxyFac.setBus(getBus());
-
-        CollectionServiceInterface csi = (CollectionServiceInterface)proxyFac.create();
-        
-        Map<String, Map<String, BeanWithGregorianDate>> complexMap;
-        complexMap = new HashMap<String, Map<String, BeanWithGregorianDate>>();
-        Map<String, BeanWithGregorianDate> innerMap = new HashMap<String, BeanWithGregorianDate>();
-        BeanWithGregorianDate bean = new BeanWithGregorianDate();
-        bean.setName("shem bean");
-        bean.setId(42);
-        innerMap.put("firstBean", bean);
-        complexMap.put("firstKey", innerMap);
-        csi.mapOfMapWithStringAndPojo(complexMap);
-        
-        Map<String, Map<String, BeanWithGregorianDate>> gotMap = impl.getLastComplexMap();
-        assertTrue(gotMap.containsKey("firstKey"));
-        Map<String, BeanWithGregorianDate> v = gotMap.get("firstKey");
-        BeanWithGregorianDate b = v.get("firstBean");
-        assertNotNull(b);
-        
-    }
-
-    public class CollectionService implements CollectionServiceInterface {
-        
-        private Map<String, Map<String, BeanWithGregorianDate>> lastComplexMap;
-        
-        /** {@inheritDoc}*/
-        public Collection<String> getStrings() {
-            return null;
-        }
-
-        /** {@inheritDoc}*/
-        public void setLongs(Collection<Long> longs) {
-        }
-
-        /** {@inheritDoc}*/
-        public Collection getUnannotatedStrings() {
-            return null;
-        }
-
-        /** {@inheritDoc}*/
-        public Collection<Collection<String>> getStringCollections() {
-            return null;
-        }
-        
-        /** {@inheritDoc}*/
-        public void takeDoubleList(List<Double> doublesList) {
-        }
-        
-        /** {@inheritDoc}*/
-        public String takeSortedStrings(SortedSet<String> strings) {
-            return strings.first();
-        }
-
-        public void method1(List<String> headers1) {
-            // do nothing, this is purely for schema issues.
-        }
-
-        public String takeStack(Stack<String> strings) {
-            return strings.firstElement();
-        }
-
-        //CHECKSTYLE:OFF
-        public String takeUnsortedSet(HashSet<String> strings) {
-            return Integer.toString(strings.size());
-        }
-
-        public String takeArrayList(ArrayList<String> strings) {
-            return strings.get(0);
-        }
-        //CHECKSTYLE:ON
-
-        public void mapOfMapWithStringAndPojo(Map<String, Map<String, BeanWithGregorianDate>>
bigParam) {
-            lastComplexMap = bigParam;
-        }
-
-        protected Map<String, Map<String, BeanWithGregorianDate>> getLastComplexMap()
{
-            return lastComplexMap;
-        }
-
-    }
 }

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java?rev=894074&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java
Sun Dec 27 16:19:11 2009
@@ -0,0 +1,125 @@
+/**
+ * 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.cxf.aegis.type.java5;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.databinding.AegisDatabinding;
+import org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * 
+ */
+public class CollectionTestsWithService extends AbstractAegisTest {
+    
+    private CollectionServiceInterface csi;
+    private CollectionService impl;
+
+    @Before
+    public void before() {
+        impl = new CollectionService();
+        createService(CollectionServiceInterface.class, impl, null);
+        
+        ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
+        proxyFac.getServiceFactory().getServiceConfigurations().add(0, 
+                                                              new XFireCompatibilityServiceConfiguration());
+        proxyFac.setServiceClass(CollectionServiceInterface.class);
+        proxyFac.setDataBinding(new AegisDatabinding());
+        proxyFac.setAddress("local://CollectionServiceInterface");
+        proxyFac.setBus(getBus());
+
+        csi = (CollectionServiceInterface)proxyFac.create();
+    }
+    
+    /**
+     * CXF-2017
+     * @throws Exception
+     */
+    @Test
+    public void testNestedMap() throws Exception {
+        Map<String, Map<String, BeanWithGregorianDate>> complexMap;
+        complexMap = new HashMap<String, Map<String, BeanWithGregorianDate>>();
+        Map<String, BeanWithGregorianDate> innerMap = new HashMap<String, BeanWithGregorianDate>();
+        BeanWithGregorianDate bean = new BeanWithGregorianDate();
+        bean.setName("shem bean");
+        bean.setId(42);
+        innerMap.put("firstBean", bean);
+        complexMap.put("firstKey", innerMap);
+        csi.mapOfMapWithStringAndPojo(complexMap);
+        
+        Map<String, Map<String, BeanWithGregorianDate>> gotMap = impl.getLastComplexMap();
+        assertTrue(gotMap.containsKey("firstKey"));
+        Map<String, BeanWithGregorianDate> v = gotMap.get("firstKey");
+        BeanWithGregorianDate b = v.get("firstBean");
+        assertNotNull(b);
+        
+    }
+    
+    @Test
+    public void testListTypes() throws Exception {
+        SortedSet<String> strings = new TreeSet<String>();
+        strings.add("Able");
+        strings.add("Baker");
+        String first = csi.takeSortedStrings(strings);
+        assertEquals("Able", first);
+        
+        //CHECKSTYLE:OFF
+        HashSet<String> hashedSet = new HashSet<String>();
+        hashedSet.addAll(strings);
+        String countString = csi.takeUnsortedSet(hashedSet);
+        assertEquals("2", countString);
+        //CHECKSTYLE:ON
+        
+    }
+    
+    @Test
+    public void returnValueIsCollectionOfArrays() {
+        Collection<double[]> doubleDouble = csi.returnCollectionOfPrimitiveArrays();
+        assertEquals(2, doubleDouble.size());
+        double[][] data = new double[2][];
+
+        for (double[] array : doubleDouble) {
+            if (array.length == 3) {
+                data[0] = array;
+            } else {
+                data[1] = array;
+            }
+        }
+        assertNotNull(data[0]);
+        assertNotNull(data[1]);
+        assertEquals(3.14, data[0][0], .0001);
+        assertEquals(2, data[0][1], .0001);
+        assertEquals(-666.6, data[0][2], .0001);
+        assertEquals(-666.6, data[1][0], .0001);
+        assertEquals(3.14, data[1][1], .0001);
+        assertEquals(2.0, data[1][2], .0001);
+    }
+
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/CollectionTestsWithService.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message