Package org.mokai.connector.smpp

Examples of org.mokai.connector.smpp.SmppConnector$EnquireLinkThread


    Assert.assertEquals(server.getStatus(), SmppServer.Status.STOPPED);
  }

  @Test
  public void testSupport() throws Exception {
    SmppConnector connector = new SmppConnector();

    Assert.assertFalse(connector.supports(new Message()));
    Assert.assertFalse(connector.supports(new Message().setProperty("to", "")));
    Assert.assertTrue(connector.supports(new Message().setProperty("to", "3")));
    Assert.assertTrue(connector.supports(new Message().setProperty("to", "5730021111111111")));
    Assert.assertFalse(connector.supports(new Message().setProperty("to", "5730021111111111a")));
    Assert.assertFalse(connector.supports(new Message().setProperty("to", "5730021111111111.")));
    Assert.assertFalse(connector.supports(new Message().setProperty("to", "5730021111111111,")));
  }
View Full Code Here


    configuration.setHost("localhost");
    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
    configuration.setPassword("test");

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    Assert.assertEquals(connector.getStatus(), Status.UNKNOWN);

    connector.doStart();
    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    try {
      stopSimulator();
      waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.FAILED);

      startSimulator();
      waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

      Assert.assertEquals(connector.getStatus(), Status.OK);
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setPassword("test");
    configuration.setSystemType("test");
    configuration.setBindNPI("1");
    configuration.setBindTON("2");

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    connector.doStart();
    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    connector.doStop();

    // validate the bind packet
    Bind bind = pp.getBindPacket(DEFAULT_TIMEOUT);
    Assert.assertNotNull( bind );
    Assert.assertEquals( bind.getCommandId(), SmppPacket.BIND_TRANSCEIVER );
