Search in sources :

Example 61 with Message

use of org.apache.camel.Message in project camel by apache.

the class SmppReplaceSmCommand method createReplaceSmTempate.

protected ReplaceSm createReplaceSmTempate(Exchange exchange) {
    Message in = exchange.getIn();
    ReplaceSm replaceSm = new ReplaceSm();
    if (in.getHeaders().containsKey(SmppConstants.ID)) {
        replaceSm.setMessageId(in.getHeader(SmppConstants.ID, String.class));
    }
    if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR)) {
        replaceSm.setSourceAddr(in.getHeader(SmppConstants.SOURCE_ADDR, String.class));
    } else {
        replaceSm.setSourceAddr(config.getSourceAddr());
    }
    if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR_TON)) {
        replaceSm.setSourceAddrTon(in.getHeader(SmppConstants.SOURCE_ADDR_TON, Byte.class));
    } else {
        replaceSm.setSourceAddrTon(config.getSourceAddrTon());
    }
    if (in.getHeaders().containsKey(SmppConstants.SOURCE_ADDR_NPI)) {
        replaceSm.setSourceAddrNpi(in.getHeader(SmppConstants.SOURCE_ADDR_NPI, Byte.class));
    } else {
        replaceSm.setSourceAddrNpi(config.getSourceAddrNpi());
    }
    if (in.getHeaders().containsKey(SmppConstants.REGISTERED_DELIVERY)) {
        replaceSm.setRegisteredDelivery(in.getHeader(SmppConstants.REGISTERED_DELIVERY, Byte.class));
    } else {
        replaceSm.setRegisteredDelivery(config.getRegisteredDelivery());
    }
    if (in.getHeaders().containsKey(SmppConstants.SCHEDULE_DELIVERY_TIME)) {
        replaceSm.setScheduleDeliveryTime(SmppUtils.formatTime(in.getHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, Date.class)));
    }
    if (in.getHeaders().containsKey(SmppConstants.VALIDITY_PERIOD)) {
        Object validityPeriod = in.getHeader(SmppConstants.VALIDITY_PERIOD);
        if (validityPeriod instanceof String) {
            replaceSm.setValidityPeriod((String) validityPeriod);
        } else if (validityPeriod instanceof Date) {
            replaceSm.setValidityPeriod(SmppUtils.formatTime((Date) validityPeriod));
        }
    }
    return replaceSm;
}
Also used : ReplaceSm(org.jsmpp.bean.ReplaceSm) Message(org.apache.camel.Message) Date(java.util.Date)

Example 62 with Message

use of org.apache.camel.Message 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 63 with Message

use of org.apache.camel.Message 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 64 with Message

use of org.apache.camel.Message 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 65 with Message

use of org.apache.camel.Message 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)

Aggregations

Message (org.apache.camel.Message)738 Exchange (org.apache.camel.Exchange)348 Test (org.junit.Test)223 Processor (org.apache.camel.Processor)118 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)104 DefaultMessage (org.apache.camel.impl.DefaultMessage)54 Endpoint (org.apache.camel.Endpoint)45 DefaultExchange (org.apache.camel.impl.DefaultExchange)44 InputStream (java.io.InputStream)38 HashMap (java.util.HashMap)38 Response (javax.ws.rs.core.Response)38 ArrayList (java.util.ArrayList)29 Map (java.util.Map)26 RouteBuilder (org.apache.camel.builder.RouteBuilder)25 Customer (org.apache.camel.component.cxf.jaxrs.testbean.Customer)25 ActionResponse (org.openstack4j.model.common.ActionResponse)25 IOException (java.io.IOException)24 DataHandler (javax.activation.DataHandler)21 Producer (org.apache.camel.Producer)21 List (java.util.List)20