Search in sources :

Example 11 with ESMClass

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

the class SmppSubmitSmCommandTest method alphabetUpdatesDataCoding.

@Test
public void alphabetUpdatesDataCoding() throws Exception {
    final byte incorrectDataCoding = (byte) 0x00;
    byte[] body = { 'A', 'B', 'C' };
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
    exchange.getIn().setHeader(SmppConstants.ALPHABET, Alphabet.ALPHA_8_BIT.value());
    exchange.getIn().setBody(body);
    expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), not(eq(DataCodings.newInstance(incorrectDataCoding))), eq((byte) 0), aryEq(body))).andReturn("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) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 12 with ESMClass

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

the class SmppSubmitSmCommandTest method execute.

@Test
public void execute() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
    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, "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());
    exchange.getIn().setBody("short message body");
    expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"), eq(TypeOfNumber.INTERNATIONAL), eq(NumberingPlanIndicator.INTERNET), eq("1919"), eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("-300101003702200+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("short message body".getBytes()))).andReturn("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));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) 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 13 with ESMClass

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

the class SmppSubmitSmCommandTest method executeWithConfigurationData.

@Test
public void executeWithConfigurationData() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
    exchange.getIn().setHeader(SmppConstants.ID, "1");
    exchange.getIn().setBody("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
    expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1616"), eq(TypeOfNumber.UNKNOWN), eq(NumberingPlanIndicator.UNKNOWN), eq("1717"), eq(new ESMClass()), eq((byte) 0), eq((byte) 1), (String) isNull(), (String) isNull(), eq(new RegisteredDelivery(SMSCDeliveryReceipt.SUCCESS_FAILURE)), eq(ReplaceIfPresentFlag.DEFAULT.value()), eq(DataCodings.newInstance((byte) 0)), eq((byte) 0), aryEq("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890".getBytes()))).andReturn("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));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) ESMClass(org.jsmpp.bean.ESMClass) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 14 with ESMClass

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

the class SmppSubmitSmCommandTest method executeWithOptionalParameter.

@Test
public void executeWithOptionalParameter() throws Exception {
    Exchange exchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    exchange.getIn().setHeader(SmppConstants.COMMAND, "SubmitSm");
    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, "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());
    exchange.getIn().setBody("short message body");
    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);
    expect(session.submitShortMessage(eq("CMT"), eq(TypeOfNumber.NATIONAL), eq(NumberingPlanIndicator.NATIONAL), eq("1818"), eq(TypeOfNumber.INTERNATIONAL), eq(NumberingPlanIndicator.INTERNET), eq("1919"), eq(new ESMClass()), eq((byte) 1), eq((byte) 2), eq("-300101001831100+"), eq("-300101003702200+"), eq(new RegisteredDelivery(SMSCDeliveryReceipt.FAILURE)), eq(ReplaceIfPresentFlag.REPLACE.value()), 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((byte) 0)))).andReturn("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));
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) 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) RegisteredDelivery(org.jsmpp.bean.RegisteredDelivery) Test(org.junit.Test)

Example 15 with ESMClass

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

the class SmppSubmitMultiCommand method createSubmitMulti.

protected SubmitMulti[] createSubmitMulti(Exchange exchange) throws SmppException {
    byte[][] segments = splitBody(exchange.getIn());
    ESMClass esmClass;
    // multipart message
    if (segments.length > 1) {
        esmClass = new ESMClass(MessageMode.DEFAULT, MessageType.DEFAULT, GSMSpecificFeature.UDHI);
    } else {
        esmClass = new ESMClass();
    }
    SubmitMulti template = createSubmitMultiTemplate(exchange);
    SubmitMulti[] submitMulties = new SubmitMulti[segments.length];
    for (int i = 0; i < segments.length; i++) {
        SubmitMulti submitMulti = SmppUtils.copySubmitMulti(template);
        submitMulti.setEsmClass(esmClass.value());
        submitMulti.setDataCoding(template.getDataCoding());
        submitMulti.setShortMessage(segments[i]);
        submitMulties[i] = submitMulti;
    }
    return submitMulties;
}
Also used : ESMClass(org.jsmpp.bean.ESMClass) SubmitMulti(org.jsmpp.bean.SubmitMulti)

Aggregations

ESMClass (org.jsmpp.bean.ESMClass)36 RegisteredDelivery (org.jsmpp.bean.RegisteredDelivery)33 Exchange (org.apache.camel.Exchange)30 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)30 DefaultExchange (org.apache.camel.impl.DefaultExchange)30 Test (org.junit.Test)30 SubmitMultiResult (org.jsmpp.bean.SubmitMultiResult)12 Address (org.jsmpp.bean.Address)11 Date (java.util.Date)9 LinkedHashMap (java.util.LinkedHashMap)6 DataSmResult (org.jsmpp.session.DataSmResult)5 Message (org.apache.camel.Message)4 MessageId (org.jsmpp.util.MessageId)4 OptionalParameter (org.jsmpp.bean.OptionalParameter)3 SubmitSm (org.jsmpp.bean.SubmitSm)3 ArrayList (java.util.ArrayList)2 EasyMock.isNull (org.easymock.EasyMock.isNull)2 SubmitMulti (org.jsmpp.bean.SubmitMulti)2 UnsuccessDelivery (org.jsmpp.bean.UnsuccessDelivery)2 Assert.assertNull (org.junit.Assert.assertNull)2