Search in sources :

Example 16 with DefaultMessage

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

the class SpringLdapProducerTest method testNullDN.

@Test(expected = UnsupportedOperationException.class)
public void testNullDN() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, null);
    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 17 with DefaultMessage

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

the class SpringLdapProducerTest method testUnbind.

@Test
public void testUnbind() throws Exception {
    String dn = "some dn";
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, dn);
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.UNBIND);
    processBody(exchange, in, body);
    verify(ldapTemplate).unbind(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) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 18 with DefaultMessage

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

the class SpringLdapProducerTest method testModifyAttributes.

@Test
public void testModifyAttributes() throws Exception {
    String dn = "cn=dn";
    ModificationItem[] modificationItems = new ModificationItem[] { new ModificationItem(DirContext.ADD_ATTRIBUTE, new BasicAttribute("key", "value")) };
    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.MODIFICATION_ITEMS, modificationItems);
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.MODIFY_ATTRIBUTES);
    processBody(exchange, in, body);
    verify(ldapTemplate).modifyAttributes(eq(dn), eq(modificationItems));
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) 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) DefaultMessage(org.apache.camel.impl.DefaultMessage) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 19 with DefaultMessage

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

the class SpringLdapProducerTest method testNoDNForFunctionDrivenOperation.

@Test
public void testNoDNForFunctionDrivenOperation() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();
    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.FUNCTION, Mockito.mock(BiFunction.class));
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.FUNCTION_DRIVEN);
    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) BiFunction(java.util.function.BiFunction) Test(org.junit.Test)

Example 20 with DefaultMessage

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

the class SpringLdapProducerTest method testEmptyDN.

@Test(expected = UnsupportedOperationException.class)
public void testEmptyDN() 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)

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