Search in sources :

Example 16 with Union

use of org.apache.cxf.binding.corba.wsdl.Union in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testTypeInheritance.

// tests Type Inheritance and attributes.
@Test
public void testTypeInheritance() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/TypeInheritance.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("TypeInheritancePortType");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(3, typemap.getElementsByTagName("corba:union").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:anonstring").getLength());
        assertEquals(17, typemap.getElementsByTagName("corba:struct").getLength());
        TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("TypeInheritanceCORBABinding");
        idlgen.setOutputFile("typeInherit.idl");
        idlgen.generateIDL(model);
        List<CorbaType> types = mapType.getStructOrExceptionOrUnion();
        for (int i = 0; i < types.size(); i++) {
            CorbaType type = types.get(i);
            if ("Type5SequenceStruct".equals(type.getName())) {
                assertTrue("Name is incorrect for Type5SequenceStruct Type", type instanceof Struct);
                assertEquals("Type is incorrect for AnonSequence Type", "Type5", type.getType().getLocalPart());
            } else if ("attrib2Type".equals(type.getName())) {
                assertTrue("Name is incorrect for attrib2Type Type", type instanceof Anonstring);
                assertEquals("Type is incorrect for AnonString Type", "string", type.getType().getLocalPart());
            } else if ("attrib2Type_nil".equals(type.getName())) {
                assertTrue("Name is incorrect for Struct Type", type instanceof Union);
                assertEquals("Type is incorrect for AnonSequence Type", "attrib2", type.getType().getLocalPart());
            }
        }
        File f = new File("typeInherit.idl");
        assertTrue("typeInherit.idl should be generated", f.exists());
    } finally {
        new File("typeInherit.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Union(org.apache.cxf.binding.corba.wsdl.Union) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) File(java.io.File) Test(org.junit.Test)

Aggregations

Union (org.apache.cxf.binding.corba.wsdl.Union)16 QName (javax.xml.namespace.QName)8 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)6 Unionbranch (org.apache.cxf.binding.corba.wsdl.Unionbranch)6 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 File (java.io.File)3 Definition (javax.wsdl.Definition)3 CaseType (org.apache.cxf.binding.corba.wsdl.CaseType)3 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)3 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)3 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)2 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2 Array (org.apache.cxf.binding.corba.wsdl.Array)2 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)2