Search in sources :

Example 6 with Sms

use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm_Gsm7Enc.

@Test(groups = { "TxSmppServer" })
public void testSubmitSm_Gsm7Enc() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.smppSess = new SmppSessionsProxy();
    this.sbb.setSmppServerSessions(smppSess);
    int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
    long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
    long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
    long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
    long windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
    long windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
    Esme esme = new Esme("Esme_1", "Esme_systemId_1", "pwd", "host", 0, false, null, SmppInterfaceVersionType.SMPP34, -1, -1, null, SmppBindType.TRANSCEIVER, SmppSession.Type.CLIENT, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, "Esme_1", true, 30000, 0, 0, -1, -1, "^[0-9a-zA-Z]*", -1, -1, "^[0-9a-zA-Z]*", 0, false, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1);
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    SubmitSm event = new SubmitSm();
    Date curDate = new Date();
    this.fillSm(event, curDate, true);
    event.setShortMessage(msgGsm7);
    event.setDataCoding((byte) 0);
    event.setEsmClass((byte) 3);
    // byte[] bbb = new byte[25500];
    // bbb[0] = 6;
    // bbb[1] = 36;
    // bbb[2] = 1;
    // bbb[3] = 13;
    // bbb[4] = 37;
    // bbb[5] = 1;
    // bbb[6] = 13;
    // for (int i = 7; i < 25500; i++) {
    // bbb[i] = 0x41;
    // }
    // event.setShortMessage(null);
    // Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, bbb);
    // event.addOptionalParameter(tlv);
    // TxSmppServerSbb.smscPropertiesManagement.setNationalLanguageLockingShift(13);
    // TxSmppServerSbb.smscPropertiesManagement.setNationalLanguageSingleShift(13);
    // event.setEsmClass((byte) 67);
    long dueSlot = this.pers.c2_getDueSlotForTime(scheduleDeliveryTime);
    PreparedStatementCollection psc = this.pers.getStatementCollection(scheduleDeliveryTime);
    int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    assertEquals(b1, 0);
    assertEquals(b2, 0L);
    TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForGsm7(SmppEncoding.Gsm7);
    this.sbb.onSubmitSm(event, aci);
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    // this.checkSmsSet(smsSet, curDate, true);
    Sms sms = smsSet.getSms(0);
    // msgGsm7
    assertEquals(sms.getShortMessageText(), sMsg_4);
    assertNull(sms.getShortMessageBin());
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    PduResponse resp = this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 0);
    assertEquals(resp.getOptionalParameterCount(), 0);
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) Esme(org.restcomm.smpp.Esme) Sms(org.mobicents.smsc.library.Sms) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 7 with Sms

use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm_createSmsEvent.

