Search in sources :

Example 11 with CorbaPrimitiveHandler

use of org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler 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);
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) CorbaStreamable(org.apache.cxf.binding.corba.CorbaStreamable) QName(javax.xml.namespace.QName) Test(org.junit.Test)

Example 12 with CorbaPrimitiveHandler

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

the class CorbaMessageTest method testGetCorbaMessageAttributes.

@Test
public void testGetCorbaMessageAttributes() {
    CorbaMessage msg = new CorbaMessage(message);
    QName param1Name = new QName("param1");
    QName param1IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param1TypeCode = orb.get_primitive_tc(TCKind.tk_long);
    CorbaPrimitiveHandler param1 = new CorbaPrimitiveHandler(param1Name, param1IdlType, param1TypeCode, null);
    CorbaStreamable p1 = msg.createStreamableObject(param1, param1Name);
    QName param2Name = new QName("param2");
    QName param2IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param2TypeCode = orb.get_primitive_tc(TCKind.tk_string);
    CorbaPrimitiveHandler param2 = new CorbaPrimitiveHandler(param2Name, param2IdlType, param2TypeCode, null);
    CorbaStreamable p2 = msg.createStreamableObject(param2, param2Name);
    msg.addStreamableArgument(p1);
    msg.addStreamableArgument(p2);
    CorbaStreamable[] arguments = msg.getStreamableArguments();
    assertTrue(arguments.length == 2);
    assertNotNull(arguments[0]);
    assertNotNull(arguments[1]);
    QName param3Name = new QName("param3");
    QName param3IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param3TypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler param3 = new CorbaPrimitiveHandler(param3Name, param3IdlType, param3TypeCode, null);
    CorbaStreamable p3 = msg.createStreamableObject(param3, param3Name);
    QName param4Name = new QName("param4");
    QName param4IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "float", CorbaConstants.NP_WSDL_CORBA);
    TypeCode param4TypeCode = orb.get_primitive_tc(TCKind.tk_float);
    CorbaPrimitiveHandler param4 = new CorbaPrimitiveHandler(param4Name, param4IdlType, param4TypeCode, null);
    CorbaStreamable p4 = msg.createStreamableObject(param4, param4Name);
    CorbaStreamable[] args = new CorbaStreamable[2];
    args[0] = p3;
    args[1] = p4;
    msg.setStreamableArguments(args);
    arguments = msg.getStreamableArguments();
    assertTrue(arguments.length == 4);
    assertNotNull(arguments[0]);
    assertNotNull(arguments[1]);
    assertNotNull(arguments[2]);
    assertNotNull(arguments[3]);
    NVList list = orb.create_list(2);
    Any value = orb.create_any();
    value.insert_Streamable(p1);
    list.add_value(p1.getName(), value, p1.getMode());
    value.insert_Streamable(p2);
    list.add_value(p2.getName(), value, p2.getMode());
    msg.setList(list);
    NVList resultList = msg.getList();
    assertTrue(resultList.count() == 2);
    QName returnName = new QName("param2");
    QName returnIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
    TypeCode returnTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
    CorbaPrimitiveHandler returnValue = new CorbaPrimitiveHandler(returnName, returnIdlType, returnTypeCode, null);
    CorbaStreamable ret = msg.createStreamableObject(returnValue, returnName);
    msg.setStreamableReturn(ret);
    CorbaStreamable retVal = msg.getStreamableReturn();
    assertNotNull(retVal);
// NEED TO DO TEST FOR EXCEPTIONS
/*Exception ex = new CorbaBindingException("TestException");
        msg.s.setException(ex);
        Exception msgEx = msg.getException();
        assertNotNull(msgEx);
        assertTrue(msgEx.getMessage().equals(ex.getMessage()));*/
}
Also used : CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NVList(org.omg.CORBA.NVList) Any(org.omg.CORBA.Any) Test(org.junit.Test)

Example 13 with CorbaPrimitiveHandler

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

the class CorbaServerConduitTest method testBuildRequestResultArgumentReturn.

