use of org.apache.cxf.binding.corba.wsdl.Anonarray in project cxf by apache.
the class CorbaUtils method getAnonTypeCode.
private static TypeCode getAnonTypeCode(ORB orb, QName type, Object obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
TypeCode tc = null;
if (obj instanceof Anonarray) {
Anonarray anonArrayType = (Anonarray) obj;
tc = orb.create_array_tc((int) anonArrayType.getBound(), getTypeCode(orb, anonArrayType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Anonfixed) {
Anonfixed anonFixedType = (Anonfixed) obj;
tc = orb.create_fixed_tc((short) anonFixedType.getDigits(), (short) anonFixedType.getScale());
} else if (obj instanceof Anonsequence) {
Anonsequence anonSeqType = (Anonsequence) obj;
tc = orb.create_sequence_tc((int) anonSeqType.getBound(), getTypeCode(orb, anonSeqType.getElemtype(), typeMap, seenTypes));
} else if (obj instanceof Anonstring) {
Anonstring anonStringType = (Anonstring) obj;
tc = orb.create_string_tc((int) anonStringType.getBound());
} else if (obj instanceof Anonwstring) {
Anonwstring anonWStringType = (Anonwstring) obj;
tc = orb.create_wstring_tc((int) anonWStringType.getBound());
}
return tc;
}
use of org.apache.cxf.binding.corba.wsdl.Anonarray in project cxf by apache.
the class WSDLToCorbaBindingTest method assertMixedArraysMappingEasyTypes.
/**
* @param typeMap
*/
private void assertMixedArraysMappingEasyTypes(CorbaTypeMap typeMap) {
Sequence p1 = (Sequence) typeMap.getType("p1-unwrapped-sequenceArray");
assertEquals(new QName("", "p1-unwrapped-sequence"), p1.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p1.getElemtype());
Sequence p1q = (Sequence) typeMap.getType("p1-unwrapped-sequence-qArray");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p1-unwrapped-sequence-q"), p1q.getElemname());
assertFalse(p1.isWrapped());
Sequence p2 = (Sequence) typeMap.getType("UnboundedArray");
assertEquals(new QName("", "item"), p2.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p2.getElemtype());
assertTrue(p2.isWrapped());
Array p3 = (Array) typeMap.getType("p3-unwrapped-arrayArray");
assertEquals(new QName("", "p3-unwrapped-array"), p3.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p3.getElemtype());
Array p3q = (Array) typeMap.getType("p3-unwrapped-array-qArray");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p3-unwrapped-array-q"), p3q.getElemname());
assertFalse(p3.isWrapped());
Array p4 = (Array) typeMap.getType("FixedArray");
assertEquals(new QName("", "item"), p4.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p4.getElemtype());
assertTrue(p4.isWrapped());
Sequence p5 = (Sequence) typeMap.getType("p5-anonymous-unwrapped-sequenceArray");
assertEquals(new QName("", "p5-anonymous-unwrapped-sequence"), p5.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p5.getElemtype());
Sequence p5q = (Sequence) typeMap.getType("p5-anonymous-unwrapped-sequence-qArray");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p5-anonymous-unwrapped-sequence-q"), p5q.getElemname());
assertFalse(p5.isWrapped());
Anonsequence p6 = (Anonsequence) typeMap.getType("MixedArrayType.p6-anonymous-wrapped-sequenceType");
assertEquals(new QName("", "item"), p6.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p6.getElemtype());
assertFalse(p6.isQualified());
assertTrue(p6.isWrapped());
Anonsequence p6q = (Anonsequence) typeMap.getType("MixedArrayType.p6-anonymous-wrapped-sequence-qType");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p6q.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p6q.getElemtype());
assertTrue(p6q.isQualified());
assertTrue(p6q.isWrapped());
Array p7 = (Array) typeMap.getType("p7-anonymous-unwrapped-arrayArray");
assertEquals(new QName("", "p7-anonymous-unwrapped-array"), p7.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p7.getElemtype());
assertFalse(p7.isQualified());
assertFalse(p7.isWrapped());
Array p7q = (Array) typeMap.getType("p7-anonymous-unwrapped-array-qArray");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p7-anonymous-unwrapped-array-q"), p7q.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p7q.getElemtype());
assertTrue(p7q.isQualified());
assertFalse(p7q.isWrapped());
Anonarray p8 = (Anonarray) typeMap.getType("MixedArrayType.p8-anonymous-wrapped-arrayType");
assertEquals(new QName("", "item"), p8.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p8.getElemtype());
assertFalse(p8.isQualified());
assertTrue(p8.isWrapped());
Anonarray p8q = (Anonarray) typeMap.getType("MixedArrayType.p8-anonymous-wrapped-array-qType");
assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p8q.getElemname());
assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p8q.getElemtype());
assertTrue(p8q.isQualified());
assertTrue(p8q.isWrapped());
}
use of org.apache.cxf.binding.corba.wsdl.Anonarray in project cxf by apache.
the class WSDLToCorbaBindingTypeTest method testAnonType.
// tests anonymous arrays and sequences
@Test
public void testAnonType() throws Exception {
try {
String fileName = getClass().getResource("/wsdl/atype.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(3, typemap.getElementsByTagName("corba:anonsequence").getLength());
assertEquals(2, typemap.getElementsByTagName("corba:anonarray").getLength());
assertEquals(1, typemap.getElementsByTagName("corba:array").getLength());
assertEquals(2, typemap.getElementsByTagName("corba:struct").getLength());
TypeMappingType mapType = (TypeMappingType) model.getExtensibilityElements().get(0);
Map<String, CorbaType> tmap = new HashMap<>();
for (CorbaType type : mapType.getStructOrExceptionOrUnion()) {
tmap.put(type.getName(), type);
}
WSDLToIDLAction idlgen = new WSDLToIDLAction();
idlgen.setBindingName("XCORBABinding");
idlgen.setOutputFile("atype.idl");
idlgen.generateIDL(model);
Array arr = (Array) tmap.get("X.A");
assertNotNull(arr);
assertEquals("ElementType is incorrect for Array Type", "X._5_A", arr.getElemtype().getLocalPart());
Anonarray arr2 = (Anonarray) tmap.get("X._5_A");
assertNotNull(arr2);
assertEquals("ElementType is incorrect for Anon Array Type", "X._4_A", arr2.getElemtype().getLocalPart());
Anonarray arr3 = (Anonarray) tmap.get("X._4_A");
assertNotNull(arr3);
assertEquals("ElementType is incorrect for Anon Array Type", "X._1_A", arr3.getElemtype().getLocalPart());
Anonsequence seq = (Anonsequence) tmap.get("X._1_A");
assertNotNull(seq);
assertEquals("ElementType is incorrect for Anon Sequence Type", "X._2_A", seq.getElemtype().getLocalPart());
Anonsequence seq2 = (Anonsequence) tmap.get("X._2_A");
assertNotNull(seq2);
assertEquals("ElementType is incorrect for Anon Sequence Type", "X._3_A", seq2.getElemtype().getLocalPart());
Anonsequence seq3 = (Anonsequence) tmap.get("X._3_A");
assertNotNull(seq3);
assertEquals("ElementType is incorrect for Anon Sequence Type", "long", seq3.getElemtype().getLocalPart());
File f = new File("atype.idl");
assertTrue("atype.idl should be generated", f.exists());
} finally {
new File("atype.idl").deleteOnExit();
}
}
Aggregations