Search in sources :

Example 96 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToIDLTest method testBindingGenDefault.

@Test
public void testBindingGenDefault() throws Exception {
    String[] cmdArgs = { "-corba", "-i", "BasePortType", "-d", output.getRoot().toString(), getClass().getResource("/wsdl/simpleList.wsdl").toString() };
    String error = execute(cmdArgs);
    assertNull("WSDLToIDL Failed", error);
    File f = new File(output.getRoot(), "simpleList-corba.wsdl");
    assertTrue("simpleList-corba.wsdl should be generated", f.exists());
    WSDLToProcessor proc = new WSDLToProcessor();
    try {
        proc.parseWSDL(f.getAbsolutePath());
        Definition model = proc.getWSDLDefinition();
        assertNotNull("WSDL Definition Should not be Null", model);
        QName bindingName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding");
        assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName));
    } catch (Exception e) {
        fail("WSDLToCORBA generated an invalid simpleList-corba.wsdl");
    }
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) WSDLToProcessor(org.apache.cxf.tools.corba.processors.wsdl.WSDLToProcessor) File(java.io.File) Test(org.junit.Test)

Example 97 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToIDLTest method testBindingGenSpecifiedFile.

@Test
public void testBindingGenSpecifiedFile() throws Exception {
    String[] cmdArgs = { "-corba", "-i", "BasePortType", "-w", "simpleList-corba_gen.wsdl", "-d", output.getRoot().toString(), getClass().getResource("/wsdl/simpleList.wsdl").toString() };
    String error = execute(cmdArgs);
    assertNull("WSDLToIDL Failed", error);
    File f = new File(output.getRoot(), "simpleList-corba_gen.wsdl");
    assertTrue("simpleList-corba_gen.wsdl should be generated", f.exists());
    WSDLToProcessor proc = new WSDLToProcessor();
    try {
        proc.parseWSDL(f.toString());
        Definition model = proc.getWSDLDefinition();
        assertNotNull("WSDL Definition Should not be Null", model);
        QName bindingName = new QName("http://schemas.apache.org/tests", "BaseCORBABinding");
        assertNotNull("Binding Node not found in WSDL", model.getBinding(bindingName));
    } catch (Exception e) {
        fail("WSDLToIDL generated an invalid simpleList-corba.wsdl");
    }
}
Also used : QName(javax.xml.namespace.QName) Definition(javax.wsdl.Definition) WSDLToProcessor(org.apache.cxf.tools.corba.processors.wsdl.WSDLToProcessor) File(java.io.File) Test(org.junit.Test)

Example 98 with Definition

use of javax.wsdl.Definition 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 99 with Definition

use of javax.wsdl.Definition 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 100 with Definition

use of javax.wsdl.Definition in project cxf by apache.

the class WSDLToCorbaBindingTest method testMultipartCORBABindingGeneration.

@Test
public void testMultipartCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/multipart.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("Test.MultiPart");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/tests", "Test.MultiPartCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("Test.MultiPartCORBABinding", binding.getQName().getLocalPart());
    assertEquals("Test.MultiPart", binding.getPortType().getQName().getLocalPart());
    assertEquals(1, binding.getExtensibilityElements().size());
    assertEquals(32, binding.getBindingOperations().size());
    List<ExtensibilityElement> extElements = getExtensibilityElements(binding);
    ExtensibilityElement extElement = extElements.get(0);
    if ("binding".equals(extElement.getElementType().getLocalPart())) {
        BindingType bindingType = (BindingType) extElement;
        assertEquals(bindingType.getRepositoryID(), "IDL:Test/MultiPart:1.0");
    }
    getStringAttributeTest(binding);
    getTestIdTest(binding);
    setTestIdTest(binding);
    testVoidTest(binding);
    testPrimitiveTypeTest(binding, "test_short", CorbaConstants.NT_CORBA_SHORT);
    testPrimitiveTypeTest(binding, "test_long", CorbaConstants.NT_CORBA_LONG);
    testPrimitiveTypeTest(binding, "test_longlong", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_ushort", CorbaConstants.NT_CORBA_USHORT);
    testPrimitiveTypeTest(binding, "test_ulong", CorbaConstants.NT_CORBA_ULONG);
    testPrimitiveTypeTest(binding, "test_ulonglong", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_float", CorbaConstants.NT_CORBA_FLOAT);
    testPrimitiveTypeTest(binding, "test_double", CorbaConstants.NT_CORBA_DOUBLE);
    testPrimitiveTypeTest(binding, "test_octet", CorbaConstants.NT_CORBA_OCTET);
    testPrimitiveTypeTest(binding, "test_boolean", CorbaConstants.NT_CORBA_BOOLEAN);
    testPrimitiveTypeTest(binding, "test_char", CorbaConstants.NT_CORBA_CHAR);
    testPrimitiveTypeTest(binding, "test_integer", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_nonNegativeInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_positiveInteger", CorbaConstants.NT_CORBA_ULONGLONG);
    testPrimitiveTypeTest(binding, "test_negativeInteger", CorbaConstants.NT_CORBA_LONGLONG);
    testPrimitiveTypeTest(binding, "test_normalizedString", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_token", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_language", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_Name", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_NCName", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_ID", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_anyURI", CorbaConstants.NT_CORBA_STRING);
    testPrimitiveTypeTest(binding, "test_nick_name", CorbaConstants.NT_CORBA_STRING);
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) Definition(javax.wsdl.Definition) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Aggregations

Definition (javax.wsdl.Definition)226 Test (org.junit.Test)113 QName (javax.xml.namespace.QName)61 File (java.io.File)52 Document (org.w3c.dom.Document)44 Element (org.w3c.dom.Element)40 HashMap (java.util.HashMap)36 WSDLReader (javax.wsdl.xml.WSDLReader)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)31 JBossWSTest (org.jboss.wsf.test.JBossWSTest)31 Service (javax.wsdl.Service)24 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)23 URL (java.net.URL)21 ArrayList (java.util.ArrayList)21 Port (javax.wsdl.Port)21 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)21 Bus (org.apache.cxf.Bus)20 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)20 WSDLManager (org.apache.cxf.wsdl.WSDLManager)20 IOException (java.io.IOException)18