Search in sources :

Example 16 with SmsSet

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

the class CassandraTest method createTestSms.

private Sms createTestSms(int num, String number, UUID id) throws Exception {
    PreparedStatementCollection psc = sbb.getStatementCollection(new Date());
    SmsSet smsSet = new SmsSet();
    smsSet.setDestAddr(number);
    smsSet.setDestAddrNpi(1);
    smsSet.setDestAddrTon(5);
    smsSet.setNetworkId(9);
    if (num == 1)
        smsSet.setCorrelationId("CI=100001000022222");
    Sms sms = new Sms();
    // sms.setSmsSet(smsSet);
    smsSet.addSms(sms);
    // sms.setDbId(UUID.randomUUID());
    sms.setDbId(id);
    sms.setSourceAddr("11112_" + num);
    sms.setSourceAddrTon(14 + num);
    sms.setSourceAddrNpi(11 + num);
    sms.setMessageId(8888888 + num);
    sms.setMoMessageRef(102 + num);
    sms.setOrigNetworkId(49);
    sms.setOrigEsmeName("esme_" + num);
    sms.setOrigSystemId("sys_" + num);
    sms.setSubmitDate(new GregorianCalendar(2013, 1, 15, 12, 00 + num).getTime());
    sms.setDeliveryDate(new GregorianCalendar(2013, 1, 15, 12, 15 + num).getTime());
    sms.setServiceType("serv_type__" + num);
    sms.setEsmClass(11 + num);
    sms.setProtocolId(12 + num);
    sms.setPriority(13 + num);
    sms.setRegisteredDelivery(14 + num);
    sms.setReplaceIfPresent(15 + num);
    sms.setDataCoding(16 + num);
    sms.setDefaultMsgId(17 + num);
    // sms.setShortMessage(new byte[] { (byte)(21 + num), 23, 25, 27, 29 });
    if (num != 2)
        sms.setShortMessageText("Mes text" + num);
    if (num != 3)
        sms.setShortMessageBin(new byte[] { (byte) (21 + num), 23, 25, 27, 29 });
    sms.setScheduleDeliveryTime(new GregorianCalendar(2013, 1, 20, 10, 00 + num).getTime());
    sms.setValidityPeriod(new GregorianCalendar(2013, 1, 23, 13, 33 + num).getTime());
    // short tag, byte[] value, String tagName
    Tlv tlv = new Tlv((short) 5, new byte[] { (byte) (1 + num), 2, 3, 4, 5 });
    sms.getTlvSet().addOptionalParameter(tlv);
    tlv = new Tlv((short) 6, new byte[] { (byte) (6 + num), 7, 8 });
    sms.getTlvSet().addOptionalParameter(tlv);
    smsSet.setDueDelay(510);
    sms.setDeliveryCount(9);
    sms.setOriginatorSccpAddress("11224455");
    sms.setStatusReportRequest(true);
    sms.setDeliveryAttempt(321);
    sms.setUserData("userdata");
    sms.setMprocNotes("mproc notes xxx");
    // sms.setExtraData("extradata_1");
    sms.setExtraData_2("extradata_2");
    sms.setExtraData_3("extradata_3");
    sms.setExtraData_4("extradata_4");
    return sms;
}
Also used : Sms(org.mobicents.smsc.library.Sms) GregorianCalendar(java.util.GregorianCalendar) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) Date(java.util.Date) SmsSet(org.mobicents.smsc.library.SmsSet) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 17 with SmsSet

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

the class CassandraTest method testOldFormatMessage.

