Search in sources :

Example 26 with OperationType

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

the class WSDLToCorbaBindingTest method testExceptionCORBABindingGeneration.

// next story to add Fault support
@Test
public void testExceptionCORBABindingGeneration() throws Exception {
    String fileName = getClass().getResource("/wsdl/exceptions.wsdl").toString();
    generator.setWsdlFile(fileName);
    generator.addInterfaceName("TestException.ExceptionTest");
    Definition model = generator.generateCORBABinding();
    QName bName = new QName("http://schemas.apache.org/idl/exceptions.idl", "TestException.ExceptionTestCORBABinding", "tns");
    Binding binding = model.getBinding(bName);
    assertNotNull(binding);
    assertEquals("TestException.ExceptionTestCORBABinding", binding.getQName().getLocalPart());
    assertEquals("TestException.ExceptionTest", 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:TestException/ExceptionTest:1.0");
        }
    }
    Iterator<?> j = binding.getBindingOperations().iterator();
    while (j.hasNext()) {
        BindingOperation bindingOperation = (BindingOperation) j.next();
        assertEquals(1, bindingOperation.getExtensibilityElements().size());
        assertEquals(bindingOperation.getBindingInput().getName(), "review_data");
        assertEquals(bindingOperation.getBindingOutput().getName(), "review_dataResponse");
        Iterator<?> f = bindingOperation.getBindingFaults().values().iterator();
        boolean hasBadRecord = false;
        boolean hasMyException = false;
        while (f.hasNext()) {
            BindingFault bindingFault = (BindingFault) f.next();
            if ("TestException.BadRecord".equals(bindingFault.getName())) {
                hasBadRecord = true;
            } else if ("MyException".equals(bindingFault.getName())) {
                hasMyException = true;
            } else {
                fail("Unexpected BindingFault: " + bindingFault.getName());
            }
        }
        assertTrue("Did not get expected TestException.BadRecord", hasBadRecord);
        assertTrue("Did not get expected MyException", hasMyException);
        for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
            if ("operation".equals(extElement.getElementType().getLocalPart())) {
                OperationType corbaOpType = (OperationType) extElement;
                assertEquals(corbaOpType.getName(), "review_data");
                assertEquals(1, corbaOpType.getParam().size());
                assertEquals(2, corbaOpType.getRaises().size());
                hasBadRecord = false;
                hasMyException = false;
                for (int k = 0; k < corbaOpType.getRaises().size(); k++) {
                    String localPart = corbaOpType.getRaises().get(k).getException().getLocalPart();
                    if ("TestException.BadRecord".equals(localPart)) {
                        hasBadRecord = true;
                    } else if ("MyExceptionType".equals(localPart)) {
                        hasMyException = true;
                    } else {
                        fail("Unexpected Raises: " + localPart);
                    }
                }
                assertTrue("Did not find expected TestException.BadRecord", hasBadRecord);
                assertTrue("Did not find expected MyException", hasMyException);
            }
        }
    }
}
Also used : WSDLToCorbaBinding(org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding) Binding(javax.wsdl.Binding) BindingOperation(javax.wsdl.BindingOperation) BindingFault(javax.wsdl.BindingFault) 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) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Test(org.junit.Test)

Example 27 with OperationType

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

the class WSDLToCorbaBindingTest method checkFixedTypeFour.

private void checkFixedTypeFour(BindingOperation bindingOperation, Map<String, CorbaType> mapType) {
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType) extElement;
            assertEquals(corbaOpType.getName(), "extended_op_m");
            assertEquals(3, corbaOpType.getParam().size());
            assertEquals("EXTENDED.X.PARAM.H", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
            assertEquals("EXTENDED.X.PARAM.H", corbaOpType.getReturn().getIdltype().getLocalPart());
            Fixed fixed = (Fixed) mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
            assertNotNull("Could not find the decimal type", fixed.getType());
            assertEquals("Fixed digits is incorrect for the return corba parameter", 8, fixed.getDigits());
            assertEquals("Fixed scale is incorrect for the return corba parameter", 2, fixed.getScale());
        }
    }
}
Also used : OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed)

