use of org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader in project smscgateway by RestComm.
the class TxSmppServerSbb method createSmsEvent.
// *********
// General Sms creating and processing methods
protected Sms createSmsEvent(BaseSm event, Esme origEsme, TargetAddress ta, PersistenceRAInterface store) throws SmscProcessingException {
Sms sms = new Sms();
sms.setDbId(UUID.randomUUID());
sms.setOriginationType(OriginationType.SMPP);
// checking parameters first
if (event.getSourceAddress() == null || event.getSourceAddress().getAddress() == null || event.getSourceAddress().getAddress().isEmpty()) {
throw new SmscProcessingException("SourceAddress digits are absent", SmppConstants.STATUS_INVSRCADR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_SRC_ADDR_INVALID);
}
sms.setSourceAddr(event.getSourceAddress().getAddress());
sms.setSourceAddrTon(event.getSourceAddress().getTon());
sms.setSourceAddrNpi(event.getSourceAddress().getNpi());
sms.setOrigNetworkId(origEsme.getNetworkId());
int dcs = event.getDataCoding();
String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
if (err != null) {
throw new SmscProcessingException("TxSmpp DataCoding scheme does not supported: " + dcs + " - " + err, SmppExtraConstants.ESME_RINVDCS, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_DATA_CODING_INVALID);
}
// storing additional parameters
ArrayList<Tlv> optionalParameters = event.getOptionalParameters();
if (optionalParameters != null && optionalParameters.size() > 0) {
for (Tlv tlv : optionalParameters) {
if (tlv.getTag() != SmppConstants.TAG_MESSAGE_PAYLOAD) {
sms.getTlvSet().addOptionalParameter(tlv);
}
}
}
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(dcs);
sms.setDataCoding(dcs);
sms.setOrigSystemId(origEsme.getSystemId());
sms.setOrigEsmeName(origEsme.getName());
sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
sms.setServiceType(event.getServiceType());
sms.setEsmClass(event.getEsmClass());
sms.setProtocolId(event.getProtocolId());
sms.setPriority(event.getPriority());
sms.setRegisteredDelivery(event.getRegisteredDelivery());
sms.setReplaceIfPresent(event.getReplaceIfPresent());
sms.setDefaultMsgId(event.getDefaultMsgId());
boolean udhPresent = (event.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0;
Tlv sarMsgRefNum = event.getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
Tlv sarTotalSegments = event.getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
Tlv sarSegmentSeqnum = event.getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
boolean segmentTlvFlag = (sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null);
// short message data
byte[] data = event.getShortMessage();
if (event.getShortMessageLength() == 0) {
// Probably the message_payload Optional Parameter is being used
Tlv messagePaylod = event.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
if (messagePaylod != null) {
data = messagePaylod.getValue();
}
}
if (data == null) {
data = new byte[0];
}
byte[] udhData;
byte[] textPart;
String msg;
udhData = null;
textPart = data;
if (udhPresent && data.length > 2) {
// UDH exists
int udhLen = (textPart[0] & 0xFF) + 1;
if (udhLen <= textPart.length) {
textPart = new byte[textPart.length - udhLen];
udhData = new byte[udhLen];
System.arraycopy(data, udhLen, textPart, 0, textPart.length);
System.arraycopy(data, 0, udhData, 0, udhLen);
}
}
msg = parseShortMessageText(event);
sms.setShortMessageText(msg);
sms.setShortMessageBin(udhData);
// checking of min / max length
if (origEsme.getMinMessageLength() >= 0 && msg.length() < origEsme.getMinMessageLength()) {
SmscProcessingException e = new SmscProcessingException("Message length is less than a min length limit for ESME=" + origEsme.getName() + ", len=" + msg.length(), SmppConstants.STATUS_INVMSGLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_SHORT);
e.setSkipErrorLogging(true);
throw e;
}
if (origEsme.getMaxMessageLength() >= 0 && msg.length() > origEsme.getMaxMessageLength()) {
SmscProcessingException e = new SmscProcessingException("Message length is more than a max length limit for ESME=" + origEsme.getName() + ", len=" + msg.length(), SmppConstants.STATUS_INVMSGLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
e.setSkipErrorLogging(true);
throw e;
}
// checking max message length
if (udhPresent || segmentTlvFlag) {
// here splitting by SMSC is not supported
UserDataHeader udh = null;
int lenSolid = MessageUtil.getMaxSolidMessageBytesLength();
if (udhPresent) {
udh = new UserDataHeaderImpl(udhData);
} else {
udh = createNationalLanguageUdh(origEsme, dataCodingScheme);
if (udh != null && udh.getNationalLanguageLockingShift() != null) {
lenSolid -= 3;
sms.setNationalLanguageLockingShift(udh.getNationalLanguageLockingShift().getNationalLanguageIdentifier().getCode());
}
if (udh != null && udh.getNationalLanguageSingleShift() != null) {
lenSolid -= 3;
sms.setNationalLanguageSingleShift(udh.getNationalLanguageSingleShift().getNationalLanguageIdentifier().getCode());
}
}
int messageLen = MessageUtil.getMessageLengthInBytes(dataCodingScheme, msg, udh);
if (udhData != null)
lenSolid -= udhData.length;
if (messageLen > lenSolid) {
throw new SmscProcessingException("Message length in bytes is too big for solid message: " + messageLen + ">" + lenSolid, SmppConstants.STATUS_INVPARLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
}
} else {
// here splitting by SMSC is supported
int lenSegmented = MessageUtil.getMaxSegmentedMessageBytesLength();
UserDataHeader udh = createNationalLanguageUdh(origEsme, dataCodingScheme);
if (msg.length() * 2 > (lenSegmented - 6) * 255) {
// firstly draft length check
int messageLen = MessageUtil.getMessageLengthInBytes(dataCodingScheme, msg, udh);
if (udh != null) {
if (udh.getNationalLanguageLockingShift() != null) {
lenSegmented -= 3;
sms.setNationalLanguageLockingShift(udh.getNationalLanguageLockingShift().getNationalLanguageIdentifier().getCode());
}
if (udh.getNationalLanguageSingleShift() != null) {
lenSegmented -= 3;
sms.setNationalLanguageSingleShift(udh.getNationalLanguageSingleShift().getNationalLanguageIdentifier().getCode());
}
}
if (messageLen > lenSegmented * 255) {
throw new SmscProcessingException("Message length in bytes is too big for segmented message: " + messageLen + ">" + lenSegmented, SmppConstants.STATUS_INVPARLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
}
} else {
if (udh != null) {
if (udh.getNationalLanguageLockingShift() != null) {
sms.setNationalLanguageLockingShift(udh.getNationalLanguageLockingShift().getNationalLanguageIdentifier().getCode());
}
if (udh.getNationalLanguageSingleShift() != null) {
sms.setNationalLanguageSingleShift(udh.getNationalLanguageSingleShift().getNationalLanguageIdentifier().getCode());
}
}
}
}
// ValidityPeriod processing
Tlv tlvQosTimeToLive = event.getOptionalParameter(SmppConstants.TAG_QOS_TIME_TO_LIVE);
Date validityPeriod;
if (tlvQosTimeToLive != null) {
long valTime;
try {
valTime = (new Date()).getTime() + tlvQosTimeToLive.getValueAsInt();
} catch (TlvConvertException e) {
throw new SmscProcessingException("TlvConvertException when getting TAG_QOS_TIME_TO_LIVE tlv field: " + e.getMessage(), SmppConstants.STATUS_INVOPTPARAMVAL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_VALIDITY_PERIOD_PARSING);
}
validityPeriod = new Date(valTime);
} else {
try {
validityPeriod = MessageUtil.parseSmppDate(event.getValidityPeriod());
} catch (ParseException e) {
throw new SmscProcessingException("ParseException when parsing ValidityPeriod field: " + e.getMessage(), SmppConstants.STATUS_INVEXPIRY, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_VALIDITY_PERIOD_PARSING);
}
}
MessageUtil.applyValidityPeriod(sms, validityPeriod, true, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
// ScheduleDeliveryTime processing
Date scheduleDeliveryTime;
try {
scheduleDeliveryTime = MessageUtil.parseSmppDate(event.getScheduleDeliveryTime());
} catch (ParseException e) {
throw new SmscProcessingException("ParseException when parsing ScheduleDeliveryTime field: " + e.getMessage(), SmppConstants.STATUS_INVSCHED, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_SCHEDULER_DELIVERY_TIME_PARSING);
}
MessageUtil.applyScheduleDeliveryTime(sms, scheduleDeliveryTime);
SmsSet smsSet;
smsSet = new SmsSet();
smsSet.setDestAddr(ta.getAddr());
smsSet.setDestAddrNpi(ta.getAddrNpi());
smsSet.setDestAddrTon(ta.getAddrTon());
smsSet.setNetworkId(origEsme.getNetworkId());
smsSet.addSms(sms);
sms.setSmsSet(smsSet);
long messageId = store.c2_getNextMessageId();
SmscStatProvider.getInstance().setCurrentMessageId(messageId);
sms.setMessageId(messageId);
return sms;
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader in project smscgateway by RestComm.
the class TxSmppServerSbb method createNationalLanguageUdh.
private UserDataHeader createNationalLanguageUdh(Esme origEsme, DataCodingScheme dataCodingScheme) {
UserDataHeader udh = null;
int nationalLanguageSingleShift = 0;
int nationalLanguageLockingShift = 0;
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7) {
nationalLanguageSingleShift = origEsme.getNationalLanguageSingleShift();
nationalLanguageLockingShift = origEsme.getNationalLanguageLockingShift();
if (nationalLanguageSingleShift == -1)
nationalLanguageSingleShift = smscPropertiesManagement.getNationalLanguageSingleShift();
if (nationalLanguageLockingShift == -1)
nationalLanguageLockingShift = smscPropertiesManagement.getNationalLanguageLockingShift();
}
return MessageUtil.getNationalLanguageIdentifierUdh(nationalLanguageLockingShift, nationalLanguageSingleShift);
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader in project smscgateway by RestComm.
the class A2Text method testA3.
@Test
public void testA3() throws Exception {
DataCodingScheme dcs = new DataCodingSchemeImpl(0xF1);
String msg = "Welcome to [thiopien\nPrices in EUR\n\nLocal calls from 2.19/min\nIncoming calls 1.29/min\nCalls home from 1.99/min\n\nSMS from 1.29\nData from 19.99/mb\n\n--Lufth";
UserDataHeader udh = new UserDataHeaderImpl();
ConcatenatedShortMessagesIdentifierImpl udhe = new ConcatenatedShortMessagesIdentifierImpl(false, 227, 2, 1);
udh.addInformationElement(udhe);
int messageLen = MessageUtil.getMessageLengthInBytes(dcs, msg, udh);
int i1 = 0;
i1++;
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader in project smscgateway by RestComm.
the class MessageUtil method calculateMsgParts.
public static int calculateMsgParts(String msg, DataCodingScheme dataCodingScheme, int nationalLanguageLockingShift, int nationalLanguageSingleShift) {
int lenSolid = MessageUtil.getMaxSolidMessageCharsLength(dataCodingScheme);
int lenSegmented = MessageUtil.getMaxSegmentedMessageCharsLength(dataCodingScheme);
UserDataHeader udh = null;
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7 && (nationalLanguageLockingShift > 0 || nationalLanguageSingleShift > 0)) {
udh = MessageUtil.getNationalLanguageIdentifierUdh(nationalLanguageLockingShift, nationalLanguageSingleShift);
if (nationalLanguageLockingShift > 0) {
lenSolid -= 3;
lenSegmented -= 3;
}
if (nationalLanguageSingleShift > 0) {
lenSolid -= 3;
lenSegmented -= 3;
}
}
int msgLenInChars = msg.length();
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7 && msgLenInChars * 2 > lenSolid) {
// GSM7 data coding. We need to care if some characters occupy two char places
msgLenInChars = UserDataImpl.checkEncodedDataLengthInChars(msg, udh);
}
if (msgLenInChars <= lenSolid) {
return 1;
} else {
if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7) {
String[] res = UserDataImpl.sliceString(msg, lenSegmented, udh);
return res.length;
} else {
ArrayList<String> res = new ArrayList<String>();
int segmCnt = (msg.length() - 1) / lenSegmented + 1;
for (int i1 = 0; i1 < segmCnt; i1++) {
if (i1 == segmCnt - 1) {
res.add(msg.substring(i1 * lenSegmented, msg.length()));
} else {
res.add(msg.substring(i1 * lenSegmented, (i1 + 1) * lenSegmented));
}
}
return res.size();
}
}
}
use of org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader in project smscgateway by RestComm.
the class MtTest method SuccessDelivery2Test.
/**
* MAP V2, 2 message:
* - USC2, 1 segment, +UDH
* - GSM7, 1 segment, +ReplyPathExists, Empty TC-BEGIN
* InforServiceCenter -> SRDS(Success)
*/
@Test(groups = { "Mt" })
public void SuccessDelivery2Test() throws Exception {
if (!this.cassandraDbInited)
return;
MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
MProcManagement.getInstance("Test");
ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
SmsDef sd1 = new SmsDef();
lst.add(sd1);
sd1.dataCodingScheme = 8;
sd1.esmClass = 3 + 0x40;
String msga1 = this.msgShort + "пїЅ";
// Charset ucs2Charset = Charset.forName("UTF-16BE");
// ByteBuffer bb = ucs2Charset.encode(msga1);
// byte[] buf = new byte[udhTemp.length + bb.limit()];
// System.arraycopy(udhTemp, 0, buf, 0, udhTemp.length);
// bb.get(buf, udhTemp.length, bb.limit());
// sd1.msg = buf;
sd1.msg = msga1;
sd1.msgUdh = udhTemp;
SmsDef sd2 = new SmsDef();
lst.add(sd2);
sd2.esmClass = 3 + 0x80;
StringBuilder sb = new StringBuilder();
for (int i2 = 0; i2 < 16; i2++) {
sb.append("1234567890");
}
String msga2 = sb.toString();
sd2.msg = msga2;
SmsSet smsSet = prepareDatabase(lst);
Sms sms1 = smsSet.getSms(0);
Sms sms2 = smsSet.getSms(1);
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
assertNull(serviceMt.getLastMAPDialogSms());
MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version3);
ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNumberingPlan(), org.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);
// 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);
UUID smsId = sms1.getDbId();
SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
// Mt response
ForwardShortMessageResponseImpl evt2 = new ForwardShortMessageResponseImpl();
evt2.setMAPDialog(dlg);
DialogAccept daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onForwardShortMessageResponse(evt2, null);
DialogClose dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
dlg = serviceMt.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 3);
evt = lstEvt.get(0);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
evt = lstEvt.get(1);
assertEquals(evt.testEventType, MAPTestEventType.cancelInvoke);
evt = lstEvt.get(2);
assertEquals(evt.testEventType, MAPTestEventType.send);
smsId = sms1.getDbId();
SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx1);
smsId = sms2.getDbId();
smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertNull(smsX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
// TC-CONTINUE after empty TC-BEGIN
DialogDelimiter evt6 = new DialogDelimiter(dlg);
this.mtSbb.onDialogDelimiter(evt6, null);
// Analyzing MtMessage 2
dlg = serviceMt.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version2);
dlg = serviceMt.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 5);
evt = lstEvt.get(3);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
mtFsmReq = (ForwardShortMessageRequestImpl) evt.event;
assertFalse(mtFsmReq.getMoreMessagesToSend());
sm_RP_DA = mtFsmReq.getSM_RP_DA();
daImsi = sm_RP_DA.getIMSI();
assertEquals(daImsi.getData(), imsiDig);
sm_RP_OA = mtFsmReq.getSM_RP_OA();
scas = sm_RP_OA.getServiceCentreAddressOA();
assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(scas.getAddressNature(), AddressNature.international_number);
assertEquals(scas.getNumberingPlan(), org.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);
evt = lstEvt.get(4);
assertEquals(evt.testEventType, MAPTestEventType.send);
smsId = sms1.getDbId();
smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx1);
smsId = sms2.getDbId();
smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertNull(smsX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
// Mt response 2
evt2 = new ForwardShortMessageResponseImpl();
evt2.setMAPDialog(dlg);
daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onForwardShortMessageResponse(evt2, null);
dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
dlg = serviceRsds.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version2);
assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(dlg.getRemoteAddress().getGlobalTitle().getDigits(), msdnDig);
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
evt = lstEvt.get(0);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
ReportSMDeliveryStatusRequestImpl rsdsReq = (ReportSMDeliveryStatusRequestImpl) evt.event;
assertEquals(rsdsReq.getServiceCentreAddress().getAddress(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(rsdsReq.getMsisdn().getAddress(), msdnDig);
assertEquals(rsdsReq.getSMDeliveryOutcome(), SMDeliveryOutcome.successfulTransfer);
evt = lstEvt.get(1);
assertEquals(evt.testEventType, MAPTestEventType.send);
smsId = sms1.getDbId();
smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx1);
smsId = sms2.getDbId();
smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertNull(smsX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
assertNull(smsX);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
// rsds response 2
ReportSMDeliveryStatusResponseImpl evt7 = new ReportSMDeliveryStatusResponseImpl(2, null, null);
evt7.setMAPDialog(dlg);
this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);
dcl = new DialogClose(dlg);
this.rsdsSbb.onDialogClose(dcl, null);
// b1 = this.pers.checkSmsSetExists(taR);
// assertFalse(b1);
}
Aggregations