Package ie.omk.smpp

Examples of ie.omk.smpp.Connection


    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


    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

    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

    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);
View Full Code Here

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

    }).start();

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

    DeliverSM deliverSm = (DeliverSM) packet;
    Assert.assertEquals(deliverSm.getEsmClass(), (byte) 0x04);
View Full Code Here

  private Connection connect(int port) throws UnknownHostException {
    APIConfig.getInstance().setProperty(APIConfig.BIND_TIMEOUT, 3000 + "");
    APIConfig.getInstance().setProperty(APIConfig.LINK_TIMEOUT, 3000 + "");

    TcpLink link = new TcpLink("localhost", port);
    Connection connection = new Connection(link, false);
    connection.autoAckLink(true);
    connection.autoAckMessages(true);

    return connection;
  }
View Full Code Here

    private Connection bind() throws Exception {
      TcpLink link = null;

      try {
        link = new TcpLink(configuration.getHost(), configuration.getPort());
        connection = new Connection(link, true);
        autoAckMessages(connection);

        MessageListener messageListener = new MessageListener();
        connection.addObserver(messageListener);
View Full Code Here

TOP

Related Classes of ie.omk.smpp.Connection

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.