Search in sources :

Example 16 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaStreamableTest method testReadStreamable.

@Test
public void testReadStreamable() {
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "char", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_char);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable streamable = new CorbaStreamableImpl(obj, objName);
    OutputStream oStream = orb.create_output_stream();
    oStream.write_char('c');
    InputStream iStream = oStream.create_input_stream();
    streamable._read(iStream);
    CorbaPrimitiveHandler streamableObj = (CorbaPrimitiveHandler) streamable.getObject();
    Object o = streamableObj.getValue();
    assertTrue(o instanceof Character);
    Character charValue = (Character) o;
    assertTrue(charValue.charValue() == 'c');
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) OutputStream(org.omg.CORBA.portable.OutputStream) Test(org.junit.Test)

Example 17 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaStreamableTest method testWriteStreamable.

@Test
public void testWriteStreamable() {
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "wstring", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_wstring);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    obj.setValueFromData("TestWString");
    CorbaStreamable streamable = new CorbaStreamableImpl(obj, objName);
    OutputStream oStream = orb.create_output_stream();
    streamable._write(oStream);
    InputStream iStream = oStream.create_input_stream();
    String value = iStream.read_wstring();
    assertEquals("TestWString", value);
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) OutputStream(org.omg.CORBA.portable.OutputStream) Test(org.junit.Test)

Example 18 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaStreamableTest method testCreateStreamable.

@Test
public void testCreateStreamable() {
    QName objName = new QName("object");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable streamable = new CorbaStreamableImpl(obj, objName);
    assertNotNull(streamable);
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 19 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaArrayHandlerTest method testArrayHandler.

@Test
public void testArrayHandler() {
    objName = new QName("object");
    objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "arrayType", CorbaConstants.NP_WSDL_CORBA);
    objTypeCode = orb.create_array_tc(5, orb.get_primitive_tc(TCKind.tk_long));
    Array arrayType = new Array();
    arrayType.setName("arrayType");
    arrayType.setElemtype(CorbaConstants.NT_CORBA_LONG);
    arrayType.setBound(5);
    arrayType.setRepositoryID("IDL:ArrayType:1.0");
    obj = new CorbaArrayHandler(objName, objIdlType, objTypeCode, arrayType);
    assertNotNull(obj);
    int[] arrayData = { 2, 4, 6, 8, 10 };
    for (int i = 0; i < arrayData.length; ++i) {
        QName elName = new QName("item");
        QName elIdlType = CorbaConstants.NT_CORBA_LONG;
        TypeCode elTC = orb.get_primitive_tc(TCKind.tk_long);
        CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
        el.setValue(Integer.valueOf(arrayData[i]));
        obj.addElement(el);
    }
    QName nameResult = obj.getName();
    assertNotNull(nameResult);
    assertTrue(objName.equals(nameResult));
    QName idlTypeResult = obj.getIdlType();
    assertNotNull(idlTypeResult);
    assertTrue(idlTypeResult.equals(objIdlType));
    TypeCode tcResult = obj.getTypeCode();
    assertNotNull(tcResult);
    assertTrue(tcResult.kind().value() == objTypeCode.kind().value());
    Object objDefResult = obj.getType();
    assertNotNull(objDefResult);
    assertTrue(objDefResult instanceof Array);
    int countResult = obj.getNumberOfElements();
    for (int i = 0; i < countResult; ++i) {
        CorbaObjectHandler elResult = obj.getElement(i);
        assertNotNull(elResult);
    }
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 20 with TypeCode

use of org.omg.CORBA.TypeCode in project cxf by apache.

the class CorbaEnumHandlerTest method testCorbaEnumHandler.

@Test
public void testCorbaEnumHandler() {
    Enum enumType = new Enum();
    enumType.setName("EnumType");
    enumType.setRepositoryID("IDL:EnumType:1.0");
    Enumerator enumerator0 = new Enumerator();
    enumerator0.setValue("ENUM0");
    Enumerator enumerator1 = new Enumerator();
    enumerator1.setValue("ENUM1");
    Enumerator enumerator2 = new Enumerator();
    enumerator2.setValue("ENUM2");
    enumType.getEnumerator().add(enumerator0);
    enumType.getEnumerator().add(enumerator1);
    enumType.getEnumerator().add(enumerator2);
    QName enumName = new QName("EnumType");
    QName enumIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "EnumType", CorbaConstants.NP_WSDL_CORBA);
    String[] members = new String[3];
    members[0] = enumerator0.getValue();
    members[1] = enumerator1.getValue();
    members[2] = enumerator2.getValue();
    TypeCode enumTC = orb.create_enum_tc(enumType.getRepositoryID(), enumType.getName(), members);
    CorbaEnumHandler obj = new CorbaEnumHandler(enumName, enumIdlType, enumTC, enumType);
    assertNotNull(obj);
    obj.setValue(members[1]);
    assertTrue(obj.getValue().equals(enumerator1.getValue()));
    assertTrue(obj.getIndex() == 1);
}
Also used : Enum(org.apache.cxf.binding.corba.wsdl.Enum) Enumerator(org.apache.cxf.binding.corba.wsdl.Enumerator) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Aggregations

TypeCode (org.omg.CORBA.TypeCode)69 QName (javax.xml.namespace.QName)49 Test (org.junit.Test)44 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 InputStream (org.omg.CORBA.portable.InputStream)15 OutputStream (org.omg.CORBA.portable.OutputStream)14 StructMember (org.omg.CORBA.StructMember)9 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)6 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)6 Any (org.omg.CORBA.Any)6 NVList (org.omg.CORBA.NVList)6 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4 Enum (org.apache.cxf.binding.corba.wsdl.Enum)4 Enumerator (org.apache.cxf.binding.corba.wsdl.Enumerator)4 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)4 Struct (org.apache.cxf.binding.corba.wsdl.Struct)4 IOException (java.io.IOException)3 Alias (org.apache.cxf.binding.corba.wsdl.Alias)3