Search in sources :

Example 1 with DefaultMessage

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

the class SpringLdapProducerTest method testAuthenticate.

@Test
public void testAuthenticate() throws Exception {
    String dn = "cn=dn";
    String filter = "filter";
    String password = "password";
    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.FILTER, filter);
    body.put(SpringLdapProducer.PASSWORD, password);
    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.AUTHENTICATE);
    processBody(exchange, in, body);
    verify(ldapTemplate).authenticate(Matchers.any(LdapQuery.class), eq(password));
}
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) LdapQuery(org.springframework.ldap.query.LdapQuery) Test(org.junit.Test)

Example 2 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 3 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 4 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 5 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)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)66 Message (org.apache.camel.Message)59 Exchange (org.apache.camel.Exchange)32 Test (org.junit.Test)31 DefaultExchange (org.apache.camel.impl.DefaultExchange)24 HashMap (java.util.HashMap)19 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)11 CamelContext (org.apache.camel.CamelContext)7 Producer (org.apache.camel.Producer)6 VolumeProducer (org.apache.camel.component.openstack.cinder.producer.VolumeProducer)6 GlanceProducer (org.apache.camel.component.openstack.glance.GlanceProducer)6 ProjectProducer (org.apache.camel.component.openstack.keystone.producer.ProjectProducer)6 NetworkProducer (org.apache.camel.component.openstack.neutron.producer.NetworkProducer)6 KeypairProducer (org.apache.camel.component.openstack.nova.producer.KeypairProducer)6 ContainerProducer (org.apache.camel.component.openstack.swift.producer.ContainerProducer)6 DefaultHeadersMapFactory (org.apache.camel.impl.DefaultHeadersMapFactory)6 NotificationMessage (se.inera.intyg.common.support.modules.support.api.notification.NotificationMessage)5 IOException (java.io.IOException)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 Method (java.lang.reflect.Method)3