incubator-yoko-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r516437 - in /incubator/yoko/trunk/bindings/src: main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java main/java/org/apache/yoko/bindings/corba/CorbaUtils.java test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java
Date Fri, 09 Mar 2007 15:44:15 GMT
Author: bravi
Date: Fri Mar  9 07:44:14 2007
New Revision: 516437

URL: http://svn.apache.org/viewvc?view=rev&rev=516437
Log:
[YOKO-245] - Fixing to some tests in IDLToWSDLTypeTest.

Modified:
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
    incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
    incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/IdlToWsdlTypeTest.java

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java?view=diff&rev=516437&r1=516436&r2=516437
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaStaxObject.java
Fri Mar  9 07:44:14 2007
@@ -314,14 +314,18 @@
             StartElement startEl = reader.nextEvent().asStartElement();
             QName name = startEl.getName();
             XMLEvent evt = reader.nextEvent();
-            Characters charEl;
             if (evt.isStartElement()) {
-                charEl = reader.nextEvent().asCharacters();
+                evt = reader.nextEvent();
+            }
+            String value;
+            if (evt.isCharacters()) {
+                value = evt.asCharacters().getData();
             } else {
-                charEl = evt.asCharacters();
+                value = "";
+            }
+            if (reader.peek().isEndElement()) {
+                reader.nextEvent().asEndElement();
             }
-            String value = charEl.getData();
-            reader.nextEvent().asEndElement();
             CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(name, idlType, tc, null);
             obj.setValueFromData(value);
             return obj;

Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java?view=diff&rev=516437&r1=516436&r2=516437
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
(original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
Fri Mar  9 07:44:14 2007
@@ -175,6 +175,7 @@
             for (int i = 0; i < members.length; ++i) {
                 members[i] = ((Enumerator) enums.get(i)).getValue();
             }
+            name = getTypeCodeName(name);
             tc = orb.create_enum_tc(enumType.getRepositoryID(), name, members);
         } else if (obj instanceof Exception) {
             Exception exceptType = (Exception)obj;
@@ -187,7 +188,7 @@
                 members[i] = new StructMember(member.getName(), 
                                               getTypeCode(orb, member.getIdltype(), typeMaps),
null);
             }
-            String name = exceptType.getName();
+            String name = getTypeCodeName(exceptType.getName());
             tc = orb.create_exception_tc(exceptType.getRepositoryID(), name, members);
         } else if (obj instanceof Fixed) {
             Fixed fixedType = (Fixed) obj;
@@ -198,7 +199,7 @@
             if (objType.getName().equals("CORBA.Object")) {
                 tc = orb.create_interface_tc(objType.getRepositoryID(), "Object");
             } else {
-                tc = orb.create_interface_tc(objType.getRepositoryID(), objType.getName());
+                tc = orb.create_interface_tc(objType.getRepositoryID(), getTypeCodeName(objType.getName()));
             }
         } else if (obj instanceof Sequence) {
             Sequence seqType = (Sequence)obj;
@@ -215,7 +216,7 @@
                 members[i] = new StructMember(member.getName(), 
                                               getTypeCode(orb, member.getIdltype(), typeMaps),
null);
             }