@Test
public void testBuildRequestResultArgumentReturn() {
    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 obj = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = new CorbaStreamableImpl(obj, objName);
    arguments[0] = arg;
    arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
    NVList nvlist = orb.create_list(2);
    Any value = orb.create_any();
    value.insert_Streamable(arguments[0]);
    nvlist.add_value(arguments[0].getName(), value, arguments[0].getMode());
    CorbaServerConduit conduit = setupCorbaServerConduit(false);
    CorbaMessage msg = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    ServerRequest request = control.createMock(ServerRequest.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
    EasyMock.expect(exchange.isOneWay()).andReturn(false);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    Message message = new MessageImpl();
    CorbaMessage corbaMessage = new CorbaMessage(message);
    corbaMessage.setList(nvlist);
    EasyMock.expect(exchange.getInMessage()).andReturn(corbaMessage);
    EasyMock.expect(msg.getStreamableException()).andReturn(null);
    EasyMock.expect(msg.getStreamableArguments()).andReturn(arguments);
    EasyMock.expect(msg.getStreamableReturn()).andReturn(arg);
    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
Also used : CorbaStreamableImpl(org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) Any(org.omg.CORBA.Any) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Exchange(org.apache.cxf.message.Exchange) NVList(org.omg.CORBA.NVList) ServerRequest(org.omg.CORBA.ServerRequest) MessageImpl(org.apache.cxf.message.MessageImpl) Test(org.junit.Test)

Example 14 with CorbaPrimitiveHandler

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

the class CorbaServerConduitTest method testBuildRequestResultException.

@Test
public void testBuildRequestResultException() {
    NVList list = orb.create_list(0);
    CorbaServerConduit conduit = setupCorbaServerConduit(false);
    CorbaMessage msg = control.createMock(CorbaMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    ServerRequest request = control.createMock(ServerRequest.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.get(ServerRequest.class)).andReturn(request);
    EasyMock.expect(exchange.isOneWay()).andReturn(false);
    CorbaMessage inMsg = EasyMock.createMock(CorbaMessage.class);
    EasyMock.expect(msg.getExchange()).andReturn(exchange);
    EasyMock.expect(exchange.getInMessage()).andReturn(inMsg);
    EasyMock.expect(inMsg.getList()).andReturn(list);
    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 exception = new CorbaStreamableImpl(obj, objName);
    EasyMock.expect(msg.getStreamableException()).andReturn(exception);
    EasyMock.expect(msg.getStreamableException()).andReturn(exception);
    control.replay();
    conduit.buildRequestResult(msg);
    control.verify();
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) CorbaStreamableImpl(org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NVList(org.omg.CORBA.NVList) ServerRequest(org.omg.CORBA.ServerRequest) Test(org.junit.Test)

Example 15 with CorbaPrimitiveHandler

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

the class CorbaObjectReaderTest method testReadSequence.

@Test
public void testReadSequence() {
    String[] data = { "one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one" };
    OutputStream oStream = orb.create_output_stream();
    oStream.write_long(data.length);
    for (int i = 0; i < data.length; ++i) {
        oStream.write_string(data[i]);
    }
    InputStream iStream = oStream.create_input_stream();
    CorbaObjectReader reader = new CorbaObjectReader(iStream);
    // create an sequence of strings
    QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
    QName seqIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "sequence", CorbaConstants.NP_WSDL_CORBA);
    Sequence seqType = new Sequence();
    seqType.setBound(data.length);
    seqType.setElemtype(stringIdlType);
    // name and respoitory ID of the sequence are not needed for this test
    // build the object holder for a sequence.
    TypeCode seqTC = orb.create_sequence_tc(data.length, orb.get_primitive_tc(TCKind.tk_string));
    CorbaSequenceHandler obj = new CorbaSequenceHandler(new QName("Seq"), seqIdlType, seqTC, seqType);
    for (int i = 0; i < data.length; ++i) {
        CorbaPrimitiveHandler nestedObj = new CorbaPrimitiveHandler(new QName("item"), stringIdlType, orb.get_primitive_tc(TCKind.tk_string), null);
        obj.addElement(nestedObj);
    }
    reader.readSequence(obj);
    int length = obj.getElements().size();
    for (int i = 0; i < length; ++i) {
        assertTrue(((CorbaPrimitiveHandler) obj.getElement(i)).getDataFromValue().equals(data[i]));
    }
}
Also used : 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) CorbaSequenceHandler(org.apache.cxf.binding.corba.types.CorbaSequenceHandler) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Test(org.junit.Test)

Aggregations

QName (javax.xml.namespace.QName)18 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)18 Test (org.junit.Test)18 TypeCode (org.omg.CORBA.TypeCode)18 InputStream (org.omg.CORBA.portable.InputStream)10 OutputStream (org.omg.CORBA.portable.OutputStream)10 CorbaStreamable (org.apache.cxf.binding.corba.CorbaStreamable)5 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)4 NVList (org.omg.CORBA.NVList)4 StructMember (org.omg.CORBA.StructMember)4 CorbaObjectHandler (org.apache.cxf.binding.corba.types.CorbaObjectHandler)3 Message (org.apache.cxf.message.Message)3 MessageImpl (org.apache.cxf.message.MessageImpl)3 IOException (java.io.IOException)2 CorbaStreamableImpl (org.apache.cxf.binding.corba.runtime.CorbaStreamableImpl)2 CorbaArrayHandler (org.apache.cxf.binding.corba.types.CorbaArrayHandler)2 CorbaExceptionHandler (org.apache.cxf.binding.corba.types.CorbaExceptionHandler)2 CorbaSequenceHandler (org.apache.cxf.binding.corba.types.CorbaSequenceHandler)2 CorbaStructHandler (org.apache.cxf.binding.corba.types.CorbaStructHandler)2 Array (org.apache.cxf.binding.corba.wsdl.Array)2