Search in sources :

Example 1 with CorbaObjectReferenceHandler

use of org.apache.cxf.binding.corba.types.CorbaObjectReferenceHandler 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 2 with CorbaObjectReferenceHandler

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

the class CorbaObjectWriterTest method testWriteObject.

@Test
public void testWriteObject() throws IOException {
    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);
    // 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);
    obj.setReference(objRef);
    OutputStream oStream = orb.create_output_stream();
    CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
    writer.writeObjectReference(obj);
    InputStream iStream = oStream.create_input_stream();
    org.omg.CORBA.Object resultObj = iStream.read_Object();
    assertTrue(resultObj._is_equivalent(obj.getReference()));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) OutputStream(org.omg.CORBA.portable.OutputStream) URL(java.net.URL) CorbaObjectReferenceHandler(org.apache.cxf.binding.corba.types.CorbaObjectReferenceHandler) Test(org.junit.Test)

Aggregations

URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 CorbaObjectReferenceHandler (org.apache.cxf.binding.corba.types.CorbaObjectReferenceHandler)2 Test (org.junit.Test)2 TypeCode (org.omg.CORBA.TypeCode)2 InputStream (org.omg.CORBA.portable.InputStream)2 OutputStream (org.omg.CORBA.portable.OutputStream)2