Author: bimargulies
Date: Fri Sep  4 13:08:20 2009
New Revision: 811378

URL: http://svn.apache.org/viewvc?rev=811378&view=rev
Log:
I keep forgetting that I wrote some tests for the Javascript stuff that are 
stronger than
any of the Aegis tests in Aegis.

Make sure that XML files can partially override actual parameterized types for 
maps and lists.

Modified:
    
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
    
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
    
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
    
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java

Modified: 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java?rev=811378&r1=811377&r2=811378&view=diff
==============================================================================
--- 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
 (original)
+++ 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/AbstractTypeCreator.java
 Fri Sep  4 13:08:20 2009
@@ -153,7 +153,7 @@
 
     protected AegisType createHolderType(TypeClassInfo info) {
 
-        Type heldType = TypeUtil.getSingleTypeParameter(info.getType());
+        Type heldType = TypeUtil.getSingleTypeParameter(info.getType(), 0);
         if (heldType == null) {
             throw new UnsupportedOperationException("Invalid holder type " + 
info.getType());
         }

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=811378&r1=811377&r2=811378&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
 Fri Sep  4 13:08:20 2009
@@ -211,11 +211,22 @@
      * @return the parameter, or null if the type is not what we want.
      */
     public static Type getSingleTypeParameter(Type type) {
+        return getSingleTypeParameter(type, 0);
+    }
+
+    /**
+     * Insist that a Type is a parameterized type of one parameter.
+     * This is used to decompose Holders, for example.
+     * @param type the type
+     * @param index which parameter
+     * @return the parameter, or null if the type is not what we want.
+     */
+    public static Type getSingleTypeParameter(Type type, int index) {
         if (type instanceof ParameterizedType) {
             ParameterizedType pType = (ParameterizedType) type;
             Type[] params = pType.getActualTypeArguments();
-            if (params.length == 1) {
-                return params[0];
+            if (params.length > index) {
+                return params[index];
             }
         }
         return null;

Modified: 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java?rev=811378&r1=811377&r2=811378&view=diff
==============================================================================
--- 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
 (original)
+++ 
cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/XMLTypeCreator.java
 Fri Sep  4 13:08:20 2009
@@ -476,17 +476,44 @@
         // we only mess with the generic issues for list and map
         if (Collection.class.isAssignableFrom(relatedClass)) {
             Type componentType = getComponentType(mapping, parameter);
-            Type fullType = 
ParameterizedTypeFactory.createParameterizedType(relatedClass,
-                                                                             
new Type[] {componentType});
-            info.setType(fullType);
+            if (componentType != null) { // there is actually XML config.
+                Type fullType = 
ParameterizedTypeFactory.createParameterizedType(relatedClass,
+                                                                               
  new Type[] {componentType});
+                info.setType(fullType);
+            }
         } else if (Map.class.isAssignableFrom(relatedClass)) {
             Type keyType = getKeyType(mapping, parameter);
-            info.setKeyType(keyType);
+            if (keyType != null) {
+                info.setKeyType(keyType);
+            }
             Type valueType = getValueType(mapping, parameter);
-            info.setValueType(valueType);
-            Type fullType = 
ParameterizedTypeFactory.createParameterizedType(relatedClass,
-                                                                             
new Type[] {keyType, valueType});
-            info.setType(fullType);
+            if (valueType != null) {
+                info.setValueType(valueType);
+            }
+            // if the XML only specifies one, we expect the other to come from 
a full
+            // parameterized type.
+            if (keyType != null || valueType != null) {
+                if (keyType == null || valueType == null) {
+                    if (keyType == null) {
+                        keyType = 
TypeUtil.getSingleTypeParameter(info.getType(), 0);
+                    }
+                    if (keyType == null) {
+                        keyType = Object.class;
+                    }
+                    if (valueType == null) {
+                        valueType = 
TypeUtil.getSingleTypeParameter(info.getType(), 1);
+                    }
+                    if (valueType == null) {
+                        valueType = Object.class;
+                    }
+                }
+                Type fullType 
+                    = 
ParameterizedTypeFactory.createParameterizedType(relatedClass,
+                                                                       new 
Type[] {keyType, valueType});
+                info.setType(fullType);
+                
+            }
+            
 
         }
         setType(info, parameter);

Modified: 
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java?rev=811378&r1=811377&r2=811378&view=diff
==============================================================================
--- 
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java 
(original)
+++ 
cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java 
Fri Sep  4 13:08:20 2009
@@ -77,7 +77,6 @@
         return null;
     }
     
-    @org.junit.Ignore
     @Test
     public void callAcceptAny() {
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
@@ -98,7 +97,6 @@
         return null;
     }
     
-    @org.junit.Ignore
     @Test
     public void callAcceptAnyTyped() {
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {


Reply via email to