use of org.restcomm.slee.resource.map.events.DialogAccept in project smscgateway by RestComm.
the class MtTest method SuccessDelivery1ATest.
/**
* MAP V3, 1 message, 1 segment, GSM7 - TC-CONTINUE
*/
@Test(groups = { "Mt" })
public void SuccessDelivery1ATest() 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);
// initial onSms message
SmsSetEvent event = new SmsSetEvent();
event.setSmsSet(smsSet);
this.sriSbb.onSms(event, null, null);
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNotNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(smsX.getDeliveryCount(), 0);
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);
// 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);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNotNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
assertEquals(smsX.getDeliveryCount(), 0);
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(), 0);
assertFalse(tpdu.getForwardedOrSpawned());
assertFalse(tpdu.getMoreMessagesToSend());
assertEquals(tpdu.getOriginatingAddress().getAddressValue(), origDig);
assertEquals(tpdu.getOriginatingAddress().getNumberingPlanIdentification(), NumberingPlanIdentification.ISDNTelephoneNumberingPlan);
assertEquals(tpdu.getOriginatingAddress().getTypeOfNumber(), TypeOfNumber.InternationalNumber);
assertEquals(tpdu.getProtocolIdentifier().getCode(), 7);
assertFalse(tpdu.getReplyPathExists());
assertEquals(tpdu.getServiceCentreTimeStamp().getDay(), curDate.getDate());
// assertEquals(tpdu.getServiceCentreTimeStamp().getMinute(), curDate.getMinutes());
int mon1 = tpdu.getServiceCentreTimeStamp().getMonth();
int mon2 = curDate.getMonth() + 1;
assertEquals(mon1, mon2);
assertEquals(tpdu.getSmsTpduType(), SmsTpduType.SMS_DELIVER);
assertFalse(tpdu.getStatusReportIndication());
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);
// 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);
DialogDelimiter dcl = new DialogDelimiter(dlg);
this.mtSbb.onDialogDelimiter(dcl, null);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
assertNull(smsSetX);
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
assertNull(smsX);
dlg = serviceSri.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
dlg = serviceMt.getLastMAPDialogSms();
lstEvt = dlg.getEventList();
assertEquals(lstEvt.size(), 2);
smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId);
assertNotNull(smsx2);
dlg = serviceRsds.getLastMAPDialogSms();
assertNull(dlg);
}
use of org.restcomm.slee.resource.map.events.DialogAccept in project smscgateway by RestComm.
the class MtTest method SuccessDeliveryBTest.
/**
* MAP V3, 1 message, 1 segment, GSM7
* 160 chars including [] -> 2 segments
*/
@Test(groups = { "Mt" })
public void SuccessDeliveryBTest() 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();
sb.append("[");
for (int i1 = 0; i1 < 15; i1++) {
sb.append(" 123456789");
}
sb.append(" 1234567]");
String totalMsg = sb.toString();
// int segmlen = MessageUtil.getMaxSegmentedMessageBytesLength(new DataCodingSchemeImpl(8)) / 2;
String msga1 = totalMsg.substring(0, 151);
String msga2 = totalMsg.substring(151);
sd1.msg = totalMsg;
sd1.dataCodingScheme = 0;
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(), 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(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(), 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 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