Search in sources :

Example 1 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler in project cxf by apache.

the class CorbaConduitTest method testBuildReturn.

@Test
public void testBuildReturn() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    Exchange exchange = new ExchangeImpl();
    exchange.put(Bus.class, bus);
    message.setExchange(exchange);
    QName objName = new QName("returnName");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = message.createStreamableObject(obj1, objName);
    CorbaConduit conduit = setupCorbaConduit(false);
    NamedValue ret = conduit.getReturn(message);
    assertNotNull("Return should not be null", ret != null);
    assertEquals("name should be equal", ret.name(), "return");
    message.setStreamableReturn(arg);
    NamedValue ret2 = conduit.getReturn(message);
    assertNotNull("Return2 should not be null", ret2 != null);
    assertEquals("name should be equal", ret2.name(), "returnName");
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NamedValue(org.omg.CORBA.NamedValue) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 2 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler in project cxf by apache.

the class CorbaConduitTest method testBuildArguments.

@Test
public void testBuildArguments() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    Exchange exchange = new ExchangeImpl();
    exchange.put(Bus.class, bus);
    message.setExchange(exchange);
    CorbaStreamable[] arguments = new CorbaStreamable[1];
    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 obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = message.createStreamableObject(obj1, objName);
    arguments[0] = arg;
    arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
    CorbaConduit conduit = setupCorbaConduit(false);
    NVList list = conduit.getArguments(message);
    assertNotNull("list should not be null", list != null);
    message.setStreamableArguments(arguments);
    NVList listArgs = conduit.getArguments(message);
    assertNotNull("listArgs should not be null", listArgs != null);
    assertNotNull("listArgs Item should not be null", listArgs.item(0) != null);
    assertEquals("Name should be equal", listArgs.item(0).name(), "object");
    assertEquals("flags should be 2", listArgs.item(0).flags(), 2);
    assertNotNull("Any Value should not be null", listArgs.item(0).value() != null);
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NVList(org.omg.CORBA.NVList) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 3 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler in project cxf by apache.

the class CorbaObjectReaderTest method testReadStruct.

@Test
public void testReadStruct() {
    OutputStream oStream = orb.create_output_stream();
    // create the following struct
    // struct TestStruct {
    // long member1;
    // string member2;
    // boolean member3;
    // }
    int member1 = 12345;
    String member2 = "54321";
    boolean member3 = true;
    oStream.write_long(member1);
    oStream.write_string(member2);
    oStream.write_boolean(member3);
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA);
    QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
    QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
    Struct structType = new Struct();
    structType.setName("TestStruct");
    MemberType m1 = new MemberType();
    m1.setIdltype(longIdlType);
    m1.setName("member1");
    MemberType m2 = new MemberType();
    m2.setIdltype(stringIdlType);
    m2.setName("member2");
    MemberType m3 = new MemberType();
    m3.setIdltype(boolIdlType);
    m3.setName("member3");
    structType.getMember().add(m1);
    structType.getMember().add(m2);
    structType.getMember().add(m3);
    // build the object holder
    StructMember[] structMembers = new StructMember[3];
    structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null);
    structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null);
    structMembers[2] = new StructMember("member3", orb.get_primitive_tc(TCKind.tk_boolean), null);
    TypeCode structTC = orb.create_struct_tc("IDL:org.apache.cxf.TestStruct/1.0", "TestStruct", structMembers);
    CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType, structTC, structType);
    obj.addMember(new CorbaPrimitiveHandler(new QName("member1"), longIdlType, structMembers[0].type, null));
    obj.addMember(new CorbaPrimitiveHandler(new QName("member2"), stringIdlType, structMembers[1].type, null));
    obj.addMember(new CorbaPrimitiveHandler(new QName("member3"), boolIdlType, structMembers[2].type, null));
    reader.readStruct(obj);
    List<CorbaObjectHandler> nestedObjs = obj.getMembers();
    assertTrue(Integer.parseInt(((CorbaPrimitiveHandler) nestedObjs.get(0)).getDataFromValue()) == member1);
    assertEquals(((CorbaPrimitiveHandler) nestedObjs.get(1)).getDataFromValue(), member2);
    assertTrue(Boolean.parseBoolean(((CorbaPrimitiveHandler) nestedObjs.get(2)).getDataFromValue()) == member3);
}
Also used : TypeCode(org.omg.CORBA.TypeCode) InputStream(org.omg.CORBA.portable.InputStream) QName(javax.xml.namespace.QName) OutputStream(org.omg.CORBA.portable.OutputStream) CorbaStructHandler(org.apache.cxf.binding.corba.types.CorbaStructHandler) StructMember(org.omg.CORBA.StructMember) Struct(org.apache.cxf.binding.corba.wsdl.Struct) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) Test(org.junit.Test)

Example 4 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler in project cxf by apache.

the class CorbaObjectReaderTest method testReadArray.

