Package org.mokai.connector.smpp

Examples of org.mokai.connector.smpp.SmppServerConnector$CustomPacketProcessor


    MockMessageProducer messageProducer = new MockMessageProducer();

    SmppServerConfiguration configuration = new SmppServerConfiguration();
    configuration.addUser("test", "test");

    SmppServerConnector connector = new SmppServerConnector(configuration);
    injectResource(messageProducer, connector);
    injectResource(buildConnectorContext("test"), connector);
    connector.configure();
    connector.doStart();

    // open connection and bind
    Connection connection = connect(4444);
    bind(connection, Connection.TRANSMITTER, "test", "test", null);

    SubmitSM submitSM = (SubmitSM) connection.newInstance(SMPPPacket.SUBMIT_SM);
    submitSM.setDestination(new Address(0, 0, "573001111111"));
    submitSM.setSource(new Address(0, 0, "3542"));
    submitSM.setMessageText("This is a test");

    SubmitSMResp response = (SubmitSMResp) connection.sendRequest(submitSM);
    Assert.assertNotNull(response);
    Assert.assertTrue(response.getMessageId() != null);

    Assert.assertEquals(messageProducer.messageCount(), 1);
    Message message = messageProducer.getMessage(0);
    Assert.assertNotNull(message);
    Assert.assertEquals(message.getProperty("to", String.class), "573001111111");
    Assert.assertEquals(message.getProperty("from", String.class), "3542");
    Assert.assertEquals(message.getProperty("text", String.class), "This is a test");

    connection.unbind();
    connection.closeLink();

    connector.doStop();
  }
View Full Code Here


    connector.doStop();
  }

  @Test
  public void shouldFailToBindIfBadSystemId() throws Exception {
    SmppServerConnector connector = new SmppServerConnector();
    connector.configure();
    connector.doStart();

    // open connection and bind
    Connection connection = connect(4444);

    BindResp bindResp = connection.bind(Connection.TRANSMITTER, "test", "test", null);
    Assert.assertNotNull(bindResp);
    Assert.assertEquals(bindResp.getCommandStatus(), Response.INVALID_SYSTEM_ID.getCommandStatus());

    connector.doStop();
  }
View Full Code Here

  @Test
  public void shouldFailToBindIfBadPassword() throws Exception {
    SmppServerConfiguration configuration = new SmppServerConfiguration();
    configuration.addUser("test", "test");

    SmppServerConnector connector = new SmppServerConnector(configuration);
    connector.configure();
    connector.doStart();

    Connection connection = connect(4444);
    BindResp bindResp = connection.bind(Connection.TRANSMITTER, "test", "other", null);
    Assert.assertNotNull(bindResp);
    Assert.assertEquals(bindResp.getCommandStatus(), Response.INVALID_PASSWORD.getCommandStatus());

    connector.doStop();
  }
View Full Code Here

  @Test
  public void shouldProduceDeliverSm() throws Exception {
    SmppServerConfiguration configuration = new SmppServerConfiguration();
    configuration.addUser("test", "test");

    final SmppServerConnector connector = new SmppServerConnector(configuration);
    injectResource(buildConnectorContext("test"), connector);
    connector.configure();
    connector.doStart();

    // open connection and bind
    Connection connection = connect(4444);
    bind(connection, Connection.TRANSMITTER, "test", "test", null);

    // send deliver_sm
    new Thread(new Runnable() {

      @Override
      public void run() {
        Message message = new Message();
        message.setProperty("to", "1111");
        message.setProperty("from", "2222");
        message.setProperty("text", "This is a test");

        try {
          connector.process(message);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }

    }).start();

    SMPPPacket packet = connection.readNextPacket();
    Assert.assertNotNull(packet);
    Assert.assertEquals(packet.getCommandId(), SMPPPacket.DELIVER_SM);

    DeliverSM deliverSm = (DeliverSM) packet;
    Assert.assertEquals(deliverSm.getEsmClass(), (byte) 0);
    Assert.assertEquals(deliverSm.getSource().getAddress(), "2222");
    Assert.assertEquals(deliverSm.getDestination().getAddress(), "1111");
    Assert.assertEquals(deliverSm.getMessageText(), "This is a test");

    connector.doStop();
  }
View Full Code Here

  @Test
  public void shouldProduceDeliveryReceipt() throws Exception {
    SmppServerConfiguration configuration = new SmppServerConfiguration();
    configuration.addUser("test", "test");

    final SmppServerConnector connector = new SmppServerConnector(configuration);
    injectResource(buildConnectorContext("test"), connector);
    connector.configure();
    connector.doStart();

    // open connection and bind
    Connection connection = connect(4444);
    bind(connection, Connection.TRANSMITTER, "test", "test", null);

    final SimpleDateFormat sdf = new SimpleDateFormat("yyMMddhhmm");
    final Date submitDate = sdf.parse("1201011023");
    final Date doneDate = sdf.parse("1201011048");

    // send deliver_sm
    new Thread(new Runnable() {

      @Override
      public void run() {
        Message message = new Message();

        message.setProperty("isDLR", true);
        message.setProperty("to", "1111");
        message.setProperty("from", "2222");
        message.setProperty("messageId", "12345");
        message.setProperty("submitted", 1);
        message.setProperty("submitDate", submitDate);
        message.setProperty("delivered", 1);
        message.setProperty("doneDate", doneDate);
        message.setProperty("finalStatus", "DELIVRD");

        try {
          connector.process(message);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
View Full Code Here

TOP

Related Classes of org.mokai.connector.smpp.SmppServerConnector$CustomPacketProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.