Search in sources :

Example 6 with Address

use of org.jsmpp.bean.Address in project camel by apache.

the class SmppSubmitMultiCommandTest method bodyWithSMPP8bitDataCodingNotModified.

@Test
public void bodyWithSMPP8bitDataCodingNotModified() throws Exception {
    final byte dataCoding = (byte) 0x04;
    /* SMPP 8-bit */
    byte[] body = { (byte) 0xFF, 'A', 'B', (byte) 0x00, (byte) 0xFF, (byte) 0x7F, 'C', (byte) 0xFF };
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
    exchange.getIn().setHeader(SmppConstants.DATA_CODING, dataCoding);
    exchange.getIn().setBody(body);
    Address[] destAddrs = new Address[] { new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717") };
    expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), aryEq(destAddrs), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), aryEq(body))).andReturn(new SubmitMultiResult("1"));
    replay(session);
    command.execute(exchange);
    verify(session);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Address(org.jsmpp.bean.Address) SubmitMultiResult(org.jsmpp.bean.SubmitMultiResult) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 7 with Address

use of org.jsmpp.bean.Address in project camel by apache.

the class SmppSubmitMultiCommandTest method bodyWithGSM8bitDataCodingNotModified.

@Test
public void bodyWithGSM8bitDataCodingNotModified() throws Exception {
    final byte dataCoding = (byte) 0xF7;
    /* GSM 8-bit class 3 */
    byte[] body = { (byte) 0xFF, 'A', 'B', (byte) 0x00, (byte) 0xFF, (byte) 0x7F, 'C', (byte) 0xFF };
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
    exchange.getIn().setHeader(SmppConstants.DATA_CODING, dataCoding);
    exchange.getIn().setBody(body);
    Address[] destAddrs = new Address[] { new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717") };
    expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), aryEq(destAddrs), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance(dataCoding)), eq((byte) 0), aryEq(body))).andReturn(new SubmitMultiResult("1"));
    replay(session);
    command.execute(exchange);
    verify(session);
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Address(org.jsmpp.bean.Address) SubmitMultiResult(org.jsmpp.bean.SubmitMultiResult) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 8 with Address

use of org.jsmpp.bean.Address in project camel by apache.

the class SmppSubmitMultiCommandTest method executeWithOptionalParameter.

@Test
public void executeWithOptionalParameter() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
    exchange.getIn().setHeader(SmppConstants.ID, "1");
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR, Arrays.asList("1919"));
    exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
    exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, new Date(2222222));
    exchange.getIn().setHeader(SmppConstants.PROTOCOL_ID, (byte) 1);
    exchange.getIn().setHeader(SmppConstants.PRIORITY_FLAG, (byte) 2);
    exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
    exchange.getIn().setHeader(SmppConstants.REPLACE_IF_PRESENT_FLAG, ReplaceIfPresentFlag.REPLACE.value());
    Map<String, String> optionalParameters = new LinkedHashMap<String, String>();
    optionalParameters.put("SOURCE_SUBADDRESS", "1292");
    optionalParameters.put("ADDITIONAL_STATUS_INFO_TEXT", "urgent");
    optionalParameters.put("DEST_ADDR_SUBUNIT", "4");
    optionalParameters.put("DEST_TELEMATICS_ID", "2");
    optionalParameters.put("QOS_TIME_TO_LIVE", "3600000");
    optionalParameters.put("ALERT_ON_MESSAGE_DELIVERY", null);
    exchange.getIn().setHeader(SmppConstants.OPTIONAL_PARAMETERS, optionalParameters);
    exchange.getIn().setBody("short message body");
    expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"), aryEq(new Address[] { new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.INTERNET, "1919") }), eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("-300101003702200+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes()), eq(new OptionalParameter.Source_subaddress("1292".getBytes())), eq(new OptionalParameter.Additional_status_info_text("urgent".getBytes())), eq(new OptionalParameter.Dest_addr_subunit((byte) 4)), eq(new OptionalParameter.Dest_telematics_id((short) 2)), eq(new OptionalParameter.Qos_time_to_live(3600000)), eq(new OptionalParameter.Alert_on_message_delivery("O".getBytes())))).andReturn(new SubmitMultiResult("1"));
    replay(session);
    command.execute(exchange);
    verify(session);
    assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
    assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
    assertNull(exchange.getOut().getHeader(SmppConstants.ERROR));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Address(org.jsmpp.bean.Address) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) SubmitMultiResult(org.jsmpp.bean.SubmitMultiResult) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) Test(org.junit.Test)

