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