Search in sources :

Example 46 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class CorbaConduitTest method testBuildReturn.

@Test
public void testBuildReturn() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    Exchange exchange = new ExchangeImpl();
    exchange.put(Bus.class, bus);
    message.setExchange(exchange);
    QName objName = new QName("returnName");
    QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
    TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
    CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = message.createStreamableObject(obj1, objName);
    CorbaConduit conduit = setupCorbaConduit(false);
    NamedValue ret = conduit.getReturn(message);
    assertNotNull("Return should not be null", ret != null);
    assertEquals("name should be equal", ret.name(), "return");
    message.setStreamableReturn(arg);
    NamedValue ret2 = conduit.getReturn(message);
    assertNotNull("Return2 should not be null", ret2 != null);
    assertEquals("name should be equal", ret2.name(), "returnName");
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NamedValue(org.omg.CORBA.NamedValue) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 47 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class CorbaConduitTest method testBuildArguments.

@Test
public void testBuildArguments() throws Exception {
    Message msg = new MessageImpl();
    CorbaMessage message = new CorbaMessage(msg);
    Exchange exchange = new ExchangeImpl();
    exchange.put(Bus.class, bus);
    message.setExchange(exchange);
    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 obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
    CorbaStreamable arg = message.createStreamableObject(obj1, objName);
    arguments[0] = arg;
    arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
    CorbaConduit conduit = setupCorbaConduit(false);
    NVList list = conduit.getArguments(message);
    assertNotNull("list should not be null", list != null);
    message.setStreamableArguments(arguments);
    NVList listArgs = conduit.getArguments(message);
    assertNotNull("listArgs should not be null", listArgs != null);
    assertNotNull("listArgs Item should not be null", listArgs.item(0) != null);
    assertEquals("Name should be equal", listArgs.item(0).name(), "object");
    assertEquals("flags should be 2", listArgs.item(0).flags(), 2);
    assertNotNull("Any Value should not be null", listArgs.item(0).value() != null);
}
Also used : Exchange(org.apache.cxf.message.Exchange) CorbaPrimitiveHandler(org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler) Message(org.apache.cxf.message.Message) TypeCode(org.omg.CORBA.TypeCode) QName(javax.xml.namespace.QName) NVList(org.omg.CORBA.NVList) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) Test(org.junit.Test)

Example 48 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class SingletonResourceProvider method init.

public void init(Endpoint ep) {
    if (resourceInstance instanceof Constructor) {
        Constructor<?> c = (Constructor<?>) resourceInstance;
        Message m = new MessageImpl();
        ExchangeImpl exchange = new ExchangeImpl();
        exchange.put(Endpoint.class, ep);
        m.setExchange(exchange);
        Object[] values = ResourceUtils.createConstructorArguments(c, m, false, Collections.emptyMap());
        try {
            resourceInstance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[] {});
        } catch (Exception ex) {
            throw new ServiceConstructionException(ex);
        }
    }
    if (callPostConstruct) {
        InjectionUtils.invokeLifeCycleMethod(resourceInstance, ResourceUtils.findPostConstructMethod(ClassHelper.getRealClass(resourceInstance)));
    }
}
Also used : Message(org.apache.cxf.message.Message) Constructor(java.lang.reflect.Constructor) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl) ServiceConstructionException(org.apache.cxf.service.factory.ServiceConstructionException)

Example 49 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class JAXBElementProviderTest method createMessage.

private Message createMessage() {
    ServerProviderFactory factory = ServerProviderFactory.getInstance();
    Message m = new MessageImpl();
    m.put(Message.ENDPOINT_ADDRESS, "http://localhost:8080/bar");
    m.put("org.apache.cxf.http.case_insensitive_queries", false);
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    e.setInMessage(m);
    Endpoint endpoint = EasyMock.mock(Endpoint.class);
    EasyMock.expect(endpoint.getEndpointInfo()).andReturn(null).anyTimes();
    EasyMock.expect(endpoint.get(Application.class.getName())).andReturn(null);
    EasyMock.expect(endpoint.size()).andReturn(0).anyTimes();
    EasyMock.expect(endpoint.isEmpty()).andReturn(true).anyTimes();
    EasyMock.expect(endpoint.get(ServerProviderFactory.class.getName())).andReturn(factory).anyTimes();
    EasyMock.replay(endpoint);
    e.put(Endpoint.class, endpoint);
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) Message(org.apache.cxf.message.Message) Endpoint(org.apache.cxf.endpoint.Endpoint) MessageImpl(org.apache.cxf.message.MessageImpl) Application(javax.ws.rs.core.Application) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 50 with ExchangeImpl

use of org.apache.cxf.message.ExchangeImpl in project cxf by apache.

the class UriInfoImplTest method mockMessage.

private Message mockMessage(String baseAddress, String pathInfo, String query, String fragment) {
    Message m = new MessageImpl();
    control.reset();
    Exchange e = new ExchangeImpl();
    m.setExchange(e);
    ServletDestination d = control.createMock(ServletDestination.class);
    e.setDestination(d);
    EndpointInfo epr = new EndpointInfo();
    epr.setAddress(baseAddress);
    d.getEndpointInfo();
    EasyMock.expectLastCall().andReturn(epr).anyTimes();
    m.put(Message.REQUEST_URI, pathInfo);
    m.put(Message.QUERY_STRING, query);
    control.replay();
    return m;
}
Also used : Exchange(org.apache.cxf.message.Exchange) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ServletDestination(org.apache.cxf.transport.servlet.ServletDestination) Message(org.apache.cxf.message.Message) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Aggregations

ExchangeImpl (org.apache.cxf.message.ExchangeImpl)227 MessageImpl (org.apache.cxf.message.MessageImpl)189 Message (org.apache.cxf.message.Message)166 Exchange (org.apache.cxf.message.Exchange)159 Test (org.junit.Test)107 Endpoint (org.apache.cxf.endpoint.Endpoint)42 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)30 ByteArrayInputStream (java.io.ByteArrayInputStream)28 QName (javax.xml.namespace.QName)23 Bus (org.apache.cxf.Bus)23 HashMap (java.util.HashMap)22 List (java.util.List)22 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)20 SOAPMessage (javax.xml.soap.SOAPMessage)16 LogEvent (org.apache.cxf.ext.logging.event.LogEvent)16 ArrayList (java.util.ArrayList)15 IOException (java.io.IOException)14 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)14 Conduit (org.apache.cxf.transport.Conduit)14