Search in sources :

Example 11 with DefaultExchange

use of org.apache.camel.support.DefaultExchange in project webofneeds by researchstudio-sat.

the class WonMessageSlipComputerTests method testConnectMessageFromNode.

@Test
public void testConnectMessageFromNode() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_HEADER, dummyMessage);
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_TYPE_HEADER, URI.create(WONMSG.ConnectMessageString));
    exchange.getIn().setHeader(WonCamelConstants.DIRECTION_HEADER, URI.create(WonMessageDirection.FROM_EXTERNAL.getResource().getURI().toString()));
    exchange.getIn().setHeader(WonCamelConstants.SOCKET_TYPE_URI_HEADER, WXCHAT.ChatSocket.asURI());
    String slip = fixedMessageProcessorSlip.evaluate(exchange, String.class);
    Assert.assertEquals("bean:connectMessageFromNodeProcessor?method=process", slip);
}
Also used : DefaultExchange(org.apache.camel.support.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.support.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 12 with DefaultExchange

use of org.apache.camel.support.DefaultExchange in project webofneeds by researchstudio-sat.

the class WonMessageRoutesTest method send.

protected void send(Map properties, Map<String, Object> headers, Object body, String endpoint) {
    Exchange exchange = new DefaultExchange(camelContext);
    exchange.setPattern(ExchangePattern.InOnly);
    Endpoint ep = camelContext.getEndpoint(endpoint);
    if (properties != null) {
        if (properties.containsKey("methodName")) {
            exchange.setProperty("methodName", properties.get("methodName"));
        }
        if (properties.containsKey("protocol")) {
            exchange.setProperty("protocol", properties.get("protocol"));
        }
    }
    if (headers != null) {
        exchange.getIn().setHeaders(headers);
    }
    exchange.getIn().setBody(body);
    producerTemplate.send(ep, exchange);
}
Also used : DefaultExchange(org.apache.camel.support.DefaultExchange) DefaultExchange(org.apache.camel.support.DefaultExchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 13 with DefaultExchange

use of org.apache.camel.support.DefaultExchange in project webofneeds by researchstudio-sat.

the class WonMessageSlipComputerTests method testConnectMessageFromOwner.

@Test
public void testConnectMessageFromOwner() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_HEADER, dummyMessage);
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_TYPE_HEADER, URI.create(WONMSG.ConnectMessageString));
    exchange.getIn().setHeader(WonCamelConstants.DIRECTION_HEADER, URI.create(WonMessageDirection.FROM_OWNER.getResource().getURI().toString()));
    exchange.getIn().setHeader(WonCamelConstants.SOCKET_TYPE_URI_HEADER, WXCHAT.ChatSocket.asURI());
    String slip = fixedMessageProcessorSlip.evaluate(exchange, String.class);
    Assert.assertEquals("bean:connectMessageFromOwnerProcessor?method=process", slip);
}
Also used : DefaultExchange(org.apache.camel.support.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.support.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 14 with DefaultExchange

use of org.apache.camel.support.DefaultExchange in project webofneeds by researchstudio-sat.

the class WonMessageSlipComputerTests method testSendMessageFromOwner.

@Test
public void testSendMessageFromOwner() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_HEADER, dummyMessage);
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_TYPE_HEADER, URI.create(WONMSG.ConnectionMessageString));
    exchange.getIn().setHeader(WonCamelConstants.DIRECTION_HEADER, URI.create(WonMessageDirection.FROM_OWNER.getResource().getURI().toString()));
    exchange.getIn().setHeader(WonCamelConstants.SOCKET_TYPE_URI_HEADER, WXCHAT.ChatSocket.asURI());
    String slip = fixedMessageProcessorSlip.evaluate(exchange, String.class);
    Assert.assertEquals("bean:sendMessageFromOwnerProcessor?method=process", slip);
}
Also used : DefaultExchange(org.apache.camel.support.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.support.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 15 with DefaultExchange

use of org.apache.camel.support.DefaultExchange in project webofneeds by researchstudio-sat.

the class WonMessageSlipComputerTests method testCreateFromOwner.

@Test
public void testCreateFromOwner() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext());
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_HEADER, dummyMessage);
    exchange.getIn().setHeader(WonCamelConstants.MESSAGE_TYPE_HEADER, URI.create(WONMSG.CreateMessageString));
    exchange.getIn().setHeader(WonCamelConstants.DIRECTION_HEADER, URI.create(WonMessageDirection.FROM_OWNER.getResource().getURI().toString()));
    String slip = fixedMessageProcessorSlip.evaluate(exchange, String.class);
    Assert.assertEquals("bean:createAtomMessageProcessor?method=process", slip);
}
Also used : DefaultExchange(org.apache.camel.support.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.support.DefaultExchange) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

DefaultExchange (org.apache.camel.support.DefaultExchange)16 Exchange (org.apache.camel.Exchange)13 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)10 Test (org.junit.Test)10 URI (java.net.URI)2 WonMessage (won.protocol.message.WonMessage)2 IOException (java.io.IOException)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 ServletException (javax.servlet.ServletException)1 CamelContext (org.apache.camel.CamelContext)1 Route (org.apache.camel.Route)1 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)1 HttpConsumer (org.apache.camel.http.common.HttpConsumer)1 HttpMessage (org.apache.camel.http.common.HttpMessage)1 Synchronization (org.apache.camel.spi.Synchronization)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 AbstractCamelProcessor (won.node.camel.processor.AbstractCamelProcessor)1