Search in sources :

Example 26 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 27 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 28 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 29 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)

Example 30 with DefaultMessage

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

the class SpringLdapProducerTest method testWrongBodyType.

@Test(expected = NullPointerException.class)
public void testWrongBodyType() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    in.setBody("");
    exchange.setIn(in);
    ldapProducer.process(exchange);
}
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) Test(org.junit.Test)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)45 Message (org.apache.camel.Message)44 Exchange (org.apache.camel.Exchange)22 DefaultExchange (org.apache.camel.impl.DefaultExchange)19 Test (org.junit.Test)16 HashMap (java.util.HashMap)15 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