Search in sources :

Example 6 with Anonstring

use of org.apache.cxf.binding.corba.wsdl.Anonstring 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();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) File(java.io.File) Test(org.junit.Test)

Example 7 with Anonstring

use of org.apache.cxf.binding.corba.wsdl.Anonstring 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();
    }
}
Also used : WSDLToIDLAction(org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction) Element(org.w3c.dom.Element) Definition(javax.wsdl.Definition) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Document(org.w3c.dom.Document) Union(org.apache.cxf.binding.corba.wsdl.Union) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) File(java.io.File) Test(org.junit.Test)

Aggregations

Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)7 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)3 File (java.io.File)2 Definition (javax.wsdl.Definition)2 QName (javax.xml.namespace.QName)2 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)2 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)2 XmlSchemaMaxLengthFacet (org.apache.ws.commons.schema.XmlSchemaMaxLengthFacet)2 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)2 XmlSchemaSimpleTypeRestriction (org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction)2 Test (org.junit.Test)2 Document (org.w3c.dom.Document)2 Element (org.w3c.dom.Element)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)1 Union (org.apache.cxf.binding.corba.wsdl.Union)1