Search in sources :

Example 51 with Conduit

use of org.apache.cxf.transport.Conduit in project cxf by apache.

the class LoadDistributorTargetSelector method selectConduit.

/**
 * Called when a Conduit is actually required.
 *
 * @param message
 * @return the Conduit to use for mediation of the message
 */
public synchronized Conduit selectConduit(Message message) {
    Conduit c = message.get(Conduit.class);
    if (c != null) {
        return c;
    }
    Exchange exchange = message.getExchange();
    InvocationKey key = new InvocationKey(exchange);
    InvocationContext invocation = inProgress.get(key);
    if ((invocation != null) && !invocation.getContext().containsKey(IS_DISTRIBUTED)) {
        Endpoint target = getDistributionTarget(exchange, invocation);
        if (target != null) {
            setEndpoint(target);
            message.put(Message.ENDPOINT_ADDRESS, target.getEndpointInfo().getAddress());
            message.put(CONDUIT_COMPARE_FULL_URL, Boolean.TRUE);
            overrideAddressProperty(invocation.getContext());
            invocation.getContext().put(IS_DISTRIBUTED, null);
        }
    }
    return getSelectedConduit(message);
}
Also used : Exchange(org.apache.cxf.message.Exchange) Endpoint(org.apache.cxf.endpoint.Endpoint) Conduit(org.apache.cxf.transport.Conduit)

Example 52 with Conduit

use of org.apache.cxf.transport.Conduit in project cxf by apache.

the class JettyHTTPDestinationTest method testGetBackChannelSendDecoupled.

@Test
public void testGetBackChannelSendDecoupled() throws Exception {
    destination = setUpDestination(false, false);
    setUpDoService(false, true, true, 202);
    destination.doService(request, response);
    setUpInMessage();
    Message partialResponse = setUpOutMessage();
    partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
    Conduit partialBackChannel = destination.getBackChannel(inMessage);
    partialBackChannel.prepare(partialResponse);
    verifyBackChannelSend(partialBackChannel, partialResponse, 202);
    outMessage = setUpOutMessage();
    Conduit fullBackChannel = destination.getBackChannel(inMessage);
    fullBackChannel.prepare(outMessage);
}
Also used : Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Example 53 with Conduit

use of org.apache.cxf.transport.Conduit in project cxf by apache.

the class JettyHTTPDestinationTest method testGetBackChannelSendOneway.

@Test
public void testGetBackChannelSendOneway() throws Exception {
    destination = setUpDestination(false, false);
    setUpDoService(false, true, 500);
    destination.doService(request, response);
    setUpInMessage();
    Conduit backChannel = destination.getBackChannel(inMessage);
    outMessage = setUpOutMessage();
    backChannel.prepare(outMessage);
    verifyBackChannelSend(backChannel, outMessage, 500, true);
}
Also used : Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Example 54 with Conduit

use of org.apache.cxf.transport.Conduit in project cxf by apache.

the class JettyHTTPDestinationTest method testGetBackChannelSendFault.

@Test
public void testGetBackChannelSendFault() throws Exception {
    destination = setUpDestination(false, false);
    setUpDoService(false, true, 500);
    destination.doService(request, response);
    setUpInMessage();
    Conduit backChannel = destination.getBackChannel(inMessage);
    outMessage = setUpOutMessage();
    backChannel.prepare(outMessage);
    verifyBackChannelSend(backChannel, outMessage, 500);
}
Also used : Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Example 55 with Conduit

use of org.apache.cxf.transport.Conduit in project cxf by apache.

the class NettyHttpDestinationTest method testGetBackChannelSendDecoupled.

@Test
public void testGetBackChannelSendDecoupled() throws Exception {
    destination = setUpDestination(false, false);
    setUpDoService(false, true, true, 202);
    destination.doService(request, response);
    setUpInMessage();
    Message partialResponse = setUpOutMessage();
    partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
    Conduit partialBackChannel = destination.getBackChannel(inMessage);
    partialBackChannel.prepare(partialResponse);
    verifyBackChannelSend(partialBackChannel, partialResponse, 202);
    outMessage = setUpOutMessage();
    Conduit fullBackChannel = destination.getBackChannel(inMessage);
    fullBackChannel.prepare(outMessage);
}
Also used : Message(org.apache.cxf.message.Message) Conduit(org.apache.cxf.transport.Conduit) Test(org.junit.Test)

Aggregations

Conduit (org.apache.cxf.transport.Conduit)83 Test (org.junit.Test)36 Message (org.apache.cxf.message.Message)35 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)30 Exchange (org.apache.cxf.message.Exchange)28 IOException (java.io.IOException)18 MessageImpl (org.apache.cxf.message.MessageImpl)17 Endpoint (org.apache.cxf.endpoint.Endpoint)16 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)13 MessageObserver (org.apache.cxf.transport.MessageObserver)12 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)12 OutputStream (java.io.OutputStream)11 Bus (org.apache.cxf.Bus)11 Destination (org.apache.cxf.transport.Destination)11 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)10 InputStream (java.io.InputStream)9 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)9 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6