// @Test(groups = { "cassandra" })
// public void testingColumnAdding() throws Exception {
// if (!this.cassandraDbInited)
// return;
// 
// Date dt0 = new Date();
// Date dt = new Date(dt0.getTime() - 10 * 24 * 3600 * 1000);
// sbb.c2_deleteLiveTablesForDate(dt);
// sbb.c2_deleteArchiveTablesForDate(dt);
// 
// PreparedStatementCollection_C3 psc = sbb.getStatementCollection(dt);
// long newDueSlot = sbb.c2_getDueSlotForTime(dt);
// sbb.c2_updateDueSlotForTargetId("222222_1_11", newDueSlot);
// 
// String[] ss = sbb.getLiveTableListAsNames(sbb.getKeyspaceName());
// String s = ss[0];
// boolean res = sbb.checkFieldInTable(s, "extra_col");
// assertFalse(res);
// sbb.addFieldsToLiveTables(sbb.getKeyspaceName(), "extra_col", "text");
// 
// res = sbb.checkFieldInTable(s, "extra_col");
// assertTrue(res);
// }
public void testOldFormatMessage(TargetAddress ta, DataCodingScheme dcs, String msg, UserDataHeader udh) throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    TargetAddress lock = this.sbb.obtainSynchroObject(ta);
    long dueSlot;
    Sms sms;
    try {
        synchronized (lock) {
            SmsSet smsSet = new SmsSet();
            smsSet.setDestAddr(ta.getAddr());
            smsSet.setDestAddrNpi(ta.getAddrNpi());
            smsSet.setDestAddrTon(ta.getAddrTon());
            smsSet.setCorrelationId("CI=0000");
            smsSet.setNetworkId(9);
            sms = new Sms();
            sms.setSmsSet(smsSet);
            sms.setDbId(UUID.randomUUID());
            sms.setSourceAddr("11112");
            sms.setSourceAddrTon(1);
            sms.setSourceAddrNpi(1);
            sms.setMessageId(8888888);
            sms.setOrigNetworkId(49);
            sms.setDataCoding(dcs.getCode());
            sms.setShortMessageText(msg);
            if (udh != null) {
                sms.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
                sms.setShortMessageBin(udh.getEncodedData());
            }
            dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta.getTargetId());
            if (dueSlot == 0 || dueSlot <= sbb.c2_getCurrentDueSlot()) {
                dueSlot = sbb.c2_getDueSlotForNewSms();
                sbb.c2_updateDueSlotForTargetId(ta.getTargetId(), dueSlot);
            }
            sms.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    lock = this.sbb.obtainSynchroObject(ta);
    try {
        synchronized (lock) {
            sbb.c2_registerDueSlotWriting(dueSlot);
            ArrayList<SmsSet> lst0, lst;
            try {
                lst0 = sbb.c2_getRecordList(dueSlot);
                lst = sbb.c2_sortRecordList(lst0);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
            assertEquals(lst.size(), 1);
            SmsSet smsSet = lst.get(0);
            assertEquals(smsSet.getNetworkId(), 9);
            assertEquals(sms.getOrigNetworkId(), 49);
            for (Sms sms1 : smsSet.getRawListLastSegment()) {
                if (sms1.getDbId().equals(sms.getDbId())) {
                    assertEquals(sms1.getDataCoding(), dcs.getCode());
                    if (msg != null)
                        assertEquals(sms1.getShortMessageText(), msg);
                    else
                        assertNull(sms1.getShortMessageText());
                    if (udh != null)
                        assertEquals(sms1.getShortMessageBin(), udh.getEncodedData());
                    else
                        assertNull(sms1.getShortMessageBin());
                    assertEquals(smsSet.getCorrelationId(), "CI=0000");
                }
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 18 with SmsSet

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

the class PersistenceRAInterfaceProxy method obtainArchiveSms.

public SmsProxy obtainArchiveSms(long dueSlot, String dstDigits, UUID dbId) throws PersistenceException, IOException {
    PreparedStatement ps = session.prepare("select * from \"" + Schema.FAMILY_MESSAGES + this.getTableName(dueSlot) + "\" where \"" + Schema.COLUMN_ADDR_DST_DIGITS + "\"=? and \"" + Schema.COLUMN_ID + "\"=?;");
    BoundStatement boundStatement = new BoundStatement(ps);
    boundStatement.bind(dstDigits, dbId);
    ResultSet result = session.execute(boundStatement);
    Row row = result.one();
    SmsSet smsSet = createSms(row, null, true, true, true, true, true, false);
    if (smsSet == null)
        return null;
    SmsProxy res = new SmsProxy();
    res.sms = smsSet.getSms(0);
    res.addrDstDigits = row.getString(Schema.COLUMN_ADDR_DST_DIGITS);
    res.addrDstTon = row.getInt(Schema.COLUMN_ADDR_DST_TON);
    res.addrDstNpi = row.getInt(Schema.COLUMN_ADDR_DST_NPI);
    res.destClusterName = row.getString(Schema.COLUMN_DEST_CLUSTER_NAME);
    res.destEsmeName = row.getString(Schema.COLUMN_DEST_ESME_NAME);
    res.destSystemId = row.getString(Schema.COLUMN_DEST_SYSTEM_ID);
    res.imsi = row.getString(Schema.COLUMN_IMSI);
    res.corrId = row.getString(Schema.COLUMN_CORR_ID);
    res.networkId = row.getInt(Schema.COLUMN_NETWORK_ID);
    res.nnnDigits = row.getString(Schema.COLUMN_NNN_DIGITS);
    res.smStatus = row.getInt(Schema.COLUMN_SM_STATUS);
    res.smType = row.getInt(Schema.COLUMN_SM_TYPE);
    res.deliveryCount = row.getInt(Schema.COLUMN_DELIVERY_COUNT);
    res.deliveryDate = DBOperations.getRowDate(row, Schema.COLUMN_DELIVERY_DATE);
    return res;
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) PreparedStatement(com.datastax.driver.core.PreparedStatement) Row(com.datastax.driver.core.Row) BoundStatement(com.datastax.driver.core.BoundStatement) SmsSet(org.mobicents.smsc.library.SmsSet)

Example 19 with SmsSet

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

the class PersistenceRAInterfaceProxy method obtainLiveSms.

public Sms obtainLiveSms(long dueSlot, String targetId, UUID id) throws PersistenceException {
    try {
        String s1 = "select * from \"SLOT_MESSAGES_TABLE" + this.getTableName(dueSlot) + "\" where \"DUE_SLOT\"=? and \"TARGET_ID\"=? and \"ID\"=?;";
        PreparedStatement ps = session.prepare(s1);
        BoundStatement boundStatement = new BoundStatement(ps);
        boundStatement.bind(dueSlot, targetId, id);
        ResultSet rs = session.execute(boundStatement);
        SmsSet smsSet = null;
        Row row2 = null;
        for (Row row : rs) {
            smsSet = this.createSms(row, null, true, true, true, true, true, false);
            row2 = row;
            break;
        }
        if (smsSet == null || smsSet.getSmsCount() == 0)
            return null;
        else {
            smsSet.setAlertingSupported(row2.getBool(Schema.COLUMN_ALERTING_SUPPORTED));
            smsSet.setStatus(ErrorCode.fromInt(row2.getInt(Schema.COLUMN_SM_STATUS)));
            return smsSet.getSms(0);
        }
    } catch (Exception e) {
        int ggg = 0;
        ggg = 0;
        return null;
    }
}
Also used : ResultSet(com.datastax.driver.core.ResultSet) PreparedStatement(com.datastax.driver.core.PreparedStatement) Row(com.datastax.driver.core.Row) BoundStatement(com.datastax.driver.core.BoundStatement) SmsSet(org.mobicents.smsc.library.SmsSet) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) IOException(java.io.IOException)

Example 20 with SmsSet

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

the class MtTest method SuccessDelivery2Test.

/**
 * MAP V2, 2 message:
 *  - USC2, 1 segment, +UDH
 *  - GSM7, 1 segment, +ReplyPathExists, Empty TC-BEGIN
 * InforServiceCenter -> SRDS(Success)
 */
@Test(groups = { "Mt" })
public void SuccessDelivery2Test() throws Exception {
    if (!this.cassandraDbInited)
        return;
    MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
    SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    MProcManagement.getInstance("Test");
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    lst.add(sd1);
    sd1.dataCodingScheme = 8;
    sd1.esmClass = 3 + 0x40;
    String msga1 = this.msgShort + "пїЅ";
    // Charset ucs2Charset = Charset.forName("UTF-16BE");
    // ByteBuffer bb = ucs2Charset.encode(msga1);
    // byte[] buf = new byte[udhTemp.length + bb.limit()];
    // System.arraycopy(udhTemp, 0, buf, 0, udhTemp.length);
    // bb.get(buf, udhTemp.length, bb.limit());
    // sd1.msg = buf;
    sd1.msg = msga1;
    sd1.msgUdh = udhTemp;
    SmsDef sd2 = new SmsDef();
    lst.add(sd2);
    sd2.esmClass = 3 + 0x80;
    StringBuilder sb = new StringBuilder();
    for (int i2 = 0; i2 < 16; i2++) {
        sb.append("1234567890");
    }
    String msga2 = sb.toString();
    sd2.msg = msga2;
    SmsSet smsSet = prepareDatabase(lst);
    Sms sms1 = smsSet.getSms(0);
    Sms sms2 = smsSet.getSms(1);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    assertNull(serviceMt.getLastMAPDialogSms());
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNumberingPlan(), org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
    assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
    assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
    assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNumberingPlan(), org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
    assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
    MAPTestEvent evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    SendRoutingInfoForSMRequest sriReq = (SendRoutingInfoForSMRequest) evt.event;
    assertEquals(sriReq.getMsisdn().getAddress(), msdnDig);
    assertEquals(sriReq.getMsisdn().getAddressNature(), AddressNature.international_number);
    assertEquals(sriReq.getMsisdn().getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    assertEquals(sriReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(sriReq.getServiceCentreAddress().getAddressNature(), AddressNature.international_number);
    assertEquals(sriReq.getServiceCentreAddress().getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    assertTrue(sriReq.getSm_RP_PRI());
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    // SRI "MAP only V2 supported" response
    ApplicationContextNameImpl acn = new ApplicationContextNameImpl();
    acn.setOid(new long[] { 0, 4, 0, 0, 1, 0, 20, 2 });
    DialogReject evt3 = new DialogReject(dlg, MAPRefuseReason.ApplicationContextNotSupported, acn, null);
    this.sriSbb.onDialogReject(evt3, null);
    dlg = serviceSri.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version2);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNumberingPlan(), org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
    assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
    assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
    assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNumberingPlan(), org.mobicents.protocols.ss7.indicator.NumberingPlan.ISDN_TELEPHONY);
    assertEquals(((GlobalTitle0100) dlg.getRemoteAddress().getGlobalTitle()).getNatureOfAddress(), NatureOfAddress.INTERNATIONAL);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    sriReq = (SendRoutingInfoForSMRequest) evt.event;
    assertEquals(sriReq.getMsisdn().getAddress(), msdnDig);
    assertEquals(sriReq.getMsisdn().getAddressNature(), AddressNature.international_number);
    assertEquals(sriReq.getMsisdn().getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    assertEquals(sriReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(sriReq.getServiceCentreAddress().getAddressNature(), AddressNature.international_number);
    assertEquals(sriReq.getServiceCentreAddress().getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    assertTrue(sriReq.getSm_RP_PRI());
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    // SRI response + ISC request
    IMSI imsi = new IMSIImpl(imsiDig);
    ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    LocationInfoWithLMSI locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    SendRoutingInfoForSMResponse evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, null);
    evt1.setMAPDialog(dlg);
    this.sriSbb.onSendRoutingInfoForSMResponse(evt1, null);
    ISDNAddressStringImpl storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, msdnDig);
    MWStatusImpl mwStatus = new MWStatusImpl(false, true, false, true);
    InformServiceCentreRequestImpl evt4 = new InformServiceCentreRequestImpl(storedMSISDN, mwStatus, null, null, null);
    evt4.setMAPDialog(dlg);
    this.sriSbb.onInformServiceCentreRequest(evt4, null);
    this.sriSbb.onDialogDelimiter(null, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    // MT "MAP only V2 supported" response
    acn = new ApplicationContextNameImpl();
    acn.setOid(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 });
    DialogReject evt5 = new DialogReject(dlg, MAPRefuseReason.ApplicationContextNotSupported, acn, null);
    this.mtSbb.onDialogReject(evt5, null);
    // Analyzing MtMessage 1
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version2);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    ForwardShortMessageRequestImpl mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
    assertTrue(mtFsmReq.getMoreMessagesToSend());
    SM_RP_DA sm_RP_DA = mtFsmReq.getSM_RP_DA();
    IMSI daImsi = sm_RP_DA.getIMSI();
    assertEquals(daImsi.getData(), imsiDig);
    SM_RP_OA sm_RP_OA = mtFsmReq.getSM_RP_OA();
    AddressString scas = sm_RP_OA.getServiceCentreAddressOA();
    assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(scas.getAddressNature(), AddressNature.international_number);
    assertEquals(scas.getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
    SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 8);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertTrue(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertEquals(tpdu.getOriginatingAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
    assertEquals(tpdu.getOriginatingAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
    assertEquals(tpdu.getProtocolIdentifier().getCode(), 7);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getServiceCentreTimeStamp().getDay(), curDate.getDate());
    // assertEquals(tpdu.getServiceCentreTimeStamp().getMinute(), curDate.getMinutes());
    int mon1 = tpdu.getServiceCentreTimeStamp().getMonth();
    int mon2 = curDate.getMonth() + 1;
    assertEquals(mon1, mon2);
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    UserData ud = tpdu.getUserData();
    ud.decode();
    UserDataHeader udh = ud.getDecodedUserDataHeader();
    ConcatenatedShortMessagesIdentifier udhc = udh.getConcatenatedShortMessagesIdentifier();
    assertNotNull(udhc);
    assertEquals(udhc.getReference(), 140);
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msga1);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    UUID smsId = sms1.getDbId();
    SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // Mt response
    ForwardShortMessageResponseImpl evt2 = new ForwardShortMessageResponseImpl();
    evt2.setMAPDialog(dlg);
    DialogAccept daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onForwardShortMessageResponse(evt2, null);
    DialogClose dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 3);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.cancelInvoke);
    evt = lstEvt.get(2);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsId = sms2.getDbId();
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // TC-CONTINUE after empty TC-BEGIN
    DialogDelimiter evt6 = new DialogDelimiter(dlg);
    this.mtSbb.onDialogDelimiter(evt6, null);
    // Analyzing MtMessage 2
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 5);
    evt = lstEvt.get(3);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
    assertFalse(mtFsmReq.getMoreMessagesToSend());
    sm_RP_DA = mtFsmReq.getSM_RP_DA();
    daImsi = sm_RP_DA.getIMSI();
    assertEquals(daImsi.getData(), imsiDig);
    sm_RP_OA = mtFsmReq.getSM_RP_OA();
    scas = sm_RP_OA.getServiceCentreAddressOA();
    assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(scas.getAddressNature(), AddressNature.international_number);
    assertEquals(scas.getNumberingPlan(), org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
    ssi = mtFsmReq.getSM_RP_UI();
    tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 0);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertFalse(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertEquals(tpdu.getOriginatingAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
    assertEquals(tpdu.getOriginatingAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
    assertEquals(tpdu.getProtocolIdentifier().getCode(), 7);
    assertTrue(tpdu.getReplyPathExists());
    assertEquals(tpdu.getServiceCentreTimeStamp().getDay(), curDate.getDate());
    assertEquals(tpdu.getServiceCentreTimeStamp().getMinute(), curDate.getMinutes());
    mon1 = tpdu.getServiceCentreTimeStamp().getMonth();
    mon2 = curDate.getMonth() + 1;
    assertEquals(mon1, mon2);
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertFalse(tpdu.getUserDataHeaderIndicator());
    ud = tpdu.getUserData();
    ud.decode();
    udh = ud.getDecodedUserDataHeader();
    assertNull(udh);
    msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msga2);
    evt = lstEvt.get(4);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsId = sms2.getDbId();
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    // Mt response 2
    evt2 = new ForwardShortMessageResponseImpl();
    evt2.setMAPDialog(dlg);
    daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onForwardShortMessageResponse(evt2, null);
    dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    dlg = serviceRsds.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version2);
    assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    ReportSMDeliveryStatusRequestImpl rsdsReq = (ReportSMDeliveryStatusRequestImpl) evt.event;
    assertEquals(rsdsReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(rsdsReq.getMsisdn().getAddress(), msdnDig);
    assertEquals(rsdsReq.getSMDeliveryOutcome(), SMDeliveryOutcome.successfulTransfer);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsId = sms2.getDbId();
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertNull(smsX);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
    // rsds response 2
    ReportSMDeliveryStatusResponseImpl evt7 = new ReportSMDeliveryStatusResponseImpl(2, null, null);
    evt7.setMAPDialog(dlg);
    this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);
    dcl = new DialogClose(dlg);
    this.rsdsSbb.onDialogClose(dcl, null);
// b1 = this.pers.checkSmsSetExists(taR);
// assertFalse(b1);
}
Also used : MWStatusImpl(org.mobicents.protocols.ss7.map.service.sms.MWStatusImpl) SmsDeliverTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) SendRoutingInfoForSMRequest(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) LocationInfoWithLMSI(org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) ReportSMDeliveryStatusResponseImpl(org.mobicents.protocols.ss7.map.service.sms.ReportSMDeliveryStatusResponseImpl) DialogReject(org.mobicents.slee.resource.map.events.DialogReject) IMSIImpl(org.mobicents.protocols.ss7.map.primitives.IMSIImpl) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) ArrayList(java.util.ArrayList) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SM_RP_OA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) SendRoutingInfoForSMResponse(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) DialogAccept(org.mobicents.slee.resource.map.events.DialogAccept) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI) UUID(java.util.UUID) InformServiceCentreRequestImpl(org.mobicents.protocols.ss7.map.service.sms.InformServiceCentreRequestImpl) UserDataHeader(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader) MtForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) ForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) ConcatenatedShortMessagesIdentifier(org.mobicents.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier) ForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageResponseImpl) MtForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageResponseImpl) LocationInfoWithLMSIImpl(org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) DialogDelimiter(org.mobicents.slee.resource.map.events.DialogDelimiter) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) DialogClose(org.mobicents.slee.resource.map.events.DialogClose) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) Sms(org.mobicents.smsc.library.Sms) ApplicationContextNameImpl(org.mobicents.protocols.ss7.tcap.asn.ApplicationContextNameImpl) ReportSMDeliveryStatusRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ReportSMDeliveryStatusRequestImpl) SmsSet(org.mobicents.smsc.library.SmsSet) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA) Test(org.testng.annotations.Test)

Aggregations

SmsSet (org.mobicents.smsc.library.SmsSet)116 Sms (org.mobicents.smsc.library.Sms)61 Test (org.testng.annotations.Test)45 ArrayList (java.util.ArrayList)36 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)35 Date (java.util.Date)32 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)28 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)28 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)28 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)26 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)25 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)25 UUID (java.util.UUID)23 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)21 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)19 MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)18 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)17 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)17