Search in sources :

Example 31 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class RabbitMQMessageConverter method resolveMessageFrom.

private Message resolveMessageFrom(final Exchange camelExchange, final boolean out) {
    Message message;
    if (out) {
        // use OUT message
        message = camelExchange.getOut();
    } else {
        if (camelExchange.getIn() != null) {
            // Use the existing message so we keep the headers
            message = camelExchange.getIn();
        } else {
            message = new DefaultMessage();
            camelExchange.setIn(message);
        }
    }
    return message;
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage)

Example 32 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class SpringLdapProducerTest method testNoDN.

@Test(expected = UnsupportedOperationException.class)
public void testNoDN() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    processBody(exchange, in, body);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 33 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class SpringLdapProducerTest method testFunctionDriven.

@Test
public void testFunctionDriven() throws Exception {
    String dn = "cn=dn";
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, dn);
    body.put(SpringLdapProducer.REQUEST, dn);
    body.put(SpringLdapProducer.FUNCTION, (BiFunction<LdapOperations, String, Void>) (l, q) -> {
        l.lookup(q);
        return null;
    });
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.FUNCTION_DRIVEN);
    processBody(exchange, in, body);
    verify(ldapTemplate).lookup(eq(dn));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) ModificationItem(javax.naming.directory.ModificationItem) Message(org.apache.camel.Message) Matchers(org.mockito.Matchers) BiFunction(java.util.function.BiFunction) HashMap(java.util.HashMap) Exchange(org.apache.camel.Exchange) LdapTemplate(org.springframework.ldap.core.LdapTemplate) SearchControls(javax.naming.directory.SearchControls) BasicAttribute(javax.naming.directory.BasicAttribute) LdapOperations(org.springframework.ldap.core.LdapOperations) Matchers.eq(org.mockito.Matchers.eq) Map(java.util.Map) Before(org.junit.Before) LdapQuery(org.springframework.ldap.query.LdapQuery) DefaultExchange(org.apache.camel.impl.DefaultExchange) Matchers.isNull(org.mockito.Matchers.isNull) DirContext(javax.naming.directory.DirContext) BasicAttributes(javax.naming.directory.BasicAttributes) DefaultMessage(org.apache.camel.impl.DefaultMessage) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Matchers.any(org.mockito.Matchers.any) Mockito(org.mockito.Mockito) AttributesMapper(org.springframework.ldap.core.AttributesMapper) CamelTestSupport(org.apache.camel.test.junit4.CamelTestSupport) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) LdapOperations(org.springframework.ldap.core.LdapOperations) Test(org.junit.Test)

Example 34 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class SpringLdapProducerTest method testNullOperation.

@Test(expected = UnsupportedOperationException.class)
public void testNullOperation() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, " ");
    processBody(exchange, in, body);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 35 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class SpringLdapProducerTest method testBind.

@Test
public void testBind() throws Exception {
    String dn = "some dn";
    BasicAttributes attributes = new BasicAttributes();
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, dn);
    body.put(SpringLdapProducer.ATTRIBUTES, attributes);
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.BIND);
    processBody(exchange, in, body);
    verify(ldapTemplate).bind(eq(dn), isNull(), eq(attributes));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultMessage(org.apache.camel.impl.DefaultMessage) BasicAttributes(javax.naming.directory.BasicAttributes) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)48 Message (org.apache.camel.Message)47 Exchange (org.apache.camel.Exchange)23 DefaultExchange (org.apache.camel.impl.DefaultExchange)19 Test (org.junit.Test)18 HashMap (java.util.HashMap)16 IOException (java.io.IOException)4 Method (java.lang.reflect.Method)3 NoSuchElementException (java.util.NoSuchElementException)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 Before (org.junit.Before)3 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 BasicAttribute (javax.naming.directory.BasicAttribute)2 BasicAttributes (javax.naming.directory.BasicAttributes)2 ModificationItem (javax.naming.directory.ModificationItem)2 Processor (org.apache.camel.Processor)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 Path (org.apache.hadoop.fs.Path)2