Example 28 with OperationType

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

the class WSDLToCorbaBinding method addCorbaOperationExtElement.

private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
    final OperationType operationType;
    try {
        operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException wse) {
        LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
        throw new Exception(LOG.toString(), wse);
    }
    operationType.setName(op.getName());
    List<ParamType> params = new ArrayList<>();
    List<ArgType> returns = new ArrayList<>();
    wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
    for (ParamType paramtype : params) {
        operationType.getParam().add(paramtype);
    }
    for (ArgType retType : returns) {
        operationType.setReturn(retType);
    }
    Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
    for (Fault fault : faults) {
        RaisesType raisestype = new RaisesType();
        CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
        if (extype != null) {
            raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
            operationType.getRaises().add(raisestype);
        }
    }
    bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) WSDLException(javax.wsdl.WSDLException) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 29 with OperationType

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

the class WSDLToCorbaBindingTest method testVoidTest.

private void testVoidTest(Binding binding) {
    BindingOperation bindingOp = binding.getBindingOperation("test_void", "test_void", "test_voidResponse");
    assertEquals("test_void", bindingOp.getName());
    assertEquals(1, bindingOp.getExtensibilityElements().size());
    assertEquals(bindingOp.getBindingInput().getName(), "test_void");
    assertEquals(bindingOp.getBindingOutput().getName(), "test_voidResponse");
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOp)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType) extElement;
            assertEquals(corbaOpType.getName(), "test_void");
            assertEquals(0, corbaOpType.getParam().size());
        }
    }
}
Also used : BindingOperation(javax.wsdl.BindingOperation) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Example 30 with OperationType

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

the class WSDLToCorbaBindingTest method checkSequenceType.

private void checkSequenceType(BindingOperation bindingOperation, Map<String, CorbaType> mapType) {
    for (ExtensibilityElement extElement : getExtensibilityElements(bindingOperation)) {
        if ("operation".equals(extElement.getElementType().getLocalPart())) {
            OperationType corbaOpType = (OperationType) extElement;
            assertEquals(corbaOpType.getName(), "op_h");
            assertEquals(3, corbaOpType.getParam().size());
            assertEquals("Y.H", corbaOpType.getParam().get(0).getIdltype().getLocalPart());
            assertEquals("Y.H", corbaOpType.getReturn().getIdltype().getLocalPart());
            Sequence seq = (Sequence) mapType.get(corbaOpType.getReturn().getIdltype().getLocalPart());
            assertEquals("ElementType is incorrect for Sequence Type", "fixed_1", seq.getElemtype().getLocalPart());
        }
    }
}
Also used : OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) ExtensibilityElement(javax.wsdl.extensions.ExtensibilityElement)

Aggregations

OperationType (org.apache.cxf.binding.corba.wsdl.OperationType)31 ExtensibilityElement (javax.wsdl.extensions.ExtensibilityElement)14 BindingOperation (javax.wsdl.BindingOperation)11 QName (javax.xml.namespace.QName)9 Test (org.junit.Test)9 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)8 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)8 ArgType (org.apache.cxf.binding.corba.wsdl.ArgType)6 BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)5 Binding (javax.wsdl.Binding)4 Definition (javax.wsdl.Definition)4 CorbaStreamWriter (org.apache.cxf.binding.corba.runtime.CorbaStreamWriter)4 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)4 Exchange (org.apache.cxf.message.Exchange)4 WSDLToCorbaBinding (org.apache.cxf.tools.corba.processors.wsdl.WSDLToCorbaBinding)4 ArrayList (java.util.ArrayList)3 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)3 RaisesType (org.apache.cxf.binding.corba.wsdl.RaisesType)3 File (java.io.File)2 OutputStream (java.io.OutputStream)2