incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmidd...@apache.org
Subject svn commit: r545280 - in /incubator/yoko/trunk/bindings/src: main/java/org/apache/yoko/bindings/corba/runtime/ main/java/org/apache/yoko/bindings/corba/types/ test/java/org/apache/yoko/bindings/corba/ test/resources/idl/type_test/
Date Thu, 07 Jun 2007 19:48:54 GMT
Author: dmiddlem
Date: Thu Jun  7 12:48:53 2007
New Revision: 545280

URL: http://svn.apache.org/viewvc?view=rev&rev=545280
Log:
Commit for YOKO-380:
* Fix a condition where the any is marshalled before the contained type has been completely
read.
* Moving an any test to the IDLToWSDL test

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandler.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyListener.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
    incubator/yoko/trunk/bindings/src/test/resources/idl/type_test/idltowsdl_type_test.idl

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/runtime/CorbaObjectWriter.java
Thu Jun  7 12:48:53 2007
@@ -97,7 +97,8 @@
             this.writeWString((String)((CorbaPrimitiveHandler)obj).getValue());
             break;
         case TCKind._tk_any:
-            this.writeAny(((CorbaAnyHandler)obj).getValue());
+            //this.writeAny(((CorbaAnyHandler)obj).getValue());
+            this.writeAny(obj);
             break;
 
         // Now for the complex types
@@ -243,9 +244,25 @@
         }
     }
 
