use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MtTest method MapVersionNegotiationTest2.
/**
* MAP V3 -> MAP V2 (Reject - Alternative ANC) -> Success
* New Message
* MAP V2 -> MAP V1 (Possible Version negotiation)
*/
@Test(groups = { "Mt" })
public void MapVersionNegotiationTest2() throws Exception {
if (!this.cassandraDbInited)
return;
MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
MProcManagement.getInstance("Test");
ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
SmsDef sd1 = new SmsDef();
lst.add(sd1);
SmsSet smsSet = prepareDatabase(lst);
Sms sms1 = smsSet.getSms(0);
UUID smsId = sms1.getDbId();
SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx1);
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
// SRI response
IMSI imsi = new IMSIImpl(imsiDig);
ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.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);
this.sriSbb.onDialogDelimiter(null, null);
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
dlg = serviceMt.getLastMAPDialogSms();
MAPApplicationContextVersion vers = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(vers, MAPApplicationContextVersion.version3);
ApplicationContextNameImpl acn = new ApplicationContextNameImpl();
acn.setOid(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 });
DialogReject evt5 = new DialogReject(dlg, MAPRefuseReason.ApplicationContextNotSupported, acn, null);
this.mtSbb.onDialogReject(evt5, null);
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
dlg = serviceMt.getLastMAPDialogSms();
vers = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(vers, MAPApplicationContextVersion.version2);
// Mt response
ForwardShortMessageResponseImpl evt2 = new ForwardShortMessageResponseImpl();
evt2.setMAPDialog(dlg);
DialogAccept daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onForwardShortMessageResponse(evt2, null);
DialogClose dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
// second message sending w\round
lst = new ArrayList<SmsDef>();
sd1 = new SmsDef();
lst.add(sd1);
smsSet = prepareDatabase(lst);
// initial onSms message
event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.sbbLoad();
this.sriSbb.onSms(event, null, null);
dlg = serviceSri.getLastMAPDialogSms();
this.mtSbb.setMapApplicationContextVersionsUsed(0);
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
// SRI response
imsi = new IMSIImpl(imsiDig);
networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN, nnnDig);
locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
evt1 = new SendRoutingInfoForSMResponseImpl(imsi, locationInfoWithLMSI, null, null, null);
evt1.setMAPDialog(dlg);
this.sriSbb.onSendRoutingInfoForSMResponse(evt1, null);
this.sriSbb.onDialogDelimiter(null, null);
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertTrue(this.mtSbb.isNegotiatedMapVersionUsing());
dlg = serviceMt.getLastMAPDialogSms();
vers = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(vers, MAPApplicationContextVersion.version2);
evt5 = new DialogReject(dlg, MAPRefuseReason.PotentialVersionIncompatibility, null, null);
this.mtSbb.onDialogReject(evt5, null);
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version1));
assertTrue(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version2));
assertFalse(this.mtSbb.isMAPVersionTested(MAPApplicationContextVersion.version3));
assertFalse(this.mtSbb.isNegotiatedMapVersionUsing());
dlg = serviceMt.getLastMAPDialogSms();
vers = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(vers, MAPApplicationContextVersion.version1);
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MtTest method SuccessDeliveryReceiptTest.
/**
* MAP V3, 1 message, 1 segment, GSM7
* +receiptRequest
*/
@Test(groups = { "Mt" })
public void SuccessDeliveryReceiptTest() throws Exception {
if (!this.cassandraDbInited)
return;
MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
MProcManagement.getInstance("Test");
// this.clearDatabase();
ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
SmsDef sd1 = new SmsDef();
sd1.dataCodingScheme = 16;
sd1.receiptRequest = true;
lst.add(sd1);
SmsSet smsSet = prepareDatabase(lst);
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNotNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
MAPApplicationContextVersion acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version3);
assertNull(serviceMt.getLastMAPDialogSms());
ArrayList<MAPTestEvent> lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
assertEquals(dlg.getLocalAddress().getGlobalTitle().getDigits(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(((GlobalTitle0100) dlg.getLocalAddress().getGlobalTitle()).getNumberingPlan(), org.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);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
// SRI response
IMSI imsi = new IMSIImpl(imsiDig);
ISDNAddressString networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, org.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);
this.sriSbb.onDialogDelimiter(null, null);
dlg = serviceMt.getLastMAPDialogSms();
acv = dlg.getApplicationContext().getApplicationContextVersion();
assertEquals(acv, MAPApplicationContextVersion.version3);
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
dlg = serviceMt.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
evt = lstEvt.get(0);
assertEquals(evt.testEventType, MAPTestEventType.componentAdded);
MtForwardShortMessageRequestImpl mtFsmReq = (MtForwardShortMessageRequestImpl) evt.event;
assertFalse(mtFsmReq.getMoreMessagesToSend());
SM_RP_DA sm_RP_DA = mtFsmReq.getSM_RP_DA();
IMSI daImsi = sm_RP_DA.getIMSI();
assertEquals(daImsi.getData(), imsiDig);
SM_RP_OA sm_RP_OA = mtFsmReq.getSM_RP_OA();
AddressString scas = sm_RP_OA.getServiceCentreAddressOA();
assertEquals(scas.getAddress(), smscPropertiesManagement.getServiceCenterGt());
assertEquals(scas.getAddressNature(), AddressNature.international_number);
assertEquals(scas.getNumberingPlan(), org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan.ISDN);
SmsSignalInfo ssi = mtFsmReq.getSM_RP_UI();
SmsDeliverTpdu tpdu = (SmsDeliverTpdu) ssi.decodeTpdu(false);
assertEquals(tpdu.getDataCodingScheme().getCode(), 16);
assertFalse(tpdu.getForwardedOrSpawned());
assertFalse(tpdu.getMoreMessagesToSend());
assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
assertEquals(tpdu.getOriginatingAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
assertEquals(tpdu.getOriginatingAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
assertEquals(tpdu.getProtocolIdentifier().getCode(), 7);
assertFalse(tpdu.getReplyPathExists());
assertEquals(tpdu.getServiceCentreTimeStamp().getDay(), curDate.getDate());
// assertEquals(tpdu.getServiceCentreTimeStamp().getMinute(), curDate.getMinutes());
int mon1 = tpdu.getServiceCentreTimeStamp().getMonth();
int mon2 = curDate.getMonth() + 1;
assertEquals(mon1, mon2);
assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
assertFalse(tpdu.getStatusReportIndication());
assertFalse(tpdu.getUserDataHeaderIndicator());
UserData ud = tpdu.getUserData();
ud.decode();
assertNull(ud.getDecodedUserDataHeader());
String msg1 = ud.getDecodedMessage();
assertEquals(msg1, msgShort);
evt = lstEvt.get(1);
assertEquals(evt.testEventType, MAPTestEventType.send);
UUID smsId = smsSet.getSms(0).getDbId();
SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
// Mt response
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
MtForwardShortMessageResponseImpl evt2 = new MtForwardShortMessageResponseImpl(null, null);
evt2.setMAPDialog(dlg);
DialogAccept daevt = new DialogAccept(dlg, null);
this.mtSbb.onDialogAccept(daevt, null);
this.mtSbb.onMtForwardShortMessageResponse(evt2, null);
DialogClose dcl = new DialogClose(dlg);
this.mtSbb.onDialogClose(dcl, null);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
dlg = serviceSri.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
dlg = serviceMt.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertNull(smsX);
smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx2);
PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
long l1 = 0;
for (PreparedStatementCollection psc : pscc) {
l1 = this.pers.c2_getDueSlotForTargetId(psc, taR.getTargetId());
if (l1 != 0)
break;
}
SmsSet set1 = this.pers.c2_getRecordListForTargeId(l1, taR.getTargetId());
// TODO: ???? .........
// this.pers.fetchSchedulableSms(set1, true);
// TODO: ???? .........
assertEquals(set1.getSmsCount(), 1);
Sms ss1 = set1.getSms(0);
assertEquals(set1.getDestAddr(), origDig);
assertEquals(ss1.getSourceAddr(), msdnDig);
assertEquals(ss1.getEsmClass(), 7);
// String sx = new String(ss1.getShortMessage());
String sx = new String(ss1.getShortMessageText());
assertTrue(sx.contains("err:000"));
dlg = serviceRsds.getLastMAPDialogSms();
assertNull(dlg);
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class MtTest method SuccessError3Test.
/**
* MAP V3, SRI error absentSubscriber -> RSDS -> new delivery attempt -> SRI error absentSubscriber -> RSDS
*/
@Test(groups = { "Mt" })
public void SuccessError3Test() throws Exception {
if (!this.cassandraDbInited)
return;
MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
MProcManagement.getInstance("Test");
ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
SmsDef sd1 = new SmsDef();
lst.add(sd1);
SmsSet smsSet = prepareDatabase(lst);
Sms sms1 = smsSet.getSms(0);
UUID smsId = sms1.getDbId();
SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNull(smsx1);
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNotNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 1);
assertNull(smsSet.getStatus());
assertEquals(smsSet.getInSystem(), 0);
assertNull(smsSet.getInSystemDate());
assertEquals(smsSet.getDueDelay(), 0);
assertNull(smsSet.getDueDate());
assertFalse(smsSet.isAlertingSupported());
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
// SRI response
MAPErrorMessage mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
ErrorComponent evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
this.sriSbb.onErrorComponent(evt2, null);
ISDNAddressStringImpl storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, msdnDig);
MWStatusImpl mwStatus = new MWStatusImpl(false, true, false, true);
InformServiceCentreRequestImpl evt4 = new InformServiceCentreRequestImpl(storedMSISDN, mwStatus, null, null, null);
evt4.setMAPDialog(dlg);
this.sriSbb.onDialogDelimiter(null, null);
PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
long l1 = 0;
for (PreparedStatementCollection psc : pscc) {
l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
if (l1 != 0)
break;
}
smsx1 = this.pers.obtainArchiveSms(l1, smsSet.getDestAddr(), smsId);
assertNull(smsx1);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNull(smsSetX);
smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
assertEquals(smsSet.getStatus(), ErrorCode.ABSENT_SUBSCRIBER);
// assertEquals(smsSet.getInSystem(), 1);
// this.testDateEq(smsSet.getInSystemDate(), curDate);
assertEquals(smsSet.getDueDelay(), SmscPropertiesManagement.getInstance().getSecondDueDelay());
this.testDateEq(new Date(new Date().getTime() + SmscPropertiesManagement.getInstance().getSecondDueDelay() * 1000), smsSet.getDueDate());
assertFalse(smsSet.isAlertingSupported());
dlg = serviceRsds.getLastMAPDialogSms();
// rsds response 2
ReportSMDeliveryStatusResponseImpl evt7 = new ReportSMDeliveryStatusResponseImpl(2, null, null);
evt7.setMAPDialog(dlg);
this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);
DialogClose dcl = new DialogClose(dlg);
this.rsdsSbb.onDialogClose(dcl, null);
// second delivery attempt **********************
ArrayList<SmsSet> lst1 = this.pers.c2_getRecordList(l1);
ArrayList<SmsSet> lst2 = this.pers.c2_sortRecordList(lst1);
smsSet = lst2.get(0);
// initial onSms message
event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.makeDlvIsNotInited();
this.sriSbb.onSms(event, null, null);
dlg = serviceSri.getLastMAPDialogSms();
// SRI response
mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
this.sriSbb.onErrorComponent(evt2, null);
storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, msdnDig);
mwStatus = new MWStatusImpl(false, true, false, true);
evt4 = new InformServiceCentreRequestImpl(storedMSISDN, mwStatus, null, null, null);
evt4.setMAPDialog(dlg);
this.sriSbb.onDialogDelimiter(null, null);
for (PreparedStatementCollection psc : pscc) {
l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
if (l1 != 0)
break;
}
smsx1 = this.pers.obtainArchiveSms(l1, smsSet.getDestAddr(), smsId);
assertNull(smsx1);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNull(smsSetX);
smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
assertEquals(smsSet.getDueDelay(), 600);
this.testDateEq(new Date(new Date().getTime() + 600 * 1000), smsSet.getDueDate());
for (PreparedStatementCollection psc : pscc) {
l1 = this.pers.c2_getDueSlotForTargetId(psc, taR.getTargetId());
if (l1 != 0)
break;
}
assertEquals(l1, 0);
// we do no test here rsds response 2 - it is the same
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class AlertSbb method setupAlert.
private void setupAlert(ISDNAddressString msisdn, AddressString serviceCentreAddress, int networkId) {
PersistenceRAInterface pers = this.getStore();
SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
// checking if SMSC is paused
if (smscPropertiesManagement.isDeliveryPause())
return;
// checking if database is available
if (!pers.isDatabaseAvailable())
return;
int addrTon = msisdn.getAddressNature().getIndicator();
int addrNpi = msisdn.getNumberingPlan().getIndicator();
String addr = msisdn.getAddress();
TargetAddress lock = pers.obtainSynchroObject(new TargetAddress(addrTon, addrNpi, addr, networkId));
try {
synchronized (lock) {
try {
long dueSlot = 0;
SmsSet smsSet0 = new SmsSet();
smsSet0.setDestAddr(addr);
smsSet0.setDestAddrNpi(addrNpi);
smsSet0.setDestAddrTon(addrTon);
smsSet0.setNetworkId(networkId);
SmsSet smsSet1 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet0.getTargetId());
if (smsSet1 != null) {
// message is already in process
if (logger.isInfoEnabled()) {
logger.info(String.format("Received AlertServiceCentre for MSISDN=%s but the delivering for this dest is already in progress", addr));
}
return;
}
dueSlot = pers.c2_getDueSlotForTargetId(smsSet0.getTargetId());
if (dueSlot != 0 && dueSlot > pers.c2_getCurrentDueSlot() && pers.c2_checkDueSlotWritingPossibility(dueSlot) == dueSlot) {
pers.c2_registerDueSlotWriting(dueSlot);
try {
if (dueSlot != 0 && dueSlot > pers.c2_getCurrentDueSlot()) {
SmsSet smsSet = pers.c2_getRecordListForTargeId(dueSlot, smsSet0.getTargetId());
if (smsSet != null) {
if (logger.isInfoEnabled()) {
logger.info(String.format("Received AlertServiceCentre for MSISDN=%s, SmsSet was loaded with %d messages", addr, smsSet.getSmsCount()));
}
for (int i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
Sms sms = smsSet.getSms(i1);
sms.setInvokedByAlert(true);
}
ArrayList<SmsSet> lstS = new ArrayList<SmsSet>();
lstS.add(smsSet);
ArrayList<SmsSet> lst = pers.c2_sortRecordList(lstS);
if (lst.size() > 0) {
smsSet = lst.get(0);
smsSet.setProcessingStarted();
this.scheduler.injectSmsDatabase(smsSet);
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("Received AlertServiceCentre for MSISDN=%s, dueSlot was scheduled but no SmsSet was loaded", addr));
}
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("Received AlertServiceCentre for MSISDN=%s but no dueSlot was scheduled or the scheduled dueSlot will come soon - 2", addr));
}
}
} finally {
pers.c2_unregisterDueSlotWriting(dueSlot);
}
} else {
if (logger.isInfoEnabled()) {
logger.info(String.format("Received AlertServiceCentre for MSISDN=%s but no dueSlot was scheduled or the scheduled dueSlot will come soon - 1", addr));
}
}
} catch (PersistenceException e) {
this.logger.severe("PersistenceException when setupAlert()" + e.getMessage(), e);
} catch (Exception e) {
this.logger.severe("Exception when setupAlert()" + e.getMessage(), e);
}
}
} finally {
pers.releaseSynchroObject(lock);
}
}
use of org.mobicents.smsc.library.Sms in project smscgateway by RestComm.
the class AlertTest method prepareDatabase.
private void prepareDatabase() throws PersistenceException {
SmsSet smsSet = createEmptySmsSet(ta1);
Sms sms = this.prepareSms(smsSet);
this.pers.c2_scheduleMessage_ReschedDueSlot(sms, false, true);
procDueSlot = sms.getDueSlot();
procTargetId = ta1.getTargetId();
procId = sms.getDbId();
// SmsSet smsSet_x1 = this.pers.obtainSmsSet(ta1);
// Sms sms = this.prepareSms(smsSet_x1);
// this.pers.createLiveSms(sms);
// this.pers.setNewMessageScheduled(smsSet_x1, farDate);
}
Aggregations