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));
}
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()));
}
Aggregations