use of org.mobicents.smsc.domain.MProcManagement in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testSubmitSm_MProc.
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_MProc() throws Exception {
if (!this.cassandraDbInited)
return;
MProcManagement mProcManagement = MProcManagement.getInstance();
SmscManagement smscManagement = SmscManagement.getInstance("Test");
SmppManagement smppManagement = SmppManagement.getInstance("Test");
smscManagement.setSmppManagement(smppManagement);
mProcManagement.setSmscManagement(smscManagement);
smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
// this.pers.stop();
DBOperations.getInstance().stop();
smscManagement.start();
try {
mProcManagement.destroyMProcRule(1);
} catch (Exception e) {
}
try {
mProcManagement.destroyMProcRule(2);
} catch (Exception e) {
}
mProcManagement.createMProcRule(1, MProcRuleFactoryDefault.RULE_CLASS_NAME, "desttonmask 1 destnpimask 1 originatingmask SMPP networkidmask 0 newnetworkid 5 adddestdigprefix 47 makecopy true");
mProcManagement.createMProcRule(2, MProcRuleFactoryDefault.RULE_CLASS_NAME, "networkidmask 5 newdestnpi 2 makecopy true");
// TODO: ***** make proper mproc rules testing
// MProcManagement.getInstance().createMProcRule(1, 1, 1, "-1", "SMPP", 0, 5, -1, -1, "47", true);
// MProcManagement.getInstance().createMProcRule(2, -1, -1, "-1", null, 5, -1, -1, 2, "-1", true);
// destTonMask, destNpiMask, destDigMask, originatingMask, networkIdMask, newNetworkId, newDestTon, newDestNpi,
// addDestDigPrefix, makeCopy
// TODO: ***** make proper mproc rules testing
this.smppSess = new SmppSessionsProxy();
this.sbb.setSmppServerSessions(smppSess);
int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_TIMEOUT;
long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
long windowMonitorInterval = SmppConstants.DEFAULT_WINDOW_MONITOR_INTERVAL;
long windowWaitTimeout = SmppConstants.DEFAULT_WINDOW_WAIT_TIMEOUT;
Esme esme = new Esme("Esme_1", "Esme_systemId_1", "pwd", "host", 0, false, null, SmppInterfaceVersionType.SMPP34, -1, -1, null, SmppBindType.TRANSCEIVER, SmppSession.Type.CLIENT, windowSize, connectTimeout, requestExpiryTimeout, clientBindTimeout, windowMonitorInterval, windowWaitTimeout, "Esme_1", true, 30000, 0, 0, -1, -1, "^[0-9a-zA-Z]*", -1, -1, "^[0-9a-zA-Z]*", 0, false, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1);
ActivityContextInterface aci = new SmppTransactionProxy(esme);
SubmitSm event = new SubmitSm();
Date curDate = new Date();
this.fillSm(event, curDate, true);
event.setShortMessage(msgUcs2);
long dueSlot = this.pers.c2_getDueSlotForTime(scheduleDeliveryTime);
PreparedStatementCollection psc = this.pers.getStatementCollection(scheduleDeliveryTime);
int b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
long b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
assertEquals(b1, 0);
assertEquals(b2, 0L);
TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
this.sbb.onSubmitSm(event, aci);
TargetAddress tax1 = new TargetAddress(1, 1, "475555", 5);
TargetAddress tax2 = new TargetAddress(1, 2, "475555", 5);
// int addrTon, int addrNpi, String addr, int networkId
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
b1 = this.pers.checkSmsExists(dueSlot, tax1.getTargetId());
assertEquals(b1, 1);
b1 = this.pers.checkSmsExists(dueSlot, tax2.getTargetId());
assertEquals(b1, 1);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
SmsSet smsSet2 = this.pers.c2_getRecordListForTargeId(dueSlot, tax1.getTargetId());
SmsSet smsSet3 = this.pers.c2_getRecordListForTargeId(dueSlot, tax2.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getNetworkId(), 0);
assertEquals(smsSet2.getDestAddr(), "475555");
assertEquals(smsSet2.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet2.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet2.getNetworkId(), 5);
assertEquals(smsSet3.getDestAddr(), "475555");
assertEquals(smsSet3.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet3.getDestAddrNpi(), SmppConstants.NPI_ISDN);
assertEquals(smsSet3.getNetworkId(), 5);
// this.checkSmsSet(smsSet, curDate, true);
// Sms sms = smsSet.getSms(0);
// assertEquals(sms.getShortMessageText(), sMsg); // msgUcs2
// assertEquals(sms.getShortMessageBin(), udhCode);
//
// assertEquals(this.smppSess.getReqList().size(), 0);
// assertEquals(this.smppSess.getRespList().size(), 1);
PduResponse resp = this.smppSess.getRespList().get(0);
assertEquals(resp.getCommandStatus(), 0);
assertEquals(resp.getOptionalParameterCount(), 0);
try {
mProcManagement.destroyMProcRule(1);
mProcManagement.destroyMProcRule(2);
} catch (Exception e) {
}
}
use of org.mobicents.smsc.domain.MProcManagement in project smscgateway by RestComm.
the class MtTest method testMProc_TempFail.
@Test(groups = { "Mt" })
public void testMProc_TempFail() throws Exception {
if (!this.cassandraDbInited)
return;
MProcManagement mProcManagement = MProcManagement.getInstance();
SmscManagement smscManagement = SmscManagement.getInstance("Test");
SmppManagement smppManagement = SmppManagement.getInstance("Test");
smscManagement.setSmppManagement(smppManagement);
mProcManagement.setSmscManagement(smscManagement);
smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
DBOperations.getInstance().stop();
smscManagement.start();
try {
mProcManagement.destroyMProcRule(1);
} catch (Exception e) {
}
try {
mProcManagement.destroyMProcRule(2);
} catch (Exception e) {
}
// mProcManagement.createMProcRule(1, MProcRuleFactoryDefault.RULE_CLASS_NAME,
// "networkidmask 0 newnetworkidaftertempfail 1");
mProcManagement.createMProcRule(1, MProcRuleFactoryDefault.RULE_CLASS_NAME, "networkidmask 0 newnetworkidafterpermfail 1");
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.mobicents.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);
evt1.setMAPDialog(dlg);
// MAPErrorMessage mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
// ErrorComponent evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
MAPErrorMessage mapErrorMessage = new MAPErrorMessageUnknownSubscriberImpl(null, null);
ErrorComponent evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
this.sriSbb.onErrorComponent(evt2, 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);
}
use of org.mobicents.smsc.domain.MProcManagement in project smscgateway by RestComm.
the class MoSbbTest method testMo4_MProc.
@Test(groups = { "Mo" })
public void testMo4_MProc() throws Exception {
if (!this.cassandraDbInited)
return;
MProcManagement mProcManagement = MProcManagement.getInstance();
SmscManagement smscManagement = SmscManagement.getInstance("Test");
SmppManagement smppManagement = SmppManagement.getInstance("Test");
smscManagement.setSmppManagement(smppManagement);
mProcManagement.setSmscManagement(smscManagement);
smscManagement.registerRuleFactory(new MProcRuleFactoryDefault());
smscManagement.start();
try {
mProcManagement.destroyMProcRule(1);
} catch (Exception e) {
}
try {
mProcManagement.destroyMProcRule(2);
} catch (Exception e) {
}
mProcManagement.createMProcRule(1, MProcRuleFactoryDefault.RULE_CLASS_NAME, "desttonmask 1 destnpimask 1 originatingmask SS7_MO networkidmask 0 adddestdigprefix 47 makecopy true");
mProcManagement.createMProcRule(2, MProcRuleFactoryDefault.RULE_CLASS_NAME, "networkidmask 0 newnetworkid 5 newdestton 2 makecopy true");
// TODO: ***** make proper mproc rules testing
// MProcManagement.getInstance().createMProcRule(1, 1, 1, "-1", "SS7_MO", 0, -1, -1, -1, "47", true);
// MProcManagement.getInstance().createMProcRule(2, -1, -1, "-1", null, 0, 5, 2, -1, "-1", true);
// destTonMask, destNpiMask, destDigMask, originatingMask, networkIdMask, newNetworkId, newDestTon, newDestNpi, addDestDigPrefix, makeCopy
// TODO: ***** make proper mproc rules testing
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("UCS2 USC2 USC2"), dataCodingScheme, null, null);
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequest event = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, false);
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);
TargetAddress tax1 = new TargetAddress(1, 1, "475555", 0);
TargetAddress tax2 = new TargetAddress(2, 1, "475555", 5);
// int addrTon, int addrNpi, String addr, int networkId
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
b2 = this.pers.c2_getDueSlotForTargetId(psc, tax1.getTargetId());
long dueSlot2 = b2;
b1 = this.pers.checkSmsExists(dueSlot, tax1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot2);
long dueSlot3 = b2;
b1 = this.pers.checkSmsExists(dueSlot, tax1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot3);
assertEquals(dialog.getResponseCount(), 1);
assertEquals(dialog.getErrorList().size(), 0);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
SmsSet smsSet2 = this.pers.c2_getRecordListForTargeId(dueSlot2, tax1.getTargetId());
SmsSet smsSet3 = this.pers.c2_getRecordListForTargeId(dueSlot3, tax2.getTargetId());
assertEquals(smsSet.getDestAddr(), "5555");
assertEquals(smsSet.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet.getNetworkId(), 0);
assertEquals(smsSet2.getDestAddr(), "475555");
assertEquals(smsSet2.getDestAddrTon(), SmppConstants.TON_INTERNATIONAL);
assertEquals(smsSet2.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet2.getNetworkId(), 0);
assertEquals(smsSet3.getDestAddr(), "475555");
assertEquals(smsSet3.getDestAddrTon(), SmppConstants.TON_NATIONAL);
assertEquals(smsSet3.getDestAddrNpi(), SmppConstants.NPI_E164);
assertEquals(smsSet3.getNetworkId(), 5);
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);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
sms = smsSet2.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);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
sms = smsSet3.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);
assertEquals(sms.getShortMessageText(), "UCS2 USC2 USC2");
assertNull(sms.getShortMessageBin());
try {
MProcManagement.getInstance().destroyMProcRule(1);
MProcManagement.getInstance().destroyMProcRule(2);
// MProcManagement.getInstance().destroyMProcRule(3);
} catch (Exception e) {
}
}
Aggregations