Search in sources :

Example 31 with SmsSet

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

the class MtTest method SuccessError1Test.

/**
 * MAP V3, SRI error absentSubscriber + ISC -> RSDS
 */
@Test(groups = { "Mt" })
public void SuccessError1Test() 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);
    SmsSet smsSet = prepareDatabase(lst);
    Sms sms1 = smsSet.getSms(0);
    UUID smsId = sms1.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    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);
    assertNull(smsSet.getStatus());
    assertEquals(smsSet.getInSystem(), 0);
    assertNull(smsSet.getInSystemDate());
    assertEquals(smsSet.getDueDelay(), 0);
    assertNull(smsSet.getDueDate());
    assertFalse(smsSet.isAlertingSupported());
    // SmsSet smsSet2 = pers.obtainSmsSet(ta1);
    SmsSet smsSet2 = smsX.getSmsSet();
    assertEquals(smsSet2.getStatus(), ErrorCode.SUCCESS);
    assertEquals(smsSet2.getInSystem(), 0);
    // this.testDateEq(smsSet2.getInSystemDate(), curDate);
    assertEquals(smsSet2.getDueDelay(), 0);
    assertNull(smsSet2.getDueDate());
    assertFalse(smsSet2.isAlertingSupported());
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertNull(serviceMt.getLastMAPDialogSms());
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
    assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
    MAPTestEvent evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    SendRoutingInfoForSMRequest sriReq = (SendRoutingInfoForSMRequest) evt.event;
    assertEquals(sriReq.getMsisdn().getAddress(), msdnDig);
    assertEquals(sriReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    assertNull(serviceRsds.getLastMAPDialogSms());
    // SRI response
    MAPErrorMessage mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
    ErrorComponent evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
    this.sriSbb.onErrorComponent(evt2, 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);
    PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
    long l1 = 0;
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
        if (l1 != 0)
            break;
    }
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    smsSet2 = smsX.getSmsSet();
    assertEquals(smsSet2.getStatus(), ErrorCode.ABSENT_SUBSCRIBER);
    assertEquals(smsSet2.getInSystem(), 0);
    // this.testDateEq(smsSet2.getInSystemDate(), curDate);
    assertEquals(smsSet2.getDueDelay(), SmscPropertiesManagement.getInstance().getSecondDueDelay());
    // this.testDateEq(new Date(new Date().getTime() + SmscPropertiesManagement.getInstance().getSecondDueDelay() * 1000), smsSet2.getDueDate());
    assertFalse(smsSet2.isAlertingSupported());
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    assertNotNull(smsX);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
    dlg = serviceRsds.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    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.absentSubscriber);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    // rsds response 2
    ReportSMDeliveryStatusResponseImpl evt7 = new ReportSMDeliveryStatusResponseImpl(2, null, null);
    evt7.setMAPDialog(dlg);
    this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);
    DialogClose dcl = new DialogClose(dlg);
    this.rsdsSbb.onDialogClose(dcl, null);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    smsSet2 = smsX.getSmsSet();
    assertEquals(smsSet2.getStatus(), ErrorCode.ABSENT_SUBSCRIBER);
    assertEquals(smsSet2.getInSystem(), 0);
    assertEquals(smsSet2.getDueDelay(), SmscPropertiesManagement.getInstance().getSecondDueDelay());
// TODO: alertingSupport field is not now filled (It can be filled in: this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);)
// assertTrue(smsSet2.isAlertingSupported());
// TODO: ???? .........
// boolean b1 = this.pers.checkSmsSetExists(taR);
// TODO: ???? .........
// assertFalse(b1);
}
Also used : MWStatusImpl(org.mobicents.protocols.ss7.map.service.sms.MWStatusImpl) SendRoutingInfoForSMRequest(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ReportSMDeliveryStatusResponseImpl(org.mobicents.protocols.ss7.map.service.sms.ReportSMDeliveryStatusResponseImpl) ArrayList(java.util.ArrayList) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion) MAPErrorMessageAbsentSubscriberSMImpl(org.mobicents.protocols.ss7.map.errors.MAPErrorMessageAbsentSubscriberSMImpl) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) UUID(java.util.UUID) InformServiceCentreRequestImpl(org.mobicents.protocols.ss7.map.service.sms.InformServiceCentreRequestImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) ErrorComponent(org.mobicents.slee.resource.map.events.ErrorComponent) 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) ReportSMDeliveryStatusRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ReportSMDeliveryStatusRequestImpl) SmsSet(org.mobicents.smsc.library.SmsSet) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage) Test(org.testng.annotations.Test)

Example 32 with SmsSet

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

the class MtTest method createEmptySmsSet.

private SmsSet createEmptySmsSet(TargetAddress ta) {
    SmsSet smsSet = new SmsSet();
    smsSet.setDestAddr(ta1.getAddr());
    smsSet.setDestAddrNpi(ta1.getAddrNpi());
    smsSet.setDestAddrTon(ta1.getAddrTon());
    smsSet.setType(SmType.SMS_FOR_SS7);
    return smsSet;
}
Also used : SmsSet(org.mobicents.smsc.library.SmsSet)

Example 33 with SmsSet

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

the class MtTest method prepareDatabase.

private SmsSet prepareDatabase(ArrayList<SmsDef> lst) throws PersistenceException {
    SmsSet smsSet = createEmptySmsSet(ta1);
    int i1 = 1;
    procDueSlot = -1;
    for (SmsDef smsDef : lst) {
        Sms sms = this.prepareSms(smsSet, i1, smsDef);
        if (sms.getStored()) {
            this.pers.c2_scheduleMessage_ReschedDueSlot(sms, false, true);
            procDueSlot = sms.getDueSlot();
        } else {
            smsSet.addSms(sms);
        }
        i1++;
    }
    if (procDueSlot != -1) {
        ArrayList<SmsSet> lst1 = this.pers.c2_getRecordList(procDueSlot);
        ArrayList<SmsSet> lst2 = this.pers.c2_sortRecordList(lst1);
        if (lst2.size() > 0) {
            SmsSet res = lst2.get(0);
            curDate = new Date();
            procTargetId = res.getTargetId();
            procId = new UUID[(int) res.getSmsCount()];
            for (i1 = 0; i1 < res.getSmsCount(); i1++) {
                procId[i1] = res.getSms(i1).getDbId();
            }
            return res;
        } else {
            return null;
        }
    } else {
        procTargetId = smsSet.getTargetId();
        procId = new UUID[(int) smsSet.getSmsCount()];
        for (i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
            procId[i1] = smsSet.getSms(i1).getDbId();
        }
        return smsSet;
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Date(java.util.Date)

Example 34 with SmsSet

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

the class MtTest3 method ReportTest.

@Test(groups = { "Mt" })
public void ReportTest() throws Exception {
    MtSbbProxy3 proxy = new MtSbbProxy3();
    Date submitDate = new Date(2015, 1, 2, 12, 30);
    Date deliveryDate = new Date(2015, 1, 2, 12, 40);
    Sms sms = new Sms();
    sms.setSourceAddr("111199990000");
    sms.setSourceAddrNpi(1);
    sms.setSourceAddrTon(1);
    sms.setShortMessageText("Hello 111");
    sms.setSubmitDate(submitDate);
    sms.setMoMessageRef(34);
    SmsSet smsSet = new SmsSet();
    smsSet.setDestAddr("888899990000");
    smsSet.setDestAddrNpi(1);
    smsSet.setDestAddrTon(1);
    smsSet.setNetworkId(0);
    smsSet.addSms(sms);
    SmsDeliveryReportData smsDeliveryReportData = new SmsDeliveryReportData();
    smsDeliveryReportData.setDeliveryDate(deliveryDate);
    smsDeliveryReportData.setStatusReportQualifier(StatusReportQualifier.SmsSubmitResult);
    smsDeliveryReportData.setStatusVal(64);
    SmsSignalInfo smsSignalInfo = proxy.createSignalInfoStatusReport(sms, true, smsDeliveryReportData);
    String s1 = smsSignalInfo.toString();
    assertNotNull(smsSignalInfo);
    SmsStatusReportTpdu si = (SmsStatusReportTpdu) smsSignalInfo.decodeTpdu(false);
    assertEquals(si.getDischargeTime().getMinute(), 40);
    assertEquals(si.getServiceCentreTimeStamp().getMinute(), 30);
    assertFalse(si.getForwardedOrSpawned());
    assertEquals(si.getMessageReference(), 34);
    assertTrue(si.getMoreMessagesToSend());
    // assertNull(si.getParameterIndicator());
    assertEquals(si.getProtocolIdentifier().getCode(), 0);
    assertEquals(si.getRecipientAddress().getAddressValue(), "888899990000");
    assertEquals(si.getRecipientAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
    assertEquals(si.getRecipientAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
    assertEquals(si.getStatus().getCode(), Status.REMOTE_PROCEDURE_ERROR);
    assertEquals(si.getStatusReportQualifier(), StatusReportQualifier.SmsSubmitResult);
}
Also used : SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) Sms(org.mobicents.smsc.library.Sms) SmsStatusReportTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsStatusReportTpdu) SmsDeliveryReportData(org.mobicents.smsc.library.SmsDeliveryReportData) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) Date(java.util.Date) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 35 with SmsSet

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

the class MtCommonSbb method onInvokeTimeout.

public void onInvokeTimeout(InvokeTimeout evt, ActivityContextInterface aci) {
    SmsSet smsSet = getSmsSet();
    if (smsSet == null) {
        logger.severe("MtCommonSbb.onInvokeTimeout(): CMP smsSet is missed");
        markDeliveringIsEnded(true);
        return;
    }
    if (logger.isWarningEnabled()) {
        this.logger.warning("\nRx : onInvokeTimeout targetId=" + smsSet.getTargetId() + ", " + evt);
    }
}
Also used : SmsSet(org.mobicents.smsc.library.SmsSet)

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