Search in sources :

Example 11 with DeliverSm

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

the class MessageReceiverListenerImplTest method onAcceptDeliverSmException.

@Test
public void onAcceptDeliverSmException() throws Exception {
    DeliverSm deliverSm = createMock(DeliverSm.class);
    Exchange exchange = createMock(Exchange.class);
    expect(endpoint.createOnAcceptDeliverSmExchange(deliverSm)).andReturn(exchange);
    processor.process(exchange);
    expect(exchange.getException()).andReturn(null);
    replay(endpoint, processor, exceptionHandler, deliverSm, exchange);
    listener.onAcceptDeliverSm(deliverSm);
    verify(endpoint, processor, exceptionHandler, deliverSm, exchange);
}
Also used : Exchange(org.apache.camel.Exchange) DeliverSm(org.jsmpp.bean.DeliverSm) Test(org.junit.Test)

Example 12 with DeliverSm

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

the class SmppBindingTest method createSmppMessageFromDeliverSmWithPayloadInOptionalParameterShouldReturnASmppMessage.

@Test
public void createSmppMessageFromDeliverSmWithPayloadInOptionalParameterShouldReturnASmppMessage() throws Exception {
    DeliverSm deliverSm = new DeliverSm();
    deliverSm.setSequenceNumber(1);
    deliverSm.setCommandId(1);
    deliverSm.setSourceAddr("1818");
    deliverSm.setSourceAddrNpi(NumberingPlanIndicator.NATIONAL.value());
    deliverSm.setSourceAddrTon(TypeOfNumber.NATIONAL.value());
    deliverSm.setDestAddress("1919");
    deliverSm.setDestAddrNpi(NumberingPlanIndicator.INTERNET.value());
    deliverSm.setDestAddrTon(TypeOfNumber.NETWORK_SPECIFIC.value());
    deliverSm.setScheduleDeliveryTime("090831230627004+");
    deliverSm.setValidityPeriod("090901230627004+");
    deliverSm.setServiceType("WAP");
    deliverSm.setOptionalParameters(new OctetString(OptionalParameter.Tag.MESSAGE_PAYLOAD, "Hello SMPP world!"));
    SmppMessage smppMessage = binding.createSmppMessage(deliverSm);
    assertEquals("Hello SMPP world!", smppMessage.getBody());
    assertEquals(13, smppMessage.getHeaders().size());
    assertEquals(1, smppMessage.getHeader(SmppConstants.SEQUENCE_NUMBER));
    assertEquals(1, smppMessage.getHeader(SmppConstants.COMMAND_ID));
    assertEquals("1818", smppMessage.getHeader(SmppConstants.SOURCE_ADDR));
    assertEquals((byte) 8, smppMessage.getHeader(SmppConstants.SOURCE_ADDR_NPI));
    assertEquals((byte) 2, smppMessage.getHeader(SmppConstants.SOURCE_ADDR_TON));
    assertEquals("1919", smppMessage.getHeader(SmppConstants.DEST_ADDR));
    assertEquals((byte) 14, smppMessage.getHeader(SmppConstants.DEST_ADDR_NPI));
    assertEquals((byte) 3, smppMessage.getHeader(SmppConstants.DEST_ADDR_TON));
    assertEquals("090831230627004+", smppMessage.getHeader(SmppConstants.SCHEDULE_DELIVERY_TIME));
    assertEquals("090901230627004+", smppMessage.getHeader(SmppConstants.VALIDITY_PERIOD));
    assertEquals("WAP", smppMessage.getHeader(SmppConstants.SERVICE_TYPE));
    assertEquals(SmppMessageType.DeliverSm.toString(), smppMessage.getHeader(SmppConstants.MESSAGE_TYPE));
}
Also used : OctetString(org.jsmpp.bean.OptionalParameter.OctetString) DeliverSm(org.jsmpp.bean.DeliverSm) Test(org.junit.Test)

Example 13 with DeliverSm

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

the class SmppMessageTest method toStringShouldReturnTheShortMessageIfTheCommandIsNotNull.

@Test
public void toStringShouldReturnTheShortMessageIfTheCommandIsNotNull() {
    DeliverSm command = new DeliverSm();
    command.setShortMessage("Hello SMPP world!".getBytes());
    message = new SmppMessage(command, new SmppConfiguration());
    assertEquals("SmppMessage: PDUHeader(0, 00000000, 00000000, 0)", message.toString());
}
Also used : DeliverSm(org.jsmpp.bean.DeliverSm) Test(org.junit.Test)

Example 14 with DeliverSm

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

the class SmppMessageTest method testSmppMessageDeliverSm.

@Test
public void testSmppMessageDeliverSm() {
    DeliverSm command = new DeliverSm();
    message = new SmppMessage(command, new SmppConfiguration());
    assertTrue(message.getCommand() instanceof DeliverSm);
    assertTrue(message.getHeaders().isEmpty());
    assertTrue(message.isDeliverSm());
}
Also used : DeliverSm(org.jsmpp.bean.DeliverSm) Test(org.junit.Test)

Example 15 with DeliverSm

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

the class SmppMessageTest method testSmppMessageDeliverReceipt.

@Test
public void testSmppMessageDeliverReceipt() {
    DeliverSm command = new DeliverSm();
    command.setSmscDeliveryReceipt();
    command.setShortMessage("id:2 sub:001 dlvrd:001 submit date:0908312310 done date:0908312311 stat:DELIVRD err:xxx Text:Hello SMPP world!".getBytes());
    message = new SmppMessage(command, new SmppConfiguration());
    assertTrue(message.getCommand() instanceof DeliverSm);
    assertTrue(message.getHeaders().isEmpty());
    assertTrue(message.isDeliveryReceipt());
}
Also used : DeliverSm(org.jsmpp.bean.DeliverSm) Test(org.junit.Test)

Aggregations

DeliverSm (org.jsmpp.bean.DeliverSm)15 Test (org.junit.Test)15 OctetString (org.jsmpp.bean.OptionalParameter.OctetString)4 Exchange (org.apache.camel.Exchange)3 OptionalParameter (org.jsmpp.bean.OptionalParameter)2