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);
}
}
}
}
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());
}
}
}
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);
}
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());
}
}
}
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());
}
}
}
Aggregations