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