@Test(groups = { "TxSmppServer" })
public void testSubmitSm_createSmsEvent() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.smppSess = new SmppSessionsProxy();
    this.sbb.setSmppServerSessions(smppSess);
    TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Utf8);
    SmscPropertiesManagement spm = SmscPropertiesManagement.getInstance("Test");
    String sMsgA = "������Hel";
    // only message part
    Charset utf8 = Charset.forName("UTF-8");
    ByteBuffer bb = utf8.encode(sMsgA);
    byte[] aMsgA = new byte[bb.limit()];
    bb.get(aMsgA);
    Charset ucs2 = Charset.forName("UTF-16BE");
    bb = ucs2.encode(sMsgA);
    byte[] aMsgAA = new byte[bb.limit()];
    bb.get(aMsgAA);
    com.cloudhopper.smpp.pdu.SubmitSm event = new com.cloudhopper.smpp.pdu.SubmitSm();
    Address addr = new Address();
    addr.setNpi((byte) 1);
    addr.setTon((byte) 1);
    addr.setAddress("2222");
    event.setSourceAddress(addr);
    Address addr2 = new Address();
    addr2.setNpi((byte) 1);
    addr2.setTon((byte) 1);
    addr2.setAddress("5555");
    event.setDestAddress(addr2);
    event.setDataCoding((byte) 8);
    event.setShortMessage(aMsgA);
    Esme origEsme = new Esme();
    TargetAddress ta = ta1;
    Sms sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
    assertEquals(sms.getShortMessageText(), sMsgA);
    // message part and UDH
    byte[] udh = new byte[] { 0x05, 0x00, 0x03, 0x29, 0x02, 0x02 };
    byte[] aMsgB = new byte[aMsgA.length + udh.length];
    System.arraycopy(udh, 0, aMsgB, 0, udh.length);
    System.arraycopy(aMsgA, 0, aMsgB, udh.length, aMsgA.length);
    event = new com.cloudhopper.smpp.pdu.SubmitSm();
    event.setSourceAddress(addr);
    event.setDestAddress(addr2);
    event.setDataCoding((byte) 8);
    event.setShortMessage(aMsgB);
    event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
    sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
    assertEquals(sms.getShortMessageText(), sMsgA);
    assertEquals(sms.getShortMessageBin(), udh);
    // binary GSM8
    String s1 = "Optic xxx";
    Charset iso = Charset.forName("ISO-8859-1");
    byte[] aMsgC = s1.getBytes(iso);
    byte[] aMsgCC = new byte[aMsgC.length + udh.length];
    System.arraycopy(udh, 0, aMsgCC, 0, udh.length);
    System.arraycopy(aMsgC, 0, aMsgCC, udh.length, aMsgC.length);
    event = new com.cloudhopper.smpp.pdu.SubmitSm();
    event.setSourceAddress(addr);
    event.setDestAddress(addr2);
    event.setDataCoding((byte) 4);
    event.setShortMessage(aMsgCC);
    event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
    sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
    assertEquals(sms.getShortMessageText(), s1);
    assertEquals(sms.getShortMessageBin(), udh);
    // GSM7
    event = new com.cloudhopper.smpp.pdu.SubmitSm();
    event.setSourceAddress(addr);
    event.setDestAddress(addr2);
    event.setDataCoding((byte) 0);
    event.setShortMessage(aMsgC);
    sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
    assertEquals(sms.getShortMessageText(), s1);
    assertNull(sms.getShortMessageBin());
}
Also used : TargetAddress(org.mobicents.smsc.library.TargetAddress) Address(com.cloudhopper.smpp.type.Address) Esme(org.restcomm.smpp.Esme) Charset(java.nio.charset.Charset) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) ByteBuffer(java.nio.ByteBuffer) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) Sms(org.mobicents.smsc.library.Sms) Test(org.testng.annotations.Test)

Example 8 with Sms

use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testDataSm.

@Test(groups = { "TxSmppServer" })
public void testDataSm() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.smppSess = new SmppSessionsProxy();
    this.sbb.setSmppServerSessions(smppSess);
    int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
    long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
    long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
    long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
    long windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
    long windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
    Esme esme = new Esme("Esme_1", "Esme_systemId_1", "pwd", "host", 0, false, null, SmppInterfaceVersionType.SMPP34, -1, -1, null, SmppBindType.TRANSCEIVER, SmppSession.Type.CLIENT, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, "Esme_1", true, 30000, 0, 0, -1, -1, "^[0-9a-zA-Z]*", -1, -1, "^[0-9a-zA-Z]*", 0, false, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1);
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    DataSm event = new DataSm();
    Date curDate = new Date();
    this.fillSm(event, curDate, false);
    Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msgUtf8);
    event.addOptionalParameter(tlv);
    tlv = new Tlv(SmppConstants.TAG_SAR_MSG_REF_NUM, msg_ref_num);
    event.addOptionalParameter(tlv);
    tlv = new Tlv(SmppConstants.TAG_SAR_SEGMENT_SEQNUM, new byte[] { 1 });
    event.addOptionalParameter(tlv);
    tlv = new Tlv(SmppConstants.TAG_SAR_TOTAL_SEGMENTS, new byte[] { 2 });
    event.addOptionalParameter(tlv);
    long dueSlot = this.pers.c2_getDueSlotForTime(new Date());
    PreparedStatementCollection psc = this.pers.getStatementCollection(new Date());
    int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    assertEquals(b1, 0);
    assertEquals(b2, 0L);
    TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Utf8);
    this.sbb.onDataSm(event, aci);
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    dueSlot = b2;
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    assertEquals(b2, dueSlot);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    this.checkSmsSet(smsSet, curDate, false);
    Sms sms = smsSet.getSms(0);
    // msgUcs2
    assertEquals(sms.getShortMessageText(), sMsg);
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    PduResponse resp = this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 0);
    assertEquals(resp.getOptionalParameterCount(), 0);
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) DataSm(com.cloudhopper.smpp.pdu.DataSm) Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Tlv(com.cloudhopper.smpp.tlv.Tlv) Test(org.testng.annotations.Test)