-            String name = structType.getName();
+            String name = getTypeCodeName(structType.getName());
             tc = orb.create_struct_tc(structType.getRepositoryID(), name, members);
         } else if (obj instanceof Union) {
             tc = getUnionTypeCode(orb, obj, typeMaps);
@@ -234,56 +235,66 @@
             List<CaseType> cases = branch.getCase();
             for (Iterator<CaseType> caseIter = cases.iterator(); caseIter.hasNext();)
{
                 CaseType cs = caseIter.next();
-                UnionMember member = new UnionMember();
-                member.name = branch.getName();
-                member.type = getTypeCode(orb, branch.getIdltype(), typeMaps);
-                member.label = orb.create_any();
-                
-                // We need to insert the labels in a way that depends on the type of the
discriminator.  
-                // According to the CORBA specification, the following types are permissable
as 
-                // discriminator types:
-                //    * signed & unsigned short
-                //    * signed & unsigned long
-                //    * signed & unsigned long long
-                //    * char
-                //    * boolean
-                switch (discTC.kind().value()) {
-                case TCKind._tk_short:
-                    member.label.insert_short(Short.parseShort(cs.getLabel()));
-                    break;
-                case TCKind._tk_ushort:
-                    member.label.insert_ushort(Short.parseShort(cs.getLabel()));
-                    break;
-                case TCKind._tk_long:
-                    member.label.insert_long(Integer.parseInt(cs.getLabel()));
-                    break;
-                case TCKind._tk_ulong:
-                    member.label.insert_ulong(Integer.parseInt(cs.getLabel()));
-                    break;
-                case TCKind._tk_longlong:
-                    member.label.insert_longlong(Long.parseLong(cs.getLabel()));
-                    break;
-                case TCKind._tk_ulonglong:
-                    member.label.insert_ulonglong(Long.parseLong(cs.getLabel()));
-                    break;
-                case TCKind._tk_char:
-                    member.label.insert_char(cs.getLabel().charAt(0));
-                    break;
-                case TCKind._tk_boolean:
-                    member.label.insert_boolean(Boolean.parseBoolean(cs.getLabel()));
-                    break;
-                default:
-                    // TODO: Throw exception since this is an unsupported discriminator type
+                if (!members.containsKey(cs.getLabel())) {
+                    UnionMember member = new UnionMember();
+                    member.name = branch.getName();
+                    member.type = getTypeCode(orb, branch.getIdltype(), typeMaps);
+                    member.label = orb.create_any();
+                    // We need to insert the labels in a way that depends on the type of
the discriminator.  
+                    // According to the CORBA specification, the following types are permissable
as 
+                    // discriminator types:
+                    //    * signed & unsigned short
+                    //    * signed & unsigned long
+                    //    * signed & unsigned long long
+                    //    * char
+                    //    * boolean
+                    switch (discTC.kind().value()) {
+                    case TCKind._tk_short:
+                        member.label.insert_short(Short.parseShort(cs.getLabel()));
+                        break;
+                    case TCKind._tk_ushort:
+                        member.label.insert_ushort(Short.parseShort(cs.getLabel()));
+                        break;
+                    case TCKind._tk_long:
+                        member.label.insert_long(Integer.parseInt(cs.getLabel()));
+                        break;
+                    case TCKind._tk_ulong:
+                        member.label.insert_ulong(Integer.parseInt(cs.getLabel()));
+                        break;
+                    case TCKind._tk_longlong:
+                        member.label.insert_longlong(Long.parseLong(cs.getLabel()));
+                        break;
+                    case TCKind._tk_ulonglong:
+                        member.label.insert_ulonglong(Long.parseLong(cs.getLabel()));
+                        break;
+                    case TCKind._tk_char:
+                        member.label.insert_char(cs.getLabel().charAt(0));
+                        break;
+                    case TCKind._tk_boolean:
+                        member.label.insert_boolean(Boolean.parseBoolean(cs.getLabel()));
+                        break;
+                    default:
+                        // TODO: Throw exception since this is an unsupported discriminator
type
+                    }
+                    // Yoko orb is strict on how the case labels are stored for each member.
 So we can't
+                    // simply insert the labels as strings 
+                    members.put(cs.getLabel(), member);
                 }
-                // Yoko orb is strict on how the case labels are stored for each member.
 So we can't
-                // simply insert the labels as strings 
-                members.put(cs.getLabel(), member);
             }
         }
         return orb.create_union_tc(unionType.getRepositoryID(), 
-                                   unionType.getName(), 
+                                   getTypeCodeName(unionType.getName()), 
                                    discTC, 
                                    (UnionMember[])members.values().toArray(new UnionMember[members.size()]));
+    }
+
+    public static String getTypeCodeName(String name) {
+        int pos = name.indexOf(".");
+        while (pos != -1) {
+            name = name.substring(pos + 1);
+            pos = name.indexOf(".");
+        }
+        return name;
     }
 
     public static boolean isPrimitiveIdlType(QName idltype) {

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=516437&r1=516436&r2=516437
==============================================================================
--- 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
Fri Mar  9 07:44:14 2007
@@ -115,10 +115,6 @@
     public void testWchar() { }
     public void testOctet () { }
     public void testAny () { }
-    public void testString() { }
     public void testWstring() { }
-    public void testStruct() { }
-    public void testUnion() { }
-    public void testEnum() { }
-    
+    public void testUnion() { }    
 }



Mime
View raw message