-    public void writeAny(Any a) throws CorbaBindingException {
+    public void writeAny(CorbaObjectHandler obj) throws CorbaBindingException {
+
+        CorbaAnyHandler anyHandler = (CorbaAnyHandler)obj;
+        CorbaObjectHandler containedType = anyHandler.getAnyContainedType();
+        Any a = anyHandler.getValue();
+
+        // This is true if we have an empty any
+        if (containedType != null) {
+            OutputStream os = a.create_output_stream();
+            CorbaObjectWriter writer = new CorbaObjectWriter(os);
+            writer.write(containedType);
+            a.read_value(os.create_input_stream(), containedType.getTypeCode());
+        }
         stream.write_any(a);
     }
+
+    //public void writeAny(Any a) throws CorbaBindingException {
+    //    stream.write_any(a);
+    //}
 
     // -- complex types --
     public void writeEnum(CorbaObjectHandler obj) throws CorbaBindingException {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyEventProducer.java
Thu Jun  7 12:48:53 2007
@@ -58,6 +58,7 @@
         serviceInfo = info;
 
         containedType = getAnyContainedType(handler.getValue());
+        handler.setAnyContainedType(containedType);
 
         if (containedType != null) {
             QName containedSchemaType = convertIdlToSchemaType(containedType);

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandler.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandler.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandler.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandler.java
Thu Jun  7 12:48:53 2007
@@ -30,6 +30,7 @@
 public class CorbaAnyHandler extends CorbaObjectHandler {
 
     private Any value;
+    private CorbaObjectHandler containedType;
     private CorbaTypeMap typeMap;
     
     public CorbaAnyHandler(QName anyName, 
@@ -45,6 +46,14 @@
     
     public Any getValue() {
         return value;
+    }
+
+    public void setAnyContainedType(CorbaObjectHandler obj) {
+        containedType = obj;
+    }
+
+    public CorbaObjectHandler getAnyContainedType() {
+        return containedType;
     }
 
     public void clear() {

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyListener.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyListener.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyListener.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaAnyListener.java
Thu Jun  7 12:48:53 2007
@@ -26,13 +26,11 @@
 import org.apache.cxf.service.model.ServiceInfo;
 
 import org.apache.yoko.bindings.corba.CorbaTypeMap;
-import org.apache.yoko.bindings.corba.runtime.CorbaObjectWriter;
 import org.apache.yoko.bindings.corba.utils.CorbaAnyHelper;
 import org.apache.yoko.wsdl.W3CConstants;
 
 import org.omg.CORBA.Any;
 import org.omg.CORBA.ORB;
-import org.omg.CORBA.portable.OutputStream;
 
 public class CorbaAnyListener extends AbstractCorbaTypeListener {
 
@@ -41,7 +39,6 @@
     private ServiceInfo serviceInfo;
     private CorbaTypeListener currentTypeListener;
     private QName containedType;
-    private int depth;
     private Map<String, String> namespaceMap;
 
     public CorbaAnyListener(CorbaObjectHandler h,
@@ -52,13 +49,11 @@
         orb = orbRef;
         typeMap = map;
         serviceInfo = info;
-        depth = 0;
 
         namespaceMap = new HashMap<String, String>();
     }
 
     public void processStartElement(QName name) {
-        depth++;
         if (currentTypeListener == null) {
             currentElement = name;
             QName idlType = convertSchemaToIdlType(containedType);
@@ -67,7 +62,14 @@
                                                                     typeMap,
                                                                     orb,
                                                                     serviceInfo);
-            currentTypeListener.processStartElement(idlType);
+
+            CorbaAnyHandler anyHandler = (CorbaAnyHandler)handler;
+            // We need an any during the write.  Since we don't have the orb in the writer,
create
+            // the any here and use it later.
+            anyHandler.setValue(orb.create_any());
+            anyHandler.setAnyContainedType(currentTypeListener.getCorbaObject());
+
+            currentTypeListener.processStartElement(name);
         } else {
             currentTypeListener.processStartElement(name);
         }
@@ -76,24 +78,9 @@
     public void processEndElement(QName name) {
         if (currentTypeListener != null) {
             currentTypeListener.processEndElement(name);
-            depth--;
-        }
-    
-        if (depth == 0 && currentTypeListener != null && currentElement.equals(name))
{
-            CorbaObjectHandler obj = currentTypeListener.getCorbaObject();
-
-            Any a = orb.create_any();
-            OutputStream os = a.create_output_stream();
-            CorbaObjectWriter writer = new CorbaObjectWriter(os);
-            writer.write(obj);
-            a.read_value(os.create_input_stream(), obj.getTypeCode());
-            
             CorbaAnyHandler anyHandler = (CorbaAnyHandler)handler;
-            anyHandler.setValue(a);
-
-            currentTypeListener = null;
-            currentElement = null;
-        } 
+            anyHandler.setAnyContainedType(currentTypeListener.getCorbaObject());
+        }
     }
 
     public void processCharacters(String text) {
@@ -111,13 +98,10 @@
             CorbaObjectHandler obj = primitiveListener.getCorbaObject();
 
             Any a = orb.create_any();
-            OutputStream os = a.create_output_stream();
-            CorbaObjectWriter writer = new CorbaObjectWriter(os);
-            writer.write(obj);
-            a.read_value(os.create_input_stream(), obj.getTypeCode());
             
             CorbaAnyHandler anyHandler = (CorbaAnyHandler)handler;
             anyHandler.setValue(a);
+            anyHandler.setAnyContainedType(obj);
         } else {
             currentTypeListener.processCharacters(text);
         }

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtils.java
Thu Jun  7 12:48:53 2007
@@ -161,6 +161,9 @@
         }
         if (!CorbaUtils.isPrimitiveIdlType(idlType)) {
             switch (obj.getTypeCode().kind().value()) {
+            case TCKind._tk_any:
+                ((CorbaAnyHandler)obj).setValue(orb.create_any());
+                break;
             case TCKind._tk_array:
                 initializeArrayHandler(orb, obj, name, schemaType, typeMap, serviceInfo);
                 break;

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/AbstractIdlToWsdlTypeTestClient.java
Thu Jun  7 12:48:53 2007
@@ -359,8 +359,68 @@
         }
     }
 
+    public boolean compareAny(Object left, Object right) {
+        boolean result = false;
+        if (left instanceof Boolean) {
+            if (right instanceof Boolean) {
+                Boolean l = (Boolean)left;
+                Boolean r = (Boolean)right;
+                result = l.equals(r);
+            } else {
+                result = false;
+            }
+        } else if (left instanceof IdltowsdlTypeTestStruct1) {
+            if (right instanceof IdltowsdlTypeTestStruct1) {
+                IdltowsdlTypeTestStruct1 l = (IdltowsdlTypeTestStruct1)left;
+                IdltowsdlTypeTestStruct1 r = (IdltowsdlTypeTestStruct1)right;
+                result = l.getStruct1Long() == r.getStruct1Long();
+                result |= l.getStruct1Short() == r.getStruct1Short();
+            } else {
+                result = false;
+            }
+        } else if (left instanceof String) {
+            if (right instanceof String) {
+                String l = (String)left;
+                String r = (String)right;
+                result = l.equals(r);
+            } else {
+                result = false;
+            }
+        } else {
+            result = false;
+        }
+        return result;
+    }
+
+
     public void testAny() throws Exception {
+        Boolean bool = new Boolean(true);
+        IdltowsdlTypeTestStruct1 struct = new IdltowsdlTypeTestStruct1();
+        struct.setStruct1Long(123);
+        struct.setStruct1Short((short) 456);
+        String str = new String("Hello");
+
+        Object valueSets[][] = {
+            {bool, bool},
+            // REVISIT: There is still an issue with using this struct here.  Commented out
for now
+            //{bool, struct},
+            //{struct, bool},
+            //{struct, str},
+            {str, str}
+        };
+
+        for (int i = 0; i < valueSets.length; i++) {
+            Object in = valueSets[i][0];
+            Holder<Object> inoutOrig = new Holder<Object>(valueSets[i][1]);
+            Holder<Object> inout = new Holder<Object>(valueSets[i][1]);
+            Holder<Object> out = new Holder<Object>();
+            
+            Object ret = client.testAny(in, inout, out);
 
+            assertTrue("testAny(): Incorrect value for out param", compareAny(inoutOrig.value,
out.value));
+            assertTrue("testAny(): Incorrect value for inout param", compareAny(in, inout.value));
+            assertTrue("testAny(): Incorrect value for return", compareAny(in, ret));
+        }
     }
 
     ////

Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
(original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
Thu Jun  7 12:48:53 2007
@@ -114,7 +114,7 @@
     public void testUnsignedLong() { }
     public void testWchar() { }
     public void testOctet () { }
-    public void testAny () { }
+    //public void testAny () { }
     public void testWstring() { }
 
     //public void testUnion() { }

Modified: incubator/yoko/trunk/bindings/src/test/resources/idl/type_test/idltowsdl_type_test.idl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/resources/idl/type_test/idltowsdl_type_test.idl?view=diff&rev=545280&r1=545279&r2=545280
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/resources/idl/type_test/idltowsdl_type_test.idl
(original)
+++ incubator/yoko/trunk/bindings/src/test/resources/idl/type_test/idltowsdl_type_test.idl
Thu Jun  7 12:48:53 2007
@@ -22,16 +22,16 @@
     string greetMe(in string name);
 
     ////
-    // base_type_spec
-
-    typedef long TpInt32;
-
-    typedef TpInt32 TpDuration;
-
-    TpDuration testAlias(in TpDuration inDuration,
-	                     inout TpDuration inoutDuration,
-						 out TpDuration outDuration);
-
+    // base_type_spec
+
+    typedef long TpInt32;
+
+    typedef TpInt32 TpDuration;
+
+    TpDuration testAlias(in TpDuration inDuration,
+	                     inout TpDuration inoutDuration,
+						 out TpDuration outDuration);
+
 
     // floating point types
     float testFloat(in float inFloat,
@@ -124,10 +124,11 @@
     struct struct1 {
         long struct1long;
         short struct1short;
-    };
-	struct struct2 {
-        long struct2long;
-        struct1 struct2struct;
+    };
+
+    struct struct2 {
+        long struct2long;
+        struct1 struct2struct;
     };
     struct1 testStruct(in struct1 inStruct1,
                        inout struct1 inoutStruct1,
@@ -151,30 +152,30 @@
     // enum
     enum1 testEnum(in enum1 inEnum1,
                    inout enum1 inoutEnum1,
-                   out enum1 outEnum1);
-
-    typedef sequence <union1> unionSet;
-
-    unionSet testUnionSet(in unionSet inUnionSet,
-                          inout unionSet inoutUnionSet,
-                          out unionSet outUnionSet);
-
-    typedef sequence <struct2> structSet;
-	typedef sequence <enum1> enumSet;
-	typedef sequence <string> stringSet;
-
-    union union2 switch(enum1) {
-	    case e1_1: union1 u2_1;
-		case e1_2: enum1 u2_2;
-		case e1_3: unionSet u2_3;
-		case e1_4: enumSet u2_4;
-		case e1_5: stringSet u2_5;
-		default: structSet u2_6;
-	};
-
-	union2 testUnionVariants(in union2 inUnion2,
-	                         inout union2 inoutUnion2,
-			  	             out union2 outUnion2);
+                   out enum1 outEnum1);
+
+    typedef sequence <union1> unionSet;
+
+    unionSet testUnionSet(in unionSet inUnionSet,
+                          inout unionSet inoutUnionSet,
+                          out unionSet outUnionSet);
+
+    typedef sequence <struct2> structSet;
+    typedef sequence <enum1> enumSet;
+    typedef sequence <string> stringSet;
+
+    union union2 switch(enum1) {
+	    case e1_1: union1 u2_1;
+		case e1_2: enum1 u2_2;
+		case e1_3: unionSet u2_3;
+		case e1_4: enumSet u2_4;
+		case e1_5: stringSet u2_5;
+		default: structSet u2_6;
+	};
+
+	union2 testUnionVariants(in union2 inUnion2,
+	                         inout union2 inoutUnion2,
+			  	             out union2 outUnion2);
 
     ////
     // const_type



Mime
View raw message