use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testNillableType.
@Test
public void testNillableType() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/nillable.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("NillablePortType");
Definition model = generator.generateCORBABinding();
Document document = writer.getDocument(model);
Element typemap = getElementNode(document, "corba:typeMapping");
assertNotNull(typemap);
assertEquals(2, typemap.getElementsByTagName("corba:union").getLength());
assertEquals(1, typemap.getElementsByTagName("corba:struct").getLength());
TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("NillableCORBABinding");
idlgen.setOutputFile("nillable.idl");
idlgen.generateIDL(model);
Union un = (Union) mapType.getStructOrExceptionOrUnion().get(2);
assertEquals("Name is incorrect for Union Type", "long_nil", un.getName());
assertEquals("Type is incorrect for Union Type", "PEl", un.getType().getLocalPart());
Unionbranch unbranch = un.getUnionbranch().get(0);
assertEquals("Name is incorrect for UnionBranch Type", "value", unbranch.getName());
assertEquals("Type is incorrect for UnionBranch Type", "long", unbranch.getIdltype().getLocalPart());
File f = new File("nillable.idl");
assertTrue("nillable.idl should be generated", f.exists());
} finally {
new File("nillable.idl").deleteOnExit();
}
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType 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);
}
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType 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 ("binding".equals(extElement.getElementType().getLocalPart())) {
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 ("operation".equals(extElement.getElementType().getLocalPart())) {
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 ("typeMapping".equals(extElement.getElementType().getLocalPart())) {
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();
}
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType in project cxf by apache.
the class WSDLSchemaManager method createCorbaTypeMap.
public TypeMappingType createCorbaTypeMap(Definition definition, String corbatypemaptns) throws WSDLException {
TypeMappingType typeMap = (TypeMappingType) definition.getExtensionRegistry().createExtension(Definition.class, CorbaConstants.NE_CORBA_TYPEMAPPING);
if (corbatypemaptns == null) {
typeMap.setTargetNamespace(definition.getTargetNamespace() + "/" + CorbaConstants.NS_CORBA_TYPEMAP);
} else {
typeMap.setTargetNamespace(corbatypemaptns);
}
definition.addExtensibilityElement((ExtensibilityElement) typeMap);
return typeMap;
}
use of org.apache.cxf.binding.corba.wsdl.TypeMappingType 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();
}
}
Aggregations