Search in sources :

Example 21 with WSDLToIDLAction

use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.

the class WSDLToCorbaBindingTypeTest method testWsAddressingAccountType.

@Test
public void testWsAddressingAccountType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/wsaddressing_bank.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Bank");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(1, DOMUtils.findAllElementsByTagNameNS(typemap, "http://cxf.apache.org/bindings/corba", "sequence").size());
        assertEquals(2, DOMUtils.findAllElementsByTagNameNS(typemap, "http://cxf.apache.org/bindings/corba", "object").size());
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("BankCORBABinding");
        idlgen.setOutputFile("wsaddressing_bank.idl");
        idlgen.generateIDL(model);
        File f = new File("wsaddressing_bank.idl");
        assertTrue("wsaddressing_bank.idl should be generated", f.exists());
    } finally {
        new File("wsaddressing_bank.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Example 22 with WSDLToIDLAction

use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction 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

WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)22 File (java.io.File)21 Definition (javax.wsdl.Definition)21 Test (org.junit.Test)21 Document (org.w3c.dom.Document)16 Element (org.w3c.dom.Element)16 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)6 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)6 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)3 Union (org.apache.cxf.binding.corba.wsdl.Union)3 Binding (javax.wsdl.Binding)2 BindingOperation (javax.wsdl.BindingOperation)2 QName (javax.xml.namespace.QName)2 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)2 BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)2 OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)2 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)2 WSDLToCorbaBinding (org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1