// need to add tests for arrays, sequences, struct, exceptions
@Test
public void testReadArray() {
    int[] data = { 1, 1, 2, 3, 5, 8, 13, 21 };
    OutputStream oStream = orb.create_output_stream();
    oStream.write_long_array(data, 0, data.length);
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    // create an array of longs
    QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
    QName arrayIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "array", CorbaConstants.NP_WSDL_CORBA);
    Array arrayType = new Array();
    arrayType.setBound(data.length);
    arrayType.setElemtype(longIdlType);
    // name and respoitory ID of the array are not needed for this test
    // build the object holder for an array.
    TypeCode arrayTC = orb.create_array_tc(data.length, orb.get_primitive_tc(TCKind.tk_long));
    CorbaArrayHandler obj = new CorbaArrayHandler(new QName("Array"), arrayIdlType, arrayTC, arrayType);
    for (int i = 0; i < data.length; ++i) {
        CorbaObjectHandler nestedObj = new CorbaPrimitiveHandler(new QName("item"), longIdlType, orb.get_primitive_tc(TCKind.tk_long), null);
        obj.addElement(nestedObj);
    }
    reader.readArray(obj);
    int length = obj.getElements().size();
    for (int i = 0; i < length; ++i) {
        assertTrue(Integer.parseInt(((CorbaPrimitiveHandler) obj.getElement(i)).getDataFromValue()) == data[i]);
    }
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) InputStream(org.omg.CORBA.portable.InputStream) QName(javax.xml.namespace.QName) OutputStream(org.omg.CORBA.portable.OutputStream) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) CorbaArrayHandler(org.apache.cxf.binding.corba.types.CorbaArrayHandler) Test(org.junit.Test)

Example 5 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler in project cxf by apache.

the class CorbaObjectReaderTest method testReadException.

@Test
public void testReadException() {
    OutputStream oStream = orb.create_output_stream();
    // create the following exception
    // exception TestExcept {
    // short code;
    // string message;
    // }
    short code = 12345;
    String message = "54321";
    oStream.write_string("IDL:org.apache.cxf.TestException/1.0");
    oStream.write_short(code);
    oStream.write_string(message);
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    QName exceptIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "exception", CorbaConstants.NP_WSDL_CORBA);
    QName shortIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    Exception exceptType = new Exception();
    exceptType.setName("TestException");
    MemberType m1 = new MemberType();
    m1.setIdltype(shortIdlType);
    m1.setName("code");
    MemberType m2 = new MemberType();
    m2.setIdltype(stringIdlType);
    m2.setName("message");
    exceptType.getMember().add(m1);
    exceptType.getMember().add(m2);
    // build the object holder
    StructMember[] exceptMembers = new StructMember[2];
    exceptMembers[0] = new StructMember("code", orb.get_primitive_tc(TCKind.tk_short), null);
    exceptMembers[1] = new StructMember("message", orb.get_primitive_tc(TCKind.tk_string), null);
    TypeCode exceptTC = orb.create_exception_tc("IDL:org.apache.cxf.TestException/1.0", "TestException", exceptMembers);
    CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType, exceptTC, exceptType);
    obj.addMember(new CorbaPrimitiveHandler(new QName("code"), shortIdlType, exceptMembers[0].type, null));
    obj.addMember(new CorbaPrimitiveHandler(new QName("message"), stringIdlType, exceptMembers[1].type, null));
    reader.readException(obj);
    List<CorbaObjectHandler> nestedObjs = obj.getMembers();
    assertTrue(Short.parseShort(((CorbaPrimitiveHandler) nestedObjs.get(0)).getDataFromValue()) == code);
    assertEquals(((CorbaPrimitiveHandler) nestedObjs.get(1)).getDataFromValue(), message);
}
Also used : TypeCode(org.omg.CORBA.TypeCode) InputStream(org.omg.CORBA.portable.InputStream) QName(javax.xml.namespace.QName) OutputStream(org.omg.CORBA.portable.OutputStream) StructMember(org.omg.CORBA.StructMember) Exception(org.apache.cxf.binding.corba.wsdl.Exception) IOException(java.io.IOException) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) CorbaExceptionHandler(org.apache.cxf.binding.corba.types.CorbaExceptionHandler) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) CorbaObjectHandler(org.apache.cxf.binding.corba.types.CorbaObjectHandler) Test(org.junit.Test)

Aggregations

QName (javax.xml.namespace.QName)18 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 Test (org.junit.Test)18 TypeCode (org.omg.CORBA.TypeCode)18 InputStream (org.omg.CORBA.portable.InputStream)10 OutputStream (org.omg.CORBA.portable.OutputStream)10 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)4 Exchange (org.apache.cxf.message.Exchange)4 NVList (org.omg.CORBA.NVList)4 StructMember (org.omg.CORBA.StructMember)4 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)3 Message (org.apache.cxf.message.Message)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 IOException (java.io.IOException)2 CorbaStreamableImpl (org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl)2 CorbaArrayHandler (org.apache.cxf.binding.corba.types.CorbaArrayHandler)2 CorbaExceptionHandler (org.apache.cxf.binding.corba.types.CorbaExceptionHandler)2 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)2 CorbaStructHandler (org.apache.cxf.binding.corba.types.CorbaStructHandler)2