Search in sources :

Example 61 with TypeCode

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

the class CorbaStructHandlerTest method testCorbaStructHandler.

@Test
public void testCorbaStructHandler() {
    Struct structType = new Struct();
    structType.setName("TestStruct");
    structType.setRepositoryID("IDL:TestStruct:1.0");
    MemberType member0 = new MemberType();
    member0.setIdltype(CorbaConstants.NT_CORBA_LONG);
    member0.setName("member0");
    MemberType member1 = new MemberType();
    member1.setIdltype(CorbaConstants.NT_CORBA_STRING);
    member1.setName("member1");
    QName structName = new QName("TestStruct");
    QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "testStruct", CorbaConstants.NP_WSDL_CORBA);
    StructMember[] structMembers = new StructMember[2];
    structMembers[0] = new StructMember("member0", orb.get_primitive_tc(TCKind.tk_long), null);
    structMembers[1] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_string), null);
    TypeCode structTC = orb.create_struct_tc(structType.getRepositoryID(), structType.getName(), structMembers);
    CorbaStructHandler obj = new CorbaStructHandler(structName, structIdlType, structTC, structType);
    assertNotNull(obj);
    CorbaPrimitiveHandler objMember0 = new CorbaPrimitiveHandler(new QName(member0.getName()), member0.getIdltype(), orb.get_primitive_tc(TCKind.tk_long), null);
    assertNotNull(objMember0);
    obj.addMember(objMember0);
    CorbaPrimitiveHandler objMember1 = new CorbaPrimitiveHandler(new QName(member1.getName()), member1.getIdltype(), orb.get_primitive_tc(TCKind.tk_string), null);
    assertNotNull(objMember1);
    obj.addMember(objMember1);
    int memberSize = obj.getMembers().size();
    assertTrue(memberSize == 2);
    QName nameResult = obj.getName();
    assertEquals(structName, nameResult);
    QName idlTypeResult = obj.getIdlType();
    assertEquals(structIdlType, idlTypeResult);
    CorbaObjectHandler member0Result = obj.getMemberByName("member0");
    assertNotNull(member0Result);
    assertEquals(member0Result.getName(), objMember0.getName());
    CorbaObjectHandler member1Result = obj.getMember(1);
    assertNotNull(member1Result);
    assertEquals(member1Result.getName(), objMember1.getName());
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) StructMember(org.omg.CORBA.StructMember) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Test(org.junit.Test)

Example 62 with TypeCode

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

the class CorbaUtilsTest method testLongTypeCode.

@Test
public void testLongTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "long", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_long);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 63 with TypeCode

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

the class CorbaUtilsTest method testOctetTypeCode.

@Test
public void testOctetTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "octet", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_octet);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 64 with TypeCode

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

the class CorbaUtilsTest method testCharTypeCode.

@Test
public void testCharTypeCode() {
    QName type = new QName(CorbaConstants.NU_WSDL_CORBA, "char", "corba");
    TypeCode tc = CorbaUtils.getPrimitiveTypeCode(orb, type);
    assertNotNull(tc);
    assertTrue(tc.kind().value() == TCKind._tk_char);
    assertTrue(CorbaUtils.isPrimitiveIdlType(type));
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 65 with TypeCode

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

the class CorbaObjectWriterTest method testWriteException.

@Test
public void testWriteException() {
    // create the following exception
    // exception TestExcept {
    // short code;
    // string message;
    // }
    short code = 12345;
    String message = "54321";
    String reposID = "IDL:org.apache.cxf.TestException/1.0";
    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");
    exceptType.setRepositoryID(reposID);
    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(reposID, "TestException", exceptMembers);
    CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType, exceptTC, exceptType);
    CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName("code"), shortIdlType, exceptMembers[0].type, null);
    member1.setValueFromData(Short.toString(code));
    CorbaPrimitiveHandler member2 = new CorbaPrimitiveHandler(new QName("message"), stringIdlType, exceptMembers[1].type, null);
    member2.setValueFromData(message);
    obj.addMember(member1);
    obj.addMember(member2);
    OutputStream oStream = orb.create_output_stream();
    CorbaObjectWriter writer = new CorbaObjectWriter(oStream);
    writer.writeException(obj);
    InputStream iStream = oStream.create_input_stream();
    String readId = iStream.read_string();
    assertEquals(readId, reposID);
    short readCode = iStream.read_short();
    assertTrue(readCode == code);
    String readMessage = iStream.read_string();
    assertEquals(readMessage, message);
}
Also used : TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) InputStream(org.omg.CORBA.portable.InputStream) 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) Test(org.junit.Test)

Aggregations

TypeCode (org.omg.CORBA.TypeCode)70 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 Exchange (org.apache.cxf.message.Exchange)4 IOException (java.io.IOException)3