Search in sources :

Example 6 with TypeMappingType

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

the class WSDLToCorbaBindingTypeTest method testNillableType.

@Test
public void testNillableType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/nillable.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("NillablePortType");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(2, typemap.getElementsByTagName("corba:union").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:struct").getLength());
        TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("NillableCORBABinding");
        idlgen.setOutputFile("nillable.idl");
        idlgen.generateIDL(model);
        Union un = (Union) mapType.getStructOrExceptionOrUnion().get(2);
        assertEquals("Name is incorrect for Union Type", "long_nil", un.getName());
        assertEquals("Type is incorrect for Union Type", "PEl", un.getType().getLocalPart());
        Unionbranch unbranch = un.getUnionbranch().get(0);
        assertEquals("Name is incorrect for UnionBranch Type", "value", unbranch.getName());
        assertEquals("Type is incorrect for UnionBranch Type", "long", unbranch.getIdltype().getLocalPart());
        File f = new File("nillable.idl");
        assertTrue("nillable.idl should be generated", f.exists());
    } finally {
        new File("nillable.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) File(java.io.File) Union(org.apache.cxf.binding.corba.wsdl.Union) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch) Test(org.junit.Test)

Example 7 with TypeMappingType

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

the class WSDLToCorbaBindingTest method testFixedBindingGeneration.

@Test
public void testFixedBindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/fixed.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("Y");
    Definition model = generator.generateCORBABinding();
    Document document = writer.getDocument(model);
    Element typemap = getElementNode(document, "corba:typeMapping");
    assertEquals(1, typemap.getElementsByTagName("corba:sequence").getLength());
    assertEquals(5, typemap.getElementsByTagName("corba:fixed").getLength());
    Element bindingElement = getElementNode(document, "binding");
    assertEquals(5, bindingElement.getElementsByTagName("corba:operation").getLength());
    QName bName = new QName("http://schemas.apache.org/idl/fixed.idl", "YCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
    Map<String, CorbaType> tmap = new HashMap<>();
    for (CorbaType type : mapType.getStructOrExceptionOrUnion()) {
        tmap.put(type.getName(), type);
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals("YCORBABinding", binding.getQName().getLocalPart());
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        checkFixedTypeOne(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkSequenceType(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeTwo(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeThree(bindingOperation, tmap);
        bindingOperation = (BindingOperation) j.next();
        checkFixedTypeFour(bindingOperation, tmap);
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 8 with TypeMappingType

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

the class WSDLToCorbaBindingTest method testMixedArraysMapping.

@Test
public void testMixedArraysMapping() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/arrays-mixed.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("X");
        Definition model = generator.generateCORBABinding();
        QName bName = new QName("http://schemas.apache.org/idl/anon.idl", "XCORBABinding", "tns");
        Binding binding = model.getBinding(bName);
        assertNotNull(binding);
        assertEquals("XCORBABinding", binding.getQName().getLocalPart());
        assertEquals("X", binding.getPortType().getQName().getLocalPart());
        assertEquals(1, binding.getExtensibilityElements().size());
        assertEquals(1, binding.getBindingOperations().size());
        for (ExtensibilityElement extElement : getExtensibilityElements(binding)) {
            if ("binding".equals(extElement.getElementType().getLocalPart())) {
                BindingType bindingType = (BindingType) extElement;
                assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
            }
        }
        Iterator<?> tm = model.getExtensibilityElements().iterator();
        assertTrue(tm.hasNext());
        TypeMappingType tmt = (TypeMappingType) tm.next();
        CorbaTypeMap typeMap = CorbaUtils.createCorbaTypeMap(Arrays.asList(tmt));
        assertNull("All nested anonymous types should have \"nested\" names", typeMap.getType("item"));
        // Checkstyle forces me to split the method...
        assertMixedArraysMappingEasyTypes(typeMap);
        // elem types are no longer strings from now.
        assertMixedArraysMappingDifficultSequences(typeMap);
        assertMixedArraysMappingDifficultArrays(typeMap);
        Iterator<?> j = binding.getBindingOperations().iterator();
        while (j.hasNext()) {
            BindingOperation bindingOperation = (BindingOperation) j.next();
            assertEquals(1, bindingOperation.getExtensibilityElements().size());
            assertEquals(bindingOperation.getBindingInput().getName(), "op_a");
            assertEquals(bindingOperation.getBindingOutput().getName(), "op_aResponse");
            for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
                if ("operation".equals(extElement.getElementType().getLocalPart())) {
                    OperationType corbaOpType = (OperationType) extElement;
                    assertEquals(corbaOpType.getName(), "op_a");
                    assertEquals(1, corbaOpType.getParam().size());
                    assertNotNull(corbaOpType.getReturn());
                    ParamType paramtype = corbaOpType.getParam().get(0);
                    assertEquals(paramtype.getName(), "part1");
                    QName idltype = new QName("http://schemas.apache.org/idl/anon.idl/corba/typemap/", "MixedArrayType", "ns1");
                    assertEquals(paramtype.getIdltype(), idltype);
                    assertEquals(paramtype.getMode().toString(), "IN");
                } else if ("typeMapping".equals(extElement.getElementType().getLocalPart())) {
                    System.out.println("x");
                }
            }
        }
        // See if an IDL is able to produce from this CORBA Binding.
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("XCORBABinding");
        idlgen.setOutputFile("array.idl");
        idlgen.generateIDL(model);
        File f = new File("array.idl");
        assertTrue("array.idl should be generated", f.exists());
    } finally {
        new File("array.idl").deleteOnExit();
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) CorbaTypeMap(org.apache.cxf.binding.corba.CorbaTypeMap) QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) BindingOperation(javax.wsdl.BindingOperation) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) File(java.io.File) Test(org.junit.Test)

Example 9 with TypeMappingType

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

the class WSDLSchemaManager method createCorbaTypeMap.

public TypeMappingType createCorbaTypeMap(Definition definition, String corbatypemaptns) throws WSDLException {
    TypeMappingType typeMap = (TypeMappingType) definition.getExtensionRegistry().createExtension(Definition.class, CorbaConstants.NE_CORBA_TYPEMAPPING);
    if (corbatypemaptns == null) {
        typeMap.setTargetNamespace(definition.getTargetNamespace() + "/" + CorbaConstants.NS_CORBA_TYPEMAP);
    } else {
        typeMap.setTargetNamespace(corbatypemaptns);
    }
    definition.addExtensibilityElement((ExtensibilityElement) typeMap);
    return typeMap;
}
Also used : Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType)

Example 10 with TypeMappingType

use of org.apache.cxf.binding.corba.wsdl.TypeMappingType 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

TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)15 Definition (javax.wsdl.Definition)8 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)8 Test (org.junit.Test)8 QName (javax.xml.namespace.QName)7 File (java.io.File)6 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)6 Document (org.w3c.dom.Document)5 Element (org.w3c.dom.Element)5 XmlSchemaCollection (org.apache.ws.commons.schema.XmlSchemaCollection)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)3 Union (org.apache.cxf.binding.corba.wsdl.Union)3 XmlSchema (org.apache.ws.commons.schema.XmlSchema)3 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)3 HashMap (java.util.HashMap)2 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)2 CorbaTypeMap (org.apache.cxf.binding.corba.CorbaTypeMap)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2