Search in sources :

Example 6 with TypeCode

use of org.omg.CORBA.TypeCode 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);
    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 : 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) Test(org.junit.Test)

Example 7 with TypeCode

use of org.omg.CORBA.TypeCode 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);
    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 : 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) Test(org.junit.Test)

Example 8 with TypeCode

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

the class CorbaObjectReaderTest method testReadObjectReference.

@Test
public void testReadObjectReference() throws IOException {
    OutputStream oStream = orb.create_output_stream();
    URL refUrl = getClass().getResource("/references/account.ref");
    String oRef = IOUtils.toString(refUrl.openStream()).trim();
    org.omg.CORBA.Object objRef = orb.string_to_object(oRef);
    assertNotNull(objRef);
    oStream.write_Object(objRef);
    // we need an ORBinstance to handle reading objects so use the input stream
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    // create a test object
    org.apache.cxf.binding.corba.wsdl.Object objectType = new org.apache.cxf.binding.corba.wsdl.Object();
    objectType.setRepositoryID("IDL:Account:1.0");
    objectType.setBinding(new QName("AccountCORBABinding"));
    QName objectName = new QName("TestObject");
    QName objectIdlType = new QName("corbaatm:TestObject");
    TypeCode objectTC = orb.create_interface_tc("IDL:Account:1.0", "TestObject");
    CorbaObjectReferenceHandler obj = new CorbaObjectReferenceHandler(objectName, objectIdlType, objectTC, objectType);
    reader.readObjectReference(obj);
    assertTrue(obj.getReference()._is_equivalent(objRef));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) InputStream(org.omg.CORBA.portable.InputStream) QName(javax.xml.namespace.QName) OutputStream(org.omg.CORBA.portable.OutputStream) URL(java.net.URL) CorbaObjectReferenceHandler(org.apache.cxf.binding.corba.types.CorbaObjectReferenceHandler) Test(org.junit.Test)

Example 9 with TypeCode

use of org.omg.CORBA.TypeCode 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(new Long(((CorbaPrimitiveHandler) obj.getElement(i)).getDataFromValue()).intValue() == 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 10 with TypeCode

use of org.omg.CORBA.TypeCode 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(new Short(((CorbaPrimitiveHandler) nestedObjs.get(0)).getDataFromValue()).shortValue() == code);
    assertTrue(((CorbaPrimitiveHandler) nestedObjs.get(1)).getDataFromValue().equals(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

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