View Full Code Here

    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
    configuration.setPassword("test");
    configuration.setDataCoding(3);

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    injectResource(messageStore, connector);
    connector.doStart();
    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    try {
      Message message = new Message();
      message.setProperty("to", "3002175604");
      message.setProperty("from", "3542");
      message.setProperty("text", "This is the test with ñ");

      connector.process(message);

      Assert.assertNotNull(message.getReference());

      Mockito.verify(messageStore, Mockito.timeout(1000)).saveOrUpdate(Mockito.any(Message.class));

      List<SmppPacket> packets = pp.getPackets(1, DEFAULT_TIMEOUT);
      Assert.assertNotNull(packets);
      Assert.assertEquals(packets.size(), 1);

      SubmitSm submitSM = (SubmitSm) packets.get(0);
      Assert.assertNotNull(submitSM);
      Assert.assertEquals(submitSM.getDestAddress().getAddress(), "3002175604");
      Assert.assertEquals(submitSM.getSourceAddress().getAddress(), "3542");
      Assert.assertEquals(submitSM.getDataCoding(), 3);

      Assert.assertEquals(submitSM.getShortMessage(), "This is the test with ñ");
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
    configuration.setPassword("test");
    configuration.setDataCoding(3);

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    injectResource(messageStore, connector);
    connector.doStart();
    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    try {
      Message message = new Message();
      message.setProperty("to", "3002175604");
      message.setProperty("from", "3542");
      message.setProperty("text", "This is a long message to test how the smpp is working with long message splitting them by the 160 character and sending two messages. Finish the first message This is the second message.");

      connector.process(message);

      Assert.assertNotNull(message.getReference());

      List<SmppPacket> packets = pp.getPackets(2, DEFAULT_TIMEOUT);
      Assert.assertNotNull(packets);
      Assert.assertEquals(packets.size(), 2);

      SmppPacket packet = packets.get(0);
      Assert.assertNotNull(packet);
      Assert.assertEquals( packet.getCommandId(), SmppPacket.SUBMIT_SM );

      SubmitSm submitSm = (SubmitSm) packet;
      Assert.assertEquals( submitSm.getShortMessage(), "This is a long message to test how the smpp is working with long message splitting them by the 160 character and sending two messages. Finish the first message ");

      Tlv totalTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
      Assert.assertNotNull(totalTlv);
      Assert.assertEquals(ByteArrayUtil.toByte(totalTlv.getValue()), 2);

      Tlv segmentTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
      Assert.assertNotNull(segmentTlv);
      Assert.assertEquals(ByteArrayUtil.toByte(segmentTlv.getValue()), 1);

      Tlv msgRefTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
      Assert.assertNotNull(msgRefTlv);

      packet = packets.get(1);
      Assert.assertNotNull(packet);
      Assert.assertEquals( packet.getCommandId(), SmppPacket.SUBMIT_SM );

      submitSm = (SubmitSm) packet;
      Assert.assertEquals( submitSm.getShortMessage(), "This is the second message." );

      totalTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
      Assert.assertNotNull(totalTlv);
      Assert.assertEquals(ByteArrayUtil.toByte(totalTlv.getValue()), 2);

      segmentTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
      Assert.assertNotNull(segmentTlv);
      Assert.assertEquals(ByteArrayUtil.toByte(segmentTlv.getValue()), 2);

      msgRefTlv = submitSm.getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
      Assert.assertNotNull(msgRefTlv);
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setHost("localhost");
    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
    configuration.setPassword("test");

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    injectResource(messageProducer, connector);
    connector.doStart();

    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    try {
      String to = "3542";
      String from = "3002175604";
      String text = "this is a test";

      // retrieve the session
      Assert.assertEquals(server.getSessions().size(), 1);
      SmppSession session = server.getSessions().iterator().next();
      Assert.assertNotNull(session);

      // create and send the request
      DeliverSm deliverSM = new DeliverSm();
      deliverSM.setDestAddress(new Address((byte) 0, (byte) 0, to));
      deliverSM.setSourceAddress(new Address((byte) 0, (byte) 0, from));
      deliverSM.setShortMessage(text.getBytes());

      session.sendRequest(deliverSM);

      long timeout = 2000;
      if (!receiveMessage(messageProducer, timeout)) {
        Assert.fail("the message was not received");
      }

      Message message = (Message) messageProducer.getMessage(0);
      Assert.assertEquals(to, message.getProperty("to", String.class));
      Assert.assertEquals(from, message.getProperty("from", String.class));
      Assert.assertEquals(text, message.getProperty("text", String.class));
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setSystemId("test");
    configuration.setPassword("test");

    MockMessageStore messageStore = new MockMessageStore();
    MockMessageProducer messageProducer = new MockMessageProducer();
    SmppConnector connector = createAndStartSmppConnector(configuration, messageStore, messageProducer);

    try {
      String from = "3542";
      String to = "3002175604";

      // send a message
      Message message = new Message();
      message.setProperty("to", to);
      message.setProperty("from", from);
      message.setProperty("text", "This is the test");
      message.setProperty("receiptDestination", "test");
      sendMessage(connector, messageStore, message);

      // retrieve the session
      Assert.assertEquals(server.getSessions().size(), 1);
      SmppSession session = server.getSessions().iterator().next();
      Assert.assertNotNull(session);

      DeliverSm deliverSM = new DeliverSm();
      deliverSM.setEsmClass(SmppConstants.ESM_CLASS_MT_SMSC_DELIVERY_RECEIPT);
      deliverSM.setDestAddress(new Address((byte) 0, (byte) 0, from));
      deliverSM.setSourceAddress(new Address((byte) 0, (byte) 0, to));
      deliverSM.setShortMessage("id:12000 sub:1 dlvrd:1 submit date:1101010000 done date:1101010000 stat:DELIVRD err:0 text:This is a ... ".getBytes());

      session.sendRequest(deliverSM);

      long timeout = 2000;
      if (!receiveMessage(messageProducer, timeout)) {
        Assert.fail("the delivery receipt was not received");
      }

      Message receivedMessage = (Message) messageProducer.getMessage(0);
      Assert.assertEquals(from, receivedMessage.getProperty("to", String.class));
      Assert.assertEquals(to, receivedMessage.getProperty("from", String.class));
      Assert.assertEquals(receivedMessage.getProperty("messageId", String.class), 12000 + "");
      Assert.assertEquals("DELIVRD", receivedMessage.getProperty("finalStatus", String.class));
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setPassword("test");
    configuration.setDlrIdConversion(DlrIdConversion.HEXA_TO_DEC);

    MockMessageStore messageStore = new MockMessageStore();
    MockMessageProducer messageProducer = new MockMessageProducer();
    SmppConnector connector = createAndStartSmppConnector(configuration, messageStore, messageProducer);

    try {
      // send a message
      Message message = new Message();
      message.setProperty("to", "3542");
      message.setProperty("from", "3002175604");
      message.setProperty("text", "This is the test");
      message.setProperty("receiptDestination", "test");
      sendMessage(connector, messageStore, message);

      // retrieve the session
      Assert.assertEquals(server.getSessions().size(), 1);
      SmppSession session = server.getSessions().iterator().next();
      Assert.assertNotNull(session);

      DeliverSm deliverSM = new DeliverSm();
      deliverSM.setEsmClass(SmppConstants.ESM_CLASS_MT_SMSC_DELIVERY_RECEIPT);
      deliverSM.setDestAddress(new Address((byte) 0, (byte) 0, "3002175604"));
      deliverSM.setSourceAddress(new Address((byte) 0, (byte) 0, "3542"));
      deliverSM.setShortMessage("id:16fee0e525 sub:1 dlvrd:1 submit date:1101010000 done date:1101010000 stat:DELIVRD err:0 text:This is a ... ".getBytes());

      session.sendRequest(deliverSM);

      long timeout = 2000;
      if (!receiveMessage(messageProducer, timeout)) {
        Assert.fail("the delivery receipt was not received");
      }

      Message receivedMessage = (Message) messageProducer.getMessage(0);
      Assert.assertNotNull(receivedMessage);
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setPassword("test");
    configuration.setDlrIdConversion(DlrIdConversion.DEC_TO_HEXA);

    MockMessageStore messageStore = new MockMessageStore();
    MockMessageProducer messageProducer = new MockMessageProducer();
    SmppConnector connector = createAndStartSmppConnector(configuration, messageStore, messageProducer);

    try {
      // send a message
      Message message = new Message();
      message.setProperty("to", "3542");
      message.setProperty("from", "3002175604");
      message.setProperty("text", "This is the test");
      message.setProperty("receiptDestination", "test");
      sendMessage(connector, messageStore, message);

      // retrieve the session
      Assert.assertEquals(server.getSessions().size(), 1);
      SmppSession session = server.getSessions().iterator().next();
      Assert.assertNotNull(session);

      DeliverSm deliverSM = new DeliverSm();
      deliverSM.setEsmClass(SmppConstants.ESM_CLASS_MT_SMSC_DELIVERY_RECEIPT);
      deliverSM.setDestAddress(new Address((byte) 0, (byte) 0, "3002175604"));
      deliverSM.setSourceAddress(new Address((byte) 0, (byte) 0, "3542"));
      deliverSM.setShortMessage("id:98765432101 sub:1 dlvrd:1 submit date:1101010000 done date:1101010000 stat:DELIVRD err:0 text:This is a ... ".getBytes());

      session.sendRequest(deliverSM);

      long timeout = 2000;
      if (!receiveMessage(messageProducer, timeout)) {
        Assert.fail("the delivery receipt was not received");
      }

      Message receivedMessage = (Message) messageProducer.getMessage(0);
      Assert.assertNotNull(receivedMessage);
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

    configuration.setPassword("test");
    configuration.addFailedCommandStatus(Response.MESSAGE_QUEUE_FULL.getCommandStatus());

    MockMessageStore messageStore = new MockMessageStore();
    MockMessageProducer messageProducer = new MockMessageProducer();
    SmppConnector connector = createAndStartSmppConnector(configuration, messageStore, messageProducer);

    try {
      // send a message
      Message message = new Message();
      message.setProperty("to", "3542");
      message.setProperty("from", "3002175604");
      message.setProperty("text", "This is the test");
      sendMessage(connector, messageStore, message);

      Assert.assertEquals(messageStore.messages.size(), 1);

      Message m1 = messageStore.messages.iterator().next();
      Assert.assertNotNull(m1);

      waitMessageUntilStatus(m1, DEFAULT_TIMEOUT, Message.STATUS_FAILED);
      Assert.assertEquals(m1.getStatus(), Message.STATUS_FAILED);
    } finally {
      connector.doStop();
    }
  }
View Full Code Here

TOP

Related Classes of org.mokai.connector.smpp.SmppConnector$EnquireLinkThread

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.