use of org.mobicents.protocols.ss7.map.api.smstpdu.UserData in project smscgateway by RestComm.
the class MoSbb method createSmsEvent.
private Sms createSmsEvent(SmsSubmitTpdu smsSubmitTpdu, TargetAddress ta, PersistenceRAInterface store, AddressString callingPartyAddress, int networkId, String originatorSccpAddress) throws SmscProcessingException {
UserData userData = smsSubmitTpdu.getUserData();
try {
userData.decode();
} catch (MAPException e) {
throw new SmscProcessingException("MO 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_MO);
// checking parameters first
if (callingPartyAddress == null || callingPartyAddress.getAddress() == null || callingPartyAddress.getAddress().isEmpty()) {
throw new SmscProcessingException("MO SourceAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
if (callingPartyAddress.getAddressNature() == null) {
throw new SmscProcessingException("MO SourceAddress AddressNature is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
if (callingPartyAddress.getNumberingPlan() == null) {
throw new SmscProcessingException("MO SourceAddress NumberingPlan is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
}
sms.setSourceAddr(callingPartyAddress.getAddress());
sms.setOriginatorSccpAddress(originatorSccpAddress);
sms.setSourceAddrTon(callingPartyAddress.getAddressNature().getIndicator());
sms.setSourceAddrNpi(callingPartyAddress.getNumberingPlan().getIndicator());
sms.setOrigNetworkId(networkId);
sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
int messageingMode = (smscPropertiesManagement.getMoDefaultMessagingMode() & 0x03);
sms.setEsmClass(messageingMode | (smsSubmitTpdu.getUserDataHeaderIndicator() ? SmppConstants.ESM_CLASS_UDHI_MASK : 0) | (smsSubmitTpdu.getReplyPathExists() ? SmppConstants.ESM_CLASS_REPLY_PATH_MASK : 0));
sms.setProtocolId(smsSubmitTpdu.getProtocolIdentifier().getCode());
sms.setPriority(0);
// TODO: do we need somehow care with RegisteredDelivery ?
sms.setReplaceIfPresent(smsSubmitTpdu.getRejectDuplicates() ? 2 : 0);
sms.setStatusReportRequest(smsSubmitTpdu.getStatusReportRequest());
DataCodingScheme dataCodingScheme = smsSubmitTpdu.getDataCodingScheme();
int dcs = dataCodingScheme.getCode();
String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
if (err != null) {
throw new SmscProcessingException("MO 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
ValidityPeriod vp = smsSubmitTpdu.getValidityPeriod();
ValidityPeriodFormat vpf = smsSubmitTpdu.getValidityPeriodFormat();
Date validityPeriod = null;
if (vp != null && vpf != null && vpf != ValidityPeriodFormat.fieldNotPresent) {
switch(vpf) {
case fieldPresentAbsoluteFormat:
AbsoluteTimeStamp ats = vp.getAbsoluteFormatValue();
Date dt = new Date(ats.getYear(), ats.getMonth(), ats.getDay(), ats.getHour(), ats.getMinute(), ats.getSecond());
int i1 = ats.getTimeZone() * 15 * 60;
int i2 = -new Date().getTimezoneOffset() * 60;
long i3 = (i2 - i1) * 1000;
validityPeriod = new Date(dt.getTime() + i3);
break;
case fieldPresentRelativeFormat:
validityPeriod = new Date(new Date().getTime() + (long) (vp.getRelativeFormatHours() * 3600 * 1000));
break;
case fieldPresentEnhancedFormat:
this.logger.info("Recieved unsupported ValidityPeriodFormat: PresentEnhancedFormat - we skip it");
break;
}
}
MessageUtil.applyValidityPeriod(sms, validityPeriod, 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.addSms(sms);
long messageId = store.c2_getNextMessageId();
SmscStatProvider.getInstance().setCurrentMessageId(messageId);
sms.setMessageId(messageId);
sms.setMoMessageRef(smsSubmitTpdu.getMessageReference());
return sms;
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.UserData 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;
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.UserData in project smscgateway by RestComm.
the class MtTest method SuccessDelivery3Test.
/**
* MAP V1, 1 message, long message with 2 segments, GSM7
* no TC-BEGIN message because of MAP V1
* SRI response with MwdSet, but no ReportSMDeliveryStatusRequest because of MAP V1
*/
@Test(groups = { "Mt" })
public void SuccessDelivery3Test() 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 < 18; i1++) {
// msg len = 180
sb.append("0123456789");
}
String totalMsg = sb.toString();
int segmlen = MessageUtil.getMaxSegmentedMessageBytesLength(new DataCodingSchemeImpl(0));
String msga1 = totalMsg.substring(0, segmlen);
String msga2 = totalMsg.substring(segmlen);
sd1.msg = totalMsg;
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());
// SRI "MAP only V1 supported" response
DialogReject evt11 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
this.sriSbb.onDialogReject(evt11, null);
dlg = serviceSri.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version1);
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);
// SRI "MAP only V1 supported" response
DialogReject evt12 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
this.mtSbb.onDialogReject(evt12, null);
dlg = serviceMt.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version1);
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());
SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
assertEquals(tpdu.getDataCodingScheme().getCode(), 0);
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(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 1
ForwardShortMessageResponseImpl evt2 = new ForwardShortMessageResponseImpl();
evt2.setMAPDialog(dlg);
DialogAccept daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onForwardShortMessageResponse(evt2, null);
DialogClose dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
dlg = serviceMt.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version1);
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
evt = lstEvt.get(0);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
assertFalse(mtFsmReq.getMoreMessagesToSend());
sm_RP_DA = mtFsmReq.getSM_RP_DA();
daImsi = sm_RP_DA.getIMSI();
assertEquals(daImsi.getData(), imsiDig);
sm_RP_OA = mtFsmReq.getSM_RP_OA();
scas = sm_RP_OA.getServiceCentreAddressOA();
assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
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);
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 ForwardShortMessageResponseImpl();
evt2.setMAPDialog(dlg);
daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onForwardShortMessageResponse(evt2, null);
dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
dlg = serviceRsds.getLastMAPDialogSms();
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);
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.UserData 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);
}
use of org.mobicents.protocols.ss7.map.api.smstpdu.UserData 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);
}
Aggregations