Example 9 with Sms

use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitMulti.

@Test(groups = { "TxSmppServer" })
public void testSubmitMulti() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.smppSess = new SmppSessionsProxy();
    this.sbb.setSmppServerSessions(smppSess);
    int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
    long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
    long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
    long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
    long windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
    long windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
    Esme esme = new Esme("Esme_1", "Esme_systemId_1", "pwd", "host", 0, false, null, SmppInterfaceVersionType.SMPP34, -1, -1, null, SmppBindType.TRANSCEIVER, SmppSession.Type.CLIENT, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, "Esme_1", true, 30000, 0, 0, -1, -1, "^[0-9a-zA-Z]*", -1, -1, "^[0-9a-zA-Z]*", 0, false, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1);
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    SubmitMulti event = new SubmitMulti();
    Date curDate = new Date();
    this.fillSm(event, curDate, true);
    event.setShortMessage(msgUcs2);
    Address destAddr = new Address();
    destAddr.setAddress("5555");
    destAddr.setTon(SmppConstants.TON_INTERNATIONAL);
    destAddr.setNpi(SmppConstants.NPI_E164);
    event.addDestAddresses(destAddr);
    Address destAddr2 = new Address();
    destAddr2.setAddress("5556");
    destAddr2.setTon(SmppConstants.TON_INTERNATIONAL);
    destAddr2.setNpi(SmppConstants.NPI_E164);
    event.addDestAddresses(destAddr2);
    long dueSlot = this.pers.c2_getDueSlotForTime(scheduleDeliveryTime);
    PreparedStatementCollection psc = this.pers.getStatementCollection(scheduleDeliveryTime);
    int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    assertEquals(b1, 0);
    assertEquals(b2, 0L);
    b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
    assertEquals(b1, 0);
    assertEquals(b2, 0L);
    TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
    this.sbb.onSubmitMulti(event, aci);
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
    assertEquals(b1, 1);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    this.checkSmsSet(smsSet, curDate, true);
    Sms sms = smsSet.getSms(0);
    // msgUcs2
    assertEquals(sms.getShortMessageText(), sMsg);
    assertEquals(sms.getShortMessageBin(), udhCode);
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    SubmitMultiResp resp = (SubmitMultiResp) this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 0);
    assertEquals(resp.getOptionalParameterCount(), 0);
    assertEquals(resp.getUnsucessfulSmes().size(), 0);
}
Also used : TargetAddress(org.mobicents.smsc.library.TargetAddress) Address(com.cloudhopper.smpp.type.Address) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SubmitMultiResp(com.cloudhopper.smpp.pdu.SubmitMultiResp) Sms(org.mobicents.smsc.library.Sms) SubmitMulti(com.cloudhopper.smpp.pdu.SubmitMulti) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 10 with Sms

use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.

the class DBOperations method c2_getRecordArchiveForMessageId.

public Sms c2_getRecordArchiveForMessageId(long messageId) throws PersistenceException {
    Sms sms = SmsSetCache.getInstance().getDeliveredMsgValue(messageId);
    if (sms != null)
        return sms;
    SmsSet result = null;
    try {
        // first step - today search
        Date date = new Date();
        PreparedStatementCollection psc = getStatementCollection(date);
        result = this.doGetArchiveMsg(messageId, psc);
        if (result == null) {
            // second step - yesterday search
            Date date2 = new Date(date.getTime() - 1000 * 3600 * 24);
            psc = getStatementCollection(date2);
            result = this.doGetArchiveMsg(messageId, psc);
        }
    } catch (Exception e1) {
        String msg = "Failed getRecordArchiveForMessageId()";
        throw new PersistenceException(msg, e1);
    }
    if (result != null)
        return result.getSms(0);
    else
        return null;
}
Also used : Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Date(java.util.Date) XMLStreamException(javolution.xml.stream.XMLStreamException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException)

Aggregations

Sms (org.mobicents.smsc.library.Sms)139 SmsSet (org.mobicents.smsc.library.SmsSet)62 Test (org.testng.annotations.Test)43 Date (java.util.Date)42 ArrayList (java.util.ArrayList)35 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)33 TargetAddress (org.mobicents.smsc.library.TargetAddress)30 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)27 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)27 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)26 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)24 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)23 UUID (java.util.UUID)22 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)21 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)19 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)19 MAPApplicationContextVersion (org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)17 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)17