Example 9 with Address

use of org.jsmpp.bean.Address in project camel by apache.

the class SmppSubmitMultiCommandTest method executeWithValidityPeriodAsString.

@Test
public void executeWithValidityPeriodAsString() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
    exchange.getIn().setHeader(SmppConstants.ID, "1");
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_TON, TypeOfNumber.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR_NPI, NumberingPlanIndicator.NATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.SOURCE_ADDR, "1818");
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_TON, TypeOfNumber.INTERNATIONAL.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR_NPI, NumberingPlanIndicator.INTERNET.value());
    exchange.getIn().setHeader(SmppConstants.DEST_ADDR, Arrays.asList("1919"));
    exchange.getIn().setHeader(SmppConstants.SCHEDULE_DELIVERY_TIME, new Date(1111111));
    // three days
    exchange.getIn().setHeader(SmppConstants.VALIDITY_PERIOD, "000003000000000R");
    exchange.getIn().setHeader(SmppConstants.PROTOCOL_ID, (byte) 1);
    exchange.getIn().setHeader(SmppConstants.PRIORITY_FLAG, (byte) 2);
    exchange.getIn().setHeader(SmppConstants.REGISTERED_DELIVERY, new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE).value());
    exchange.getIn().setHeader(SmppConstants.REPLACE_IF_PRESENT_FLAG, ReplaceIfPresentFlag.REPLACE.value());
    exchange.getIn().setBody("short message body");
    expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"), aryEq(new Address[] { new Address(TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.INTERNET, "1919") }), eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("000003000000000R"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes()))).andReturn(new SubmitMultiResult("1"));
    replay(session);
    command.execute(exchange);
    verify(session);
    assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
    assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
    assertNull(exchange.getOut().getHeader(SmppConstants.ERROR));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Address(org.jsmpp.bean.Address) SubmitMultiResult(org.jsmpp.bean.SubmitMultiResult) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Date(java.util.Date) Test(org.junit.Test)

Example 10 with Address

use of org.jsmpp.bean.Address in project camel by apache.

the class SmppSubmitMultiCommandTest method executeWithConfigurationData.

@Test
public void executeWithConfigurationData() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitMulti");
    exchange.getIn().setHeader(SmppConstants.ID, "1");
    exchange.getIn().setBody("short message body");
    expect(session.submitMultiple(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), aryEq(new Address[] { new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717") }), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes()))).andReturn(new SubmitMultiResult("1", new UnsuccessDelivery(new Address(TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, "1717"), 0)));
    replay(session);
    command.execute(exchange);
    verify(session);
    assertEquals(Arrays.asList("1"), exchange.getOut().getHeader(SmppConstants.ID));
    assertEquals(1, exchange.getOut().getHeader(SmppConstants.SENT_MESSAGE_COUNT));
    assertNotNull(exchange.getOut().getHeader(SmppConstants.ERROR));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Address(org.jsmpp.bean.Address) SubmitMultiResult(org.jsmpp.bean.SubmitMultiResult) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) UnsuccessDelivery(org.jsmpp.bean.UnsuccessDelivery) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Aggregations

Address (org.jsmpp.bean.Address)12 Exchange (org.apache.camel.Exchange)11 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)11 DefaultExchange (org.apache.camel.impl.DefaultExchange)11 ESMClass (org.jsmpp.bean.ESMClass)11 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)11 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)11 Test (org.junit.Test)11 Date (java.util.Date)5 LinkedHashMap (java.util.LinkedHashMap)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Message (org.apache.camel.Message)1 EasyMock.isNull (org.easymock.EasyMock.isNull)1 OptionalParameter (org.jsmpp.bean.OptionalParameter)1 SubmitMulti (org.jsmpp.bean.SubmitMulti)1 UnsuccessDelivery (org.jsmpp.bean.UnsuccessDelivery)1 Assert.assertNotNull (org.junit.Assert.assertNotNull)1 Assert.assertNull (org.junit.Assert.assertNull)1