Search in sources :

Example 6 with Anonarray

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;
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) TypeCode(org.omg.CORBA.TypeCode) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 7 with Anonarray

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());
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) QName(javax.xml.namespace.QName) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 8 with Anonarray

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();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Array(org.apache.cxf.binding.corba.wsdl.Array) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) File(java.io.File) Test(org.junit.Test)

Aggregations

Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)8 Array (org.apache.cxf.binding.corba.wsdl.Array)6 QName (javax.xml.namespace.QName)5 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)4 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Definition (javax.wsdl.Definition)1 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)1 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)1 Const (org.apache.cxf.binding.corba.wsdl.Const)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)1 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)1 Union (org.apache.cxf.binding.corba.wsdl.Union)1 IdlAnonArray (org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray)1