Search in sources :

Example 26 with DataCodingScheme

use of org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme in project smscgateway by RestComm.

the class MoSbb method createSmsEvent.

private Sms createSmsEvent(SmsDeliverTpdu smsDeliverTpdu, TargetAddress ta, PersistenceRAInterface store, CorrelationIdValue civ, int networkId, String originatorSccpAddress) throws SmscProcessingException {
    UserData userData = smsDeliverTpdu.getUserData();
    try {
        userData.decode();
    } catch (MAPException e) {
        throw new SmscProcessingException("MT MAPException when decoding user data", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    Sms sms = new Sms();
    sms.setDbId(UUID.randomUUID());
    sms.setOriginationType(OriginationType.SS7_HR);
    AddressField callingPartyAddress = smsDeliverTpdu.getOriginatingAddress();
    // checking parameters first
    if (callingPartyAddress == null || callingPartyAddress.getAddressValue() == null || callingPartyAddress.getAddressValue().isEmpty()) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getTypeOfNumber() == null) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress TypeOfNumber is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getNumberingPlanIdentification() == null) {
        throw new SmscProcessingException("Home routing: TPDU OriginatingAddress NumberingPlanIdentification is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    sms.setSourceAddr(callingPartyAddress.getAddressValue());
    sms.setOriginatorSccpAddress(originatorSccpAddress);
    if (callingPartyAddress.getTypeOfNumber() == TypeOfNumber.Alphanumeric) {
        sms.setSourceAddrTon(TypeOfNumber.Alphanumeric.getCode());
        sms.setSourceAddrNpi(NumberingPlanIdentification.Unknown.getCode());
    } else {
        sms.setSourceAddrTon(callingPartyAddress.getTypeOfNumber().getCode());
        sms.setSourceAddrNpi(callingPartyAddress.getNumberingPlanIdentification().getCode());
    }
    sms.setOrigNetworkId(networkId);
    sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
    int messageingMode = (smscPropertiesManagement.getHrDefaultMessagingMode() & 0x03);
    sms.setEsmClass(messageingMode | (smsDeliverTpdu.getUserDataHeaderIndicator() ? SmppConstants.ESM_CLASS_UDHI_MASK : 0) | (smsDeliverTpdu.getReplyPathExists() ? SmppConstants.ESM_CLASS_REPLY_PATH_MASK : 0));
    sms.setProtocolId(smsDeliverTpdu.getProtocolIdentifier().getCode());
    sms.setPriority(0);
    // TODO: do we need somehow care with RegisteredDelivery ?
    sms.setReplaceIfPresent(0);
    // TODO: care with smsSubmitTpdu.getStatusReportRequest() parameter
    // sending back SMS_STATUS_REPORT tpdu ?
    DataCodingScheme dataCodingScheme = smsDeliverTpdu.getDataCodingScheme();
    int dcs = dataCodingScheme.getCode();
    String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
    if (err != null) {
        throw new SmscProcessingException("Home routing: DataCoding scheme does not supported: " + dcs + " - " + err, SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    sms.setDataCoding(dcs);
    sms.setShortMessageText(userData.getDecodedMessage());
    UserDataHeader udh = userData.getDecodedUserDataHeader();
    if (udh != null) {
        sms.setShortMessageBin(udh.getEncodedData());
    }
    // ValidityPeriod processing
    MessageUtil.applyValidityPeriod(sms, null, false, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
    SmsSet smsSet;
    smsSet = new SmsSet();
    smsSet.setDestAddr(ta.getAddr());
    smsSet.setDestAddrNpi(ta.getAddrNpi());
    smsSet.setDestAddrTon(ta.getAddrTon());
    smsSet.setNetworkId(networkId);
    smsSet.setCorrelationId(civ.getCorrelationID());
    smsSet.setImsi(civ.getImsi());
    smsSet.setLocationInfoWithLMSI(civ.getLocationInfoWithLMSI());
    smsSet.addSms(sms);
    sms.setSmsSet(smsSet);
    long messageId = store.c2_getNextMessageId();
    SmscStatProvider.getInstance().setCurrentMessageId(messageId);
    sms.setMessageId(messageId);
    return sms;
}
Also used : AddressField(org.restcomm.protocols.ss7.map.api.smstpdu.AddressField) DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) Timestamp(java.sql.Timestamp) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)

Example 27 with DataCodingScheme

use of org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme in project smscgateway by RestComm.

the class MtSbb method createSignalInfo.

protected SmsSignalInfo createSignalInfo(Sms sms, String msg, byte[] udhData, boolean moreMessagesToSend, int messageReferenceNumber, int messageSegmentCount, int messageSegmentNumber, DataCodingScheme dataCodingScheme, int nationalLanguageLockingShift, int nationalLanguageSingleShift, int sourceAddrTon, int sourceAddrNpi) throws MAPException {
    UserDataHeader userDataHeader;
    if (udhData != null) {
        userDataHeader = this.mapSmsTpduParameterFactory.createUserDataHeader(udhData);
    } else {
        userDataHeader = this.mapSmsTpduParameterFactory.createUserDataHeader();
        if (messageSegmentCount > 1) {
            UserDataHeaderElement concatenatedShortMessagesIdentifier = this.mapSmsTpduParameterFactory.createConcatenatedShortMessagesIdentifier(messageReferenceNumber > 255, messageReferenceNumber, messageSegmentCount, messageSegmentNumber);
            userDataHeader.addInformationElement(concatenatedShortMessagesIdentifier);
        }
        if (nationalLanguageLockingShift > 0) {
            NationalLanguageIdentifier nationalLanguageIdentifier = NationalLanguageIdentifier.getInstance(nationalLanguageLockingShift);
            if (nationalLanguageIdentifier != null) {
                UserDataHeaderElement nationalLanguageLockingShiftEl = this.mapSmsTpduParameterFactory.createNationalLanguageLockingShiftIdentifier(nationalLanguageIdentifier);
                userDataHeader.addInformationElement(nationalLanguageLockingShiftEl);
            }
        }
        if (nationalLanguageSingleShift > 0) {
            NationalLanguageIdentifier nationalLanguageIdentifier = NationalLanguageIdentifier.getInstance(nationalLanguageSingleShift);
            if (nationalLanguageIdentifier != null) {
                UserDataHeaderElement nationalLanguageSingleShiftEl = this.mapSmsTpduParameterFactory.createNationalLanguageSingleShiftIdentifier(nationalLanguageIdentifier);
                userDataHeader.addInformationElement(nationalLanguageSingleShiftEl);
            }
        }
    }
    UserData ud = this.mapSmsTpduParameterFactory.createUserData(msg, dataCodingScheme, userDataHeader, isoCharset);
    Date submitDate = sms.getSubmitDate();
    // TODO : TimeZone should be configurable
    AbsoluteTimeStamp serviceCentreTimeStamp = this.mapSmsTpduParameterFactory.createAbsoluteTimeStamp((submitDate.getYear() % 100), (submitDate.getMonth() + 1), submitDate.getDate(), submitDate.getHours(), submitDate.getMinutes(), submitDate.getSeconds(), -(submitDate.getTimezoneOffset() / 15));
    SmsDeliverTpdu smsDeliverTpdu = this.mapSmsTpduParameterFactory.createSmsDeliverTpdu(moreMessagesToSend, false, ((sms.getEsmClass() & SmppConstants.ESM_CLASS_REPLY_PATH_MASK) != 0), false, this.getSmsTpduOriginatingAddress(sourceAddrTon, sourceAddrNpi, sms.getSourceAddr()), this.mapSmsTpduParameterFactory.createProtocolIdentifier(sms.getProtocolId()), serviceCentreTimeStamp, ud);
    SmsSignalInfo smsSignalInfo = this.mapParameterFactory.createSmsSignalInfo(smsDeliverTpdu, isoCharset);
    return smsSignalInfo;
}
Also used : SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) Date(java.util.Date) NationalLanguageIdentifier(org.restcomm.protocols.ss7.map.api.datacoding.NationalLanguageIdentifier)

Example 28 with DataCodingScheme

use of org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme in project smscgateway by RestComm.

the class MtTest method SuccessDelivery6Test.

/**
 * MAP V3, 1 message, GSM8
 */
@Test(groups = { "Mt" })
public void SuccessDelivery6Test() 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 = 4;
    sd1.esmClass = 3 + 0x40;
    sd1.msg = this.msgShort;
    sd1.msgUdh = udhTemp;
    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();
    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);
    // SRI response
    IMSI imsi = new IMSIImpl(imsiDig);
    ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    LocationInfoWithLMSI locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    SendRoutingInfoForSMResponse evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, true, 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);
    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());
    SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
    SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 4);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertFalse(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    UserData ud = tpdu.getUserData();
    ud.decode();
    UserDataHeader udh = ud.getDecodedUserDataHeader();
    ConcatenatedShortMessagesIdentifier csm = udh.getConcatenatedShortMessagesIdentifier();
    assertEquals(csm.getReference(), 140);
    assertEquals(csm.getMesageSegmentCount(), 2);
    assertEquals(csm.getMesageSegmentNumber(), 1);
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msgShort);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    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);
    // 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);
    dlg = serviceRsds.getLastMAPDialogSms();
    assertNull(dlg);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
}
Also used : SmsDeliverTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) SendRoutingInfoForSMRequest(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) LocationInfoWithLMSI(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) IMSIImpl(org.restcomm.protocols.ss7.map.primitives.IMSIImpl) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) ArrayList(java.util.ArrayList) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) SM_RP_OA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) SendRoutingInfoForSMResponse(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) DialogAccept(org.restcomm.slee.resource.map.events.DialogAccept) SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) MtForwardShortMessageResponseImpl(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.IMSI) UUID(java.util.UUID) MtForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) ConcatenatedShortMessagesIdentifier(org.restcomm.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier) LocationInfoWithLMSIImpl(org.restcomm.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.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) DialogClose(org.restcomm.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.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA) Test(org.testng.annotations.Test)

