Search in sources :

Example 1 with WSDLToIDLAction

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

the class WSDLToCorbaBindingTest method testComplexContentStructType.

@Test
public void testComplexContentStructType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/content.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("ContentPortType");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        // assertNotNull(typemap);
        assertEquals(1, typemap.getElementsByTagName("corba:union").getLength());
        assertEquals(6, typemap.getElementsByTagName("corba:struct").getLength());
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("ContentCORBABinding");
        idlgen.setOutputFile("content.idl");
        idlgen.generateIDL(model);
        File f = new File("content.idl");
        assertTrue("content.idl should be generated", f.exists());
    } finally {
        new File("content.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Example 2 with WSDLToIDLAction

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

the class WSDLToCorbaBindingTest method testUnionType.

@Test
public void testUnionType() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/uniontype.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Test.MultiPart");
        Definition model = generator.generateCORBABinding();
        Document document = writer.getDocument(model);
        Element typemap = getElementNode(document, "corba:typeMapping");
        assertNotNull(typemap);
        assertEquals(1, typemap.getElementsByTagName("corba:union").getLength());
        assertEquals(1, typemap.getElementsByTagName("corba:enum").getLength());
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("Test.MultiPartCORBABinding");
        idlgen.setOutputFile("uniontype.idl");
        idlgen.generateIDL(model);
        File f = new File("uniontype.idl");
        assertTrue("uniontype.idl should be generated", f.exists());
    } finally {
        new File("uniontype.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) Document(org.w3c.dom.Document) File(java.io.File) Test(org.junit.Test)

Example 3 with WSDLToIDLAction

use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction 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 (extElement.getElementType().getLocalPart().equals("binding")) {
                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 (extElement.getElementType().getLocalPart().equals("operation")) {
                    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 (extElement.getElementType().getLocalPart().equals("typeMapping")) {
                    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 4 with WSDLToIDLAction

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

the class WSDLToCorbaBindingTest method testArrayMapping.

@Test
public void testArrayMapping() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/array.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 (extElement.getElementType().getLocalPart().equals("binding")) {
                BindingType bindingType = (BindingType) extElement;
                assertEquals(bindingType.getRepositoryID(), "IDL:X:1.0");
            }
        }
        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 (extElement.getElementType().getLocalPart().equals("operation")) {
                    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/", "ArrayType", "ns1");
                    assertEquals(paramtype.getIdltype(), idltype);
                    assertEquals(paramtype.getMode().toString(), "IN");
                }
            }
        }
        // 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) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) File(java.io.File) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType) Test(org.junit.Test)

Example 5 with WSDLToIDLAction

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

the class WSDLToCorbaBindingTest method testMulitPartIdl.

@Test
public void testMulitPartIdl() throws Exception {
    try {
        String fileName = getClass().getResource("/wsdl/multipart.wsdl").toString();
        generator.setWsdlFile(fileName);
        generator.addInterfaceName("Test.MultiPart");
        generator.mapBindingToInterface("Test.MultiPart", "Test.MultiPartCORBABinding");
        Definition model = generator.generateCORBABinding();
        WSDLToIDLAction idlgen = new WSDLToIDLAction();
        idlgen.setBindingName("Test.MultiPartCORBABinding");
        idlgen.setOutputFile("multipart.idl");
        idlgen.generateIDL(model);
        File f = new File("multipart.idl");
        assertTrue("multipart.idl should be generated", f.exists());
    } finally {
        new File("multipart.idl").deleteOnExit();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Definition(javax.wsdl.Definition) 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