use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.
the class WSDLToCorbaBindingTest method testAllType.
@Test
public void testAllType() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/alltype.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("BasePortType");
Definition model = generator.generateCORBABinding();
Document document = writer.getDocument(model);
Element typemap = getElementNode(document, "corba:typeMapping");
// assertNotNull(typemap);
assertEquals(1, typemap.getElementsByTagName("corba:struct").getLength());
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("BaseCORBABinding");
idlgen.setOutputFile("alltype.idl");
idlgen.generateIDL(model);
File f = new File("alltype.idl");
assertTrue("alltype.idl should be generated", f.exists());
} finally {
new File("alltype.idl").deleteOnExit();
}
}
use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.
the class WSDLToCorbaBindingTest method testSimpleListIdl.
@Test
public void testSimpleListIdl() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/simpleList.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("BasePortType");
generator.mapBindingToInterface("BasePortType", "SimpleListCORBABinding");
Definition model = generator.generateCORBABinding();
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("SimpleListCORBABinding");
idlgen.setOutputFile("simplelist.idl");
idlgen.generateIDL(model);
File f = new File("simplelist.idl");
assertTrue("simplelist.idl should be generated", f.exists());
} finally {
new File("simplelist.idl").deleteOnExit();
}
}
use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testAnyType.
@Test
public void testAnyType() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/any.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("anyInterface");
Definition model = generator.generateCORBABinding();
TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
assertEquals(5, mapType.getStructOrExceptionOrUnion().size());
int strcnt = 0;
int unioncnt = 0;
for (CorbaType corbaType : mapType.getStructOrExceptionOrUnion()) {
if (corbaType instanceof Struct) {
strcnt++;
}
if (corbaType instanceof Union) {
unioncnt++;
}
}
assertNotNull(mapType);
assertEquals(3, strcnt);
assertEquals(2, unioncnt);
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("anyInterfaceCORBABinding");
idlgen.setOutputFile("any.idl");
idlgen.generateIDL(model);
File f = new File("any.idl");
assertTrue("any.idl should be generated", f.exists());
} finally {
new File("any.idl").deleteOnExit();
}
}
use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testDateTimeTypes.
@Test
public void testDateTimeTypes() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/datetime.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("BasePortType");
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(2, typemap.getElementsByTagName("corba:struct").getLength());
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("BaseCORBABinding");
idlgen.setOutputFile("datetime.idl");
idlgen.generateIDL(model);
File f = new File("datetime.idl");
assertTrue("datetime.idl should be generated", f.exists());
} finally {
new File("datetime.idl").deleteOnExit();
}
}
use of org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testAnonFixedType.
// tests anonymous strings and fixed types.
@Test
public void testAnonFixedType() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/anonfixed.wsdl").toString();
generator.setWsdlFile(fileName);
generator.addInterfaceName("X");
Definition model = generator.generateCORBABinding();
Document document = writer.getDocument(model);
Element typemap = getElementNode(document, "corba:typeMapping");
assertNotNull(typemap);
assertEquals(1, typemap.getElementsByTagName("corba:anonfixed").getLength());
assertEquals(1, typemap.getElementsByTagName("corba:anonstring").getLength());
assertEquals(3, typemap.getElementsByTagName("corba:struct").getLength());
TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("XCORBABinding");
idlgen.setOutputFile("atype.idl");
idlgen.generateIDL(model);
List<CorbaType> types = mapType.getStructOrExceptionOrUnion();
for (int i = 0; i < types.size(); i++) {
CorbaType type = types.get(i);
if (type instanceof Anonstring) {
Anonstring str = (Anonstring) type;
assertEquals("Name is incorrect for Array Type", "X._1_S", str.getName());
assertEquals("Type is incorrect for AnonString Type", "string", str.getType().getLocalPart());
} else if (type instanceof Anonfixed) {
Anonfixed fx = (Anonfixed) type;
assertEquals("Name is incorrect for Anon Array Type", "X._2_S", fx.getName());
assertEquals("Type is incorrect for AnonFixed Type", "decimal", fx.getType().getLocalPart());
} else if (type instanceof Struct) {
Struct struct = (Struct) type;
String[] testResult;
if ("X.op_a".equals(struct.getName())) {
testResult = new String[] { "X.op_a", "X.op_a", "p1", "X.S", "p2", "X.S" };
} else if ("X.op_aResult".equals(struct.getName())) {
testResult = new String[] { "X.op_aResult", "X.op_aResult", "return", "X.S", "p2", "X.S" };
} else {
testResult = new String[] { "X.S", "X.S", "str", "X._1_S", "fx", "X._2_S" };
}
assertEquals("Name is incorrect for Anon Array Type", testResult[0], struct.getName());
assertEquals("Type is incorrect for Struct Type", testResult[1], struct.getType().getLocalPart());
assertEquals("Name for first Struct Member Type is incorrect", testResult[2], struct.getMember().get(0).getName());
assertEquals("Idltype for first Struct Member Type is incorrect", testResult[3], struct.getMember().get(0).getIdltype().getLocalPart());
assertEquals("Name for second Struct Member Type is incorrect", testResult[4], struct.getMember().get(1).getName());
assertEquals("Idltype for second Struct Member Type is incorrect", testResult[5], struct.getMember().get(1).getIdltype().getLocalPart());
} else {
// System.err.println("Type: " + i + " " + type.getClass().getName());
}
}
File f = new File("atype.idl");
assertTrue("atype.idl should be generated", f.exists());
} finally {
new File("atype.idl").deleteOnExit();
}
}
Aggregations