Example 29 with DataCodingScheme

use of org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme in project smscgateway by RestComm.

the class MtTest method SuccessDelivery4Test.

/**
 * MAP V3, 1 message, long message with 2 segments, UCS2
 * Empty TC-BEGIN message
 */
@Test(groups = { "Mt" })
public void SuccessDelivery4Test() 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);
    StringBuilder sb = new StringBuilder();
    for (int i1 = 0; i1 < 8; i1++) {
        // msg len = 80
        sb.append("012345678пїЅ");
    }
    String totalMsg = sb.toString();
    int segmlen = MessageUtil.getMaxSegmentedMessageBytesLength(new DataCodingSchemeImpl(8)) / 2;
    String msga1 = totalMsg.substring(0, segmlen);
    String msga2 = totalMsg.substring(segmlen);
    // Charset ucs2Charset = Charset.forName("UTF-16BE");
    // ByteBuffer bb = ucs2Charset.encode(totalMsg);
    // byte[] buf = new byte[bb.limit()];
    // bb.get(buf);
    sd1.msg = totalMsg;
    sd1.dataCodingScheme = 8;
    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();
    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);
    // SRI response
    IMSI imsi = new IMSIImpl(imsiDig);
    ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
    LocationInfoWithLMSI locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
    SendRoutingInfoForSMResponse evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, true, 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();
    // Empty TC-BEGIN for MAP V3
    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);
    // Empty TC-CONTINUE
    DialogDelimiter evt6 = new DialogDelimiter(dlg);
    this.mtSbb.onDialogDelimiter(evt6, null);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 5);
    evt = lstEvt.get(3);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    MtForwardShortMessageRequestImpl mtFsmReq = (MtForwardShortMessageRequestImpl) 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());
    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);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    UserData ud = tpdu.getUserData();
    ud.decode();
    UserDataHeader udh = ud.getDecodedUserDataHeader();
    ConcatenatedShortMessagesIdentifier csm = udh.getConcatenatedShortMessagesIdentifier();
    assertEquals(csm.getReference(), 1);
    assertEquals(csm.getMesageSegmentCount(), 2);
    assertEquals(csm.getMesageSegmentNumber(), 1);
    String msg1 = ud.getDecodedMessage();
    assertEquals(msg1, msga1);
    evt = lstEvt.get(4);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    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);
    // Mt response 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);
    dlg = serviceMt.getLastMAPDialogSms();
    acv = dlg.getApplicationContext().getApplicationContextVersion();
    assertEquals(acv, MAPApplicationContextVersion.version3);
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    mtFsmReq = (MtForwardShortMessageRequestImpl) 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());
    ssi = mtFsmReq.getSM_RP_UI();
    tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
    assertEquals(tpdu.getDataCodingScheme().getCode(), 8);
    assertFalse(tpdu.getForwardedOrSpawned());
    assertFalse(tpdu.getMoreMessagesToSend());
    assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
    assertFalse(tpdu.getReplyPathExists());
    assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
    assertFalse(tpdu.getStatusReportIndication());
    assertTrue(tpdu.getUserDataHeaderIndicator());
    ud = tpdu.getUserData();
    ud.decode();
    udh = ud.getDecodedUserDataHeader();
    csm = udh.getConcatenatedShortMessagesIdentifier();
    assertEquals(csm.getReference(), 1);
    assertEquals(csm.getMesageSegmentCount(), 2);
    assertEquals(csm.getMesageSegmentNumber(), 2);
    String msg2 = ud.getDecodedMessage();
    assertEquals(msg2, msga2);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    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);
    // Mt response 2
    evt2 = new MtForwardShortMessageResponseImpl(null, null);
    evt2.setMAPDialog(dlg);
    daevt = new DialogAccept(dlg, null);
    this.mtSbb.onDialogAccept(daevt, null);
    this.mtSbb.onMtForwardShortMessageResponse(evt2, null);
    dcl = new DialogClose(dlg);
    this.mtSbb.onDialogClose(dcl, null);
    dlg = serviceRsds.getLastMAPDialogSms();
    assertNull(dlg);
    dlg = serviceSri.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 2);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNotNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertNull(smsX);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
}
Also used : SmsDeliverTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) SendRoutingInfoForSMRequest(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) LocationInfoWithLMSI(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) IMSIImpl(org.restcomm.protocols.ss7.map.primitives.IMSIImpl) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) ArrayList(java.util.ArrayList) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) SM_RP_OA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) SendRoutingInfoForSMResponse(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) DialogAccept(org.restcomm.slee.resource.map.events.DialogAccept) SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) MtForwardShortMessageResponseImpl(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.IMSI) UUID(java.util.UUID) MtForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) ConcatenatedShortMessagesIdentifier(org.restcomm.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier) LocationInfoWithLMSIImpl(org.restcomm.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) DialogDelimiter(org.restcomm.slee.resource.map.events.DialogDelimiter) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) DialogClose(org.restcomm.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.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA) Test(org.testng.annotations.Test)

Example 30 with DataCodingScheme

use of org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme in project smscgateway by RestComm.

the class MtTest method SuccessDelivery2ATest.

/**
 * MAP V2, 2 message: - TC-CONTINUE
 *  - USC2, 1 segment, +UDH
 *  - GSM7, 1 segment, +ReplyPathExists, No empty TC-BEGIN because of TC-CONTINUE
 * InforServiceCenter -> SRDS(Success)
 */
@Test(groups = { "Mt" })
public void SuccessDelivery2ATest() 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);
    UUID smsId = sms1.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsId = sms2.getDbId();
    SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(smsx2);
    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.restcomm.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.restcomm.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.restcomm.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.restcomm.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.restcomm.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.restcomm.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.restcomm.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.restcomm.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.restcomm.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, 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);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(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]);
    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 "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.restcomm.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);
    smsId = sms1.getDbId();
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
    assertNull(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]);
    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);
    DialogDelimiter dcl = new DialogDelimiter(dlg);
    this.mtSbb.onDialogDelimiter(dcl, null);
    dlg = serviceMt.getLastMAPDialogSms();
    lstEvt = dlg.getEventList();
    assertEquals(lstEvt.size(), 4);
    evt = lstEvt.get(0);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    evt = lstEvt.get(1);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    evt = lstEvt.get(2);
    assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
    evt = lstEvt.get(3);
    assertEquals(evt.testEventType, MAPTestEventType.send);
    // 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) lstEvt.get(2).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.restcomm.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);
    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 DialogDelimiter(dlg);
    this.mtSbb.onDialogDelimiter(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 DialogDelimiter(dlg);
    this.rsdsSbb.onDialogClose(null, null);
// b1 = this.pers.checkSmsSetExists(taR);
// assertFalse(b1);
}
Also used : MWStatusImpl(org.restcomm.protocols.ss7.map.service.sms.MWStatusImpl) SmsDeliverTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) SendRoutingInfoForSMRequest(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMRequest) LocationInfoWithLMSI(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) ReportSMDeliveryStatusResponseImpl(org.restcomm.protocols.ss7.map.service.sms.ReportSMDeliveryStatusResponseImpl) DialogReject(org.restcomm.slee.resource.map.events.DialogReject) IMSIImpl(org.restcomm.protocols.ss7.map.primitives.IMSIImpl) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) ArrayList(java.util.ArrayList) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) SM_RP_OA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) SendRoutingInfoForSMResponse(org.restcomm.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) MAPApplicationContextVersion(org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion) SendRoutingInfoForSMResponseImpl(org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) DialogAccept(org.restcomm.slee.resource.map.events.DialogAccept) SmsSignalInfo(org.restcomm.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.restcomm.protocols.ss7.map.api.primitives.IMSI) UUID(java.util.UUID) InformServiceCentreRequestImpl(org.restcomm.protocols.ss7.map.service.sms.InformServiceCentreRequestImpl) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) ForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) MtForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.MtForwardShortMessageRequestImpl) ConcatenatedShortMessagesIdentifier(org.restcomm.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier) ForwardShortMessageResponseImpl(org.restcomm.protocols.ss7.map.service.sms.ForwardShortMessageResponseImpl) MtForwardShortMessageResponseImpl(org.restcomm.protocols.ss7.map.service.sms.MtForwardShortMessageResponseImpl) LocationInfoWithLMSIImpl(org.restcomm.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) MAPTestEvent(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent) DialogDelimiter(org.restcomm.slee.resource.map.events.DialogDelimiter) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) Sms(org.mobicents.smsc.library.Sms) ApplicationContextNameImpl(org.restcomm.protocols.ss7.tcap.asn.ApplicationContextNameImpl) ReportSMDeliveryStatusRequestImpl(org.restcomm.protocols.ss7.map.service.sms.ReportSMDeliveryStatusRequestImpl) SmsSet(org.mobicents.smsc.library.SmsSet) SM_RP_DA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA) Test(org.testng.annotations.Test)

Aggregations

DataCodingScheme (org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme)21 DataCodingSchemeImpl (org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl)19 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)18 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)18 Sms (org.mobicents.smsc.library.Sms)17 Test (org.testng.annotations.Test)17 SmsSet (org.mobicents.smsc.library.SmsSet)16 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)16 UserDataHeader (org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)16 ArrayList (java.util.ArrayList)15 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)15 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)15 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)14 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)14 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)14 Date (java.util.Date)13 SM_RP_OA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA)10 UUID (java.util.UUID)9 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)9 MAPTestEvent (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent)9