Search in sources :

Example 6 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtTest method MapVersionNegotiationTest2.

/**
 * MAP V3 -> MAP V2 (Reject - Alternative ANC) -> Success
 * New Message
 * MAP V2 -> MAP V1 (Possible Version negotiation)
 */
@Test(groups = { "Mt" })
public void MapVersionNegotiationTest2() 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);
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    // SRI response
    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);
    this.sriSbb.onDialogDelimiter(null, null);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    MAPApplicationContextVersion vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version3);
    ApplicationContextNameImpl 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);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version2);
    // 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);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    // second message sending w\round
    lst = new ArrayList<SmsDef>();
    sd1 = new SmsDef();
    lst.add(sd1);
    smsSet = prepareDatabase(lst);
    // initial onSms message
    event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.sbbLoad();
    this.sriSbb.onSms(event, null, null);
    dlg = serviceSri.getLastMAPDialogSms();
    this.mtSbb.setMapApplicationContextVersionsUsed(0);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    // SRI response
    imsi = new IMSIImpl(imsiDig);
    networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, null);
    evt1.setMAPDialog(dlg);
    this.sriSbb.onSendRoutingInfoForSMResponse(evt1, null);
    this.sriSbb.onDialogDelimiter(null, null);
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertTrue(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version2);
    evt5 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
    this.mtSbb.onDialogReject(evt5, null);
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
    assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
    assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
    assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
    dlg = serviceMt.getLastMAPDialogSms();
    vers = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(vers, MAPApplicationContextVersion.version1);
}
Also used : 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) IMSIImpl(org.mobicents.protocols.ss7.map.primitives.IMSIImpl) DialogReject(org.mobicents.slee.resource.map.events.DialogReject) ArrayList(java.util.ArrayList) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) 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) 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) 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) 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) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 7 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtTest method SuccessDeliveryReceiptTest.

/**
 * MAP V3, 1 message, 1 segment, GSM7
 * +receiptRequest
 */
@Test(groups = { "Mt" })
public void SuccessDeliveryReceiptTest() 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");
    // this.clearDatabase();
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.dataCodingScheme = 16;
    sd1.receiptRequest = true;
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    // 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);
    assertNull(serviceMt.getLastMAPDialogSms());
    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);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    // SRI response
    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);
    this.sriSbb.onDialogDelimiter(null, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    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);
    MtForwardShortMessageRequestImpl mtFsmReq = (MtForwardShortMessageRequestImpl) evt.event;
    assertFalse(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(), 16);
    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);
    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());
    assertFalse(tpdu.getUserDataHeaderIndicator());
    UserData ud = tpdu.getUserData();
    ud.decode();
    assertNull(ud.getDecodedUserDataHeader());
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msgShort);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    UUID smsId = smsSet.getSms(0).getDbId();
    SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    // Mt response
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
    MtForwardShortMessageResponseImpl evt2 = new MtForwardShortMessageResponseImpl(null, null);
    evt2.setMAPDialog(dlg);
    DialogAccept daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onMtForwardShortMessageResponse(evt2, null);
    DialogClose dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx2);
    PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
    long l1 = 0;
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, taR.getTargetId());
        if (l1 != 0)
            break;
    }
    SmsSet set1 = this.pers.c2_getRecordListForTargeId(l1, taR.getTargetId());
    // TODO: ???? .........
    // this.pers.fetchSchedulableSms(set1, true);
    // TODO: ???? .........
    assertEquals(set1.getSmsCount(), 1);
    Sms ss1 = set1.getSms(0);
    assertEquals(set1.getDestAddr(), origDig);
    assertEquals(ss1.getSourceAddr(), msdnDig);
    assertEquals(ss1.getEsmClass(), 7);
    // String sx = new String(ss1.getShortMessage());
    String sx = new String(ss1.getShortMessageText());
    assertTrue(sx.contains("err:000"));
    dlg = serviceRsds.getLastMAPDialogSms();
    assertNull(dlg);
}
Also used : 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) 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) MtForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageResponseImpl) 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) MtForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) UUID(java.util.UUID) LocationInfoWithLMSIImpl(org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) 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) 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)

Example 8 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtTest method SuccessDeliveryCTest.

/**
 * MAP V3, 1 message, 1 segment, GSM7
 * urdu alphabit
 */
@Test(groups = { "Mt" })
public void SuccessDeliveryCTest() 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();
    sd1.dataCodingScheme = 0;
    sd1.nationalAlphabet = 13;
    // 0x29, 0x1B, 0x3E
    String fullMsg = "(]";
    sd1.msg = fullMsg;
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    // 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);
    assertNull(serviceMt.getLastMAPDialogSms());
    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);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    // SRI response
    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);
    this.sriSbb.onDialogDelimiter(null, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    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);
    MtForwardShortMessageRequestImpl mtFsmReq = (MtForwardShortMessageRequestImpl) evt.event;
    assertFalse(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(), 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);
    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();
    // assertNull(ud.getDecodedUserDataHeader());
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, fullMsg);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNotNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    UUID smsId = smsSet.getSms(0).getDbId();
    SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    // Mt response
    MtForwardShortMessageResponseImpl evt2 = new MtForwardShortMessageResponseImpl(null, null);
    evt2.setMAPDialog(dlg);
    DialogAccept daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onMtForwardShortMessageResponse(evt2, null);
    DialogClose dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    int b1 = this.pers.checkSmsExists(procDueSlot, smsSet.getTargetId());
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx2);
    dlg = serviceRsds.getLastMAPDialogSms();
    assertNull(dlg);
}
Also used : 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) 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) MtForwardShortMessageResponseImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageResponseImpl) 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) MtForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) UUID(java.util.UUID) LocationInfoWithLMSIImpl(org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) 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) 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)

Example 9 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion 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 10 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion in project smscgateway by RestComm.

the class MtSbb method setupMtForwardShortMessageRequest.

// *********
// Main service methods
public void setupMtForwardShortMessageRequest(ISDNAddressString networkNode, String imsiData, LMSI lmsi, int networkId) {
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nmperforming setupMtForwardShortMessageRequest ISDNAddressString= " + networkNode);
    }
    SmsSet smsSet = getSmsSet();
    if (smsSet == null) {
        markDeliveringIsEnded(true);
        logger.severe("MtSbb.setupMtForwardShortMessageRequest(): CMP smsSet is missed");
        return;
    }
    Sms sms0 = smsSet.getSms(0);
    Integer mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
    SccpAddress networkNodeSccpAddress = this.getMSCSccpAddress(networkNode, mtRemoteSccpTt);
    IMSI imsi = this.mapParameterFactory.createIMSI(imsiData);
    SM_RP_DA sm_RP_DA = this.mapParameterFactory.createSM_RP_DA(imsi);
    AddressString scAddress = this.getServiceCenterAddressString(networkId);
    SM_RP_OA sm_RP_OA = this.mapParameterFactory.createSM_RP_OA_ServiceCentreAddressOA(scAddress);
    if (sms0 != null) {
        // we only set it for first sms in the list
        sms0.setMtServiceCenterAddress(scAddress.getAddress());
    }
    this.setNnn(networkNode);
    this.setNetworkNode(networkNodeSccpAddress);
    this.setSmRpDa(sm_RP_DA);
    this.setSmRpOa(sm_RP_OA);
    // Set cache with MAP version
    MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(networkNode.getAddress());
    if (mapApplicationContextVersion == null) {
        mapApplicationContextVersion = MAPApplicationContextVersion.getInstance(smscPropertiesManagement.getMaxMapVersion());
    } else {
        this.setNegotiatedMapVersionUsing(true);
    }
    this.setMAPVersionTested(mapApplicationContextVersion);
    // dropaftersri mproc rules
    try {
        if (this.getTotalUnsentMessageCount() > 0) {
            ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
            ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
            ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
            TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
            try {
                synchronized (lock) {
                    this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
                    this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
                }
            } finally {
                persistence.releaseSynchroObject(lock);
            }
        }
    } catch (Throwable e) {
    }
    if (this.getTotalUnsentMessageCount() == 0) {
        setupReportSMDeliveryStatusRequestSuccess(smsSet, true);
        smsSet.setStatus(ErrorCode.SUCCESS);
        this.markDeliveringIsEnded(true);
    } else {
        try {
            this.sendMtSms(this.getMtFoSMSMAPApplicationContext(mapApplicationContextVersion), MessageProcessingState.firstMessageSending, null, smsSet.getNetworkId());
        } catch (SmscProcessingException e) {
            String reason = "SmscPocessingException when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
            this.logger.severe(reason, e);
            ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
            try {
                smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
            } catch (IllegalArgumentException e1) {
            }
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
        } catch (Throwable e) {
            String reason = "Exception when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
            this.logger.severe(reason, e);
            ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
        }
    }
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) ArrayList(java.util.ArrayList) SM_RP_OA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) Sms(org.mobicents.smsc.library.Sms) MAPErrorMessageSubscriberBusyForMtSms(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI) MAPErrorCode(org.mobicents.protocols.ss7.map.api.errors.MAPErrorCode) ErrorCode(org.mobicents.smsc.library.ErrorCode) SmsSet(org.mobicents.smsc.library.SmsSet) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)

Aggregations

MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)22 SmsSet (org.mobicents.smsc.library.SmsSet)20 Test (org.testng.annotations.Test)20 ArrayList (java.util.ArrayList)19 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)18 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)18 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)18 Sms (org.mobicents.smsc.library.Sms)18 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)18 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)18 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)18 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)17 UUID (java.util.UUID)16 LocationInfoWithLMSI (org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI)16 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)16 IMSIImpl (org.mobicents.protocols.ss7.map.primitives.IMSIImpl)16 LocationInfoWithLMSIImpl (org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl)16 SendRoutingInfoForSMResponseImpl (org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl)16 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)16 MAPTestEvent (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent)15