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;
}
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));
}
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);
}
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));
}
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));
}
Aggregations