use of org.mobicents.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MoSbbTest method testMo2_Gsm7.
@Test(groups = { "Mo" })
public void testMo2_Gsm7() throws Exception {
if (!this.cassandraDbInited)
return;
// this.clearDatabase();
// SmppSessionsProxy smppServerSessions = new SmppSessionsProxy();
// this.sbb.setSmppServerSessions(smppServerSessions);
AddressString serviceCentreAddressDA = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
SM_RP_DA sm_RP_DA = new SM_RP_DAImpl(serviceCentreAddressDA);
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "4444");
SM_RP_OAImpl sm_RP_OA = new SM_RP_OAImpl();
sm_RP_OA.setMsisdn(msisdn);
AddressField destinationAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "5555");
ProtocolIdentifier protocolIdentifier = new ProtocolIdentifierImpl(12);
// 3 hours: 1 for delay + 2 different timezone
Date valDate = MessageUtil.addHours(new Date(), 3);
int tzo = -valDate.getTimezoneOffset();
AbsoluteTimeStamp absoluteFormatValue = new AbsoluteTimeStampImpl(valDate.getYear(), valDate.getMonth(), valDate.getDate(), valDate.getHours(), valDate.getMinutes(), valDate.getSeconds(), tzo / 15 + 4 * 2);
// int year, int month, int day, int hour, int minute, int second, int timeZone
ValidityPeriod validityPeriod = new ValidityPeriodImpl(absoluteFormatValue);
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(0);
UserData userData = new UserDataImpl(new String("0123456789"), dataCodingScheme, null, null);
// userData.encode();
// String decodedMessage, DataCodingScheme dataCodingScheme, UserDataHeader decodedUserDataHeader, Charset gsm8Charset
SmsTpdu tpdu = new SmsSubmitTpduImpl(true, true, false, 150, destinationAddress, protocolIdentifier, validityPeriod, userData);
// boolean rejectDuplicates, boolean replyPathExists, boolean statusReportRequest, int messageReference,
// AddressField destinationAddress, ProtocolIdentifier protocolIdentifier, ValidityPeriod validityPeriod, UserData userData
// tpdu.encodeData();
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequest event = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, false);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msg);
long dueSlot = this.pers.c2_getDueSlotForTime(new Date());
PreparedStatementCollection psc = this.pers.getStatementCollection(new Date());
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), null, null, null);
event.setMAPDialog(dialog);
Date curDate = new Date();
MAPApplicationContext act = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgMORelayContext, MAPApplicationContextVersion.version2);
dialog.setApplicationContext(act);
this.sbb.onForwardShortMessageRequest(event, null);
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
assertEquals(dialog.getResponseCount(), 1);
assertEquals(dialog.getErrorList().size(), 0);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getInSystem(), 0);
assertEquals(smsSet.getDueDelay(), 0);
assertNull(smsSet.getStatus());
assertFalse(smsSet.isAlertingSupported());
Sms sms = smsSet.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 0);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 131);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 2);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 1));
assertEquals(sms.getDeliveryCount(), 0);
// assertDateEq(smsSet.getDueDate(), new Date(curDate.getTime() + 1 * 60 * 1000));
// assertEquals(new String(sms.getShortMessage()), "0123456789");
assertEquals(sms.getShortMessageText(), "0123456789");
assertNull(sms.getShortMessageBin());
}
use of org.mobicents.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MoSbbTest method testMo3_Usc2.
@Test(groups = { "Mo" })
public void testMo3_Usc2() throws Exception {
if (!this.cassandraDbInited)
return;
// this.clearDatabase();
// SmppSessionsProxy smppServerSessions = new SmppSessionsProxy();
// this.sbb.setSmppServerSessions(smppServerSessions);
AddressString serviceCentreAddressDA = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
SM_RP_DA sm_RP_DA = new SM_RP_DAImpl(serviceCentreAddressDA);
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "4444");
SM_RP_OAImpl sm_RP_OA = new SM_RP_OAImpl();
sm_RP_OA.setMsisdn(msisdn);
AddressField destinationAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "5555");
ProtocolIdentifier protocolIdentifier = new ProtocolIdentifierImpl(12);
DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(8);
UserData userData = new UserDataImpl(new String("������"), dataCodingScheme, null, null);
// String decodedMessage, DataCodingScheme dataCodingScheme, UserDataHeader decodedUserDataHeader, Charset gsm8Charset
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
// boolean rejectDuplicates, boolean replyPathExists, boolean statusReportRequest, int messageReference,
// AddressField destinationAddress, ProtocolIdentifier protocolIdentifier, ValidityPeriod validityPeriod, UserData userData
// tpdu.encodeData();
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequest event = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, false);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msg);
long dueSlot = this.pers.c2_getDueSlotForTime(new Date());
PreparedStatementCollection psc = this.pers.getStatementCollection(new Date());
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), null, null, null);
event.setMAPDialog(dialog);
Date curDate = new Date();
MAPApplicationContext act = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgMORelayContext, MAPApplicationContextVersion.version2);
dialog.setApplicationContext(act);
this.sbb.onForwardShortMessageRequest(event, null);
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
assertEquals(dialog.getResponseCount(), 1);
assertEquals(dialog.getErrorList().size(), 0);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getInSystem(), 0);
assertEquals(smsSet.getDueDelay(), 0);
assertNull(smsSet.getStatus());
assertFalse(smsSet.isAlertingSupported());
Sms sms = smsSet.getSms(0);
assertNotNull(sms);
assertEquals(sms.getSourceAddr(), "4444");
assertEquals(sms.getSourceAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(sms.getSourceAddrNpi(), SmppConstants.NPI_E164);
assertEquals(sms.getMessageId(), DBOperations.MESSAGE_ID_LAG + 1);
assertEquals(sms.getMoMessageRef(), 150);
assertEquals(sms.getDataCoding(), 8);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 3);
assertEquals(sms.getRegisteredDelivery(), 0);
assertEquals(sms.getProtocolId(), 12);
assertEquals(sms.getPriority(), 0);
assertEquals(sms.getReplaceIfPresent(), 0);
assertEquals(sms.getDefaultMsgId(), 0);
assertEquals(sms.getTlvSet().getOptionalParameterCount(), 0);
assertNull(sms.getScheduleDeliveryTime());
assertDateEq(sms.getValidityPeriod(), MessageUtil.addHours(curDate, 24 * 3));
assertEquals(sms.getDeliveryCount(), 0);
// assertDateEq(smsSet.getDueDate(), new Date(curDate.getTime() + 1 * 60 * 1000));
// Charset ucs2Charset = Charset.forName("UTF-16BE");
// ByteBuffer bb = ByteBuffer.wrap(sms.getShortMessage());
// CharBuffer bf = ucs2Charset.decode(bb);
// String s = bf.toString();
// assertEquals(s, "������");
assertEquals(sms.getShortMessageText(), "������");
assertNull(sms.getShortMessageBin());
}
use of org.mobicents.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MtCommonSbb method getSRIMAPApplicationContext.
protected MAPApplicationContext getSRIMAPApplicationContext(MAPApplicationContextVersion applicationContextVersion) {
MAPApplicationContext mapApplicationContext = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgGatewayContext, applicationContextVersion);
this.setSriMapVersion(applicationContextVersion.getVersion());
return mapApplicationContext;
}
use of org.mobicents.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class MtSbb method onDialogReject.
@Override
public void onDialogReject(DialogReject evt, ActivityContextInterface aci) {
try {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onDialogReject(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
MAPRefuseReason mapRefuseReason = evt.getRefuseReason();
if (mapRefuseReason == MAPRefuseReason.PotentialVersionIncompatibility && evt.getMAPDialog().getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1) {
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / PotentialVersionIncompatibility=" + evt);
}
MAPApplicationContextVersion newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If version1 already tried this is error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + newMAPApplicationContextVersion + " already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
// Now send new ForwardSM with supported ACN (MAP V1)
try {
// Update cache
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(MAPApplicationContextVersion.version1), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
// If ACN not supported, lets use the new one suggested
if (mapRefuseReason == MAPRefuseReason.ApplicationContextNotSupported) {
String nodeDigits = this.getNetworkNode().getGlobalTitle().getDigits();
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / ApplicationContextNotSupported for node " + nodeDigits + " Event=" + evt);
}
// Now send new MtSMS with supported ACN
ApplicationContextName tcapApplicationContextName = evt.getAlternativeApplicationContext();
MAPApplicationContext supportedMAPApplicationContext = MAPApplicationContext.getInstance(tcapApplicationContextName.getOid());
MAPApplicationContextVersion supportedMAPApplicationContextVersion = supportedMAPApplicationContext.getApplicationContextVersion();
MAPApplicationContextVersion newMAPApplicationContextVersion = supportedMAPApplicationContextVersion;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version3;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version2;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If all versions are already tried this is
// error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + " all MAP versions are already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
}
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(newMAPApplicationContextVersion), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
super.onDialogReject(evt, aci);
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.MSC_REFUSES_SM, "onDialogReject after MT Request: " + mapRefuseReason != null ? mapRefuseReason.toString() : "", true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onDialogReject() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
use of org.mobicents.protocols.ss7.map.api.MAPApplicationContext in project smscgateway by RestComm.
the class AlertTest method testAlert1_Gsm1.
@Test(groups = { "Alert" })
public void testAlert1_Gsm1() throws Exception {
if (!this.cassandraDbInited)
return;
this.prepareDatabase();
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
// boolean b1 = this.pers.checkSmsSetExists(ta1);
// assertTrue(b1);
// SmsSet smsSet = this.pers.obtainSmsSet(ta1);
// assertEquals(smsSet.getInSystem(), 1);
// assertEquals(smsSet.getDueDate(), farDate);
Thread.sleep(1000);
Date curDate = new Date();
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "5555");
AddressString serviceCentreAddress = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
AlertServiceCentreRequest evt = new AlertServiceCentreRequestImpl(msisdn, serviceCentreAddress);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPApplicationContext appCntx = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgAlertContext, MAPApplicationContextVersion.version2);
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), appCntx, null, null);
evt.setMAPDialog(dialog);
this.sbb.onAlertServiceCentreRequest(evt, null);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
// assertNotNull(smsSetX); TODO: this will work after alert is with direct Activities sending
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId);
// assertNull(smsX);
// b1 = this.pers.checkSmsSetExists(ta1);
// assertTrue(b1);
// smsSet = this.pers.obtainSmsSet(ta1);
// assertEquals(smsSet.getInSystem(), 1);
// this.testDateEq(smsSet.getDueDate(), curDate);
}
Aggregations