Search in sources :

Example 1 with MProcRuleFactoryDefault

use of org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault 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) {
    }
}
Also used : MProcManagement(org.mobicents.smsc.domain.MProcManagement) PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) TransactionRolledbackLocalException(javax.slee.TransactionRolledbackLocalException) TransactionRequiredLocalException(javax.slee.TransactionRequiredLocalException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) SLEEException(javax.slee.SLEEException) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) SmscManagement(org.mobicents.smsc.domain.SmscManagement) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) SmppManagement(org.restcomm.smpp.SmppManagement) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 2 with MProcRuleFactoryDefault

use of org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault 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);
}
Also used : MProcManagement(org.mobicents.smsc.domain.MProcManagement) LocationInfoWithLMSI(org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) MAPErrorMessageUnknownSubscriberImpl(org.mobicents.protocols.ss7.map.errors.MAPErrorMessageUnknownSubscriberImpl) IMSIImpl(org.mobicents.protocols.ss7.map.primitives.IMSIImpl) ArrayList(java.util.ArrayList) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SendRoutingInfoForSMResponse(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) SendRoutingInfoForSMResponseImpl(org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl) MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) SmscManagement(org.mobicents.smsc.domain.SmscManagement) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI) SmppManagement(org.restcomm.smpp.SmppManagement) LocationInfoWithLMSIImpl(org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) ErrorComponent(org.mobicents.slee.resource.map.events.ErrorComponent) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage) Test(org.testng.annotations.Test)

Example 3 with MProcRuleFactoryDefault

use of org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault in project smscgateway by RestComm.

the class SMSCShellExecutorTest method testShellExecutor_MProc.

@Test(groups = { "ShellExecutor" })
public void testShellExecutor_MProc() throws Exception {
    TT_PersistenceProxy sbb = new TT_PersistenceProxy();
    boolean cassandraDbInited = sbb.testCassandraAccess();
    if (!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();
    SMSCShellExecutor exec = new SMSCShellExecutor();
    exec.setSmscManagement(smscManagement);
    mProcManagement.mprocs.clear();
    mProcManagement.store();
    assertEquals(mProcManagement.mprocs.size(), 0);
    String[] args = "smsc mproc add mproc 10 desttonmask 2 destnpimask 3 destdigmask ^[0-9a-zA-Z]* originatingmask SS7_MO networkidmask 21 newnetworkid 22 newdestton 4 newdestnpi 5 adddestdigprefix 47 makecopy true".split(" ");
    String s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    MProcRuleDefaultImpl rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 22);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 10 newnetworkid 23".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    args = "smsc mproc modify 11 newnetworkid 24".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getNewNetworkId(), 23);
    args = "smsc mproc add mproc 9 networkidmask 31 newnetworkid 32".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    assertEquals(mProcManagement.mprocs.size(), 0);
    mProcManagement.load();
    assertEquals(mProcManagement.mprocs.size(), 2);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    assertEquals(rule.getId(), 10);
    assertEquals(rule.getDestTonMask(), 2);
    assertEquals(rule.getDestNpiMask(), 3);
    assertEquals(rule.getDestDigMask(), "^[0-9a-zA-Z]*");
    assertEquals(rule.getOriginatingMask(), OrigType.SS7_MO);
    assertEquals(rule.getNetworkIdMask(), 21);
    assertEquals(rule.getNewNetworkId(), 23);
    assertEquals(rule.getNewDestTon(), 4);
    assertEquals(rule.getNewDestNpi(), 5);
    assertEquals(rule.getAddDestDigPrefix(), "47");
    assertTrue(rule.isMakeCopy());
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNotNull(rule);
    assertEquals(rule.getDestDigMask(), "-1");
    assertNull(rule.getOriginatingMask());
    assertEquals(rule.getNetworkIdMask(), 31);
    assertEquals(rule.getNewNetworkId(), 32);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(15);
    assertNull(rule);
    args = "smsc mproc show 9".split(" ");
    s = exec.execute(args);
    args = "smsc mproc show".split(" ");
    s = exec.execute(args);
    args = "smsc mproc remove 9".split(" ");
    s = exec.execute(args);
    assertEquals(mProcManagement.mprocs.size(), 1);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(10);
    assertNotNull(rule);
    rule = (MProcRuleDefaultImpl) mProcManagement.getMProcRuleById(9);
    assertNull(rule);
    mProcManagement.mprocs.clear();
    smscManagement.stop();
}
Also used : MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) SMSCShellExecutor(org.mobicents.smsc.domain.SMSCShellExecutor) SmppManagement(org.restcomm.smpp.SmppManagement) MProcRuleDefaultImpl(org.mobicents.smsc.mproc.impl.MProcRuleDefaultImpl) Test(org.testng.annotations.Test)

Example 4 with MProcRuleFactoryDefault

use of org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault 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) {
    }
}
Also used : DataCodingScheme(org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme) MProcManagement(org.mobicents.smsc.domain.MProcManagement) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) SmsTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SmsSignalInfoImpl(org.mobicents.protocols.ss7.map.service.sms.SmsSignalInfoImpl) TargetAddress(org.mobicents.smsc.library.TargetAddress) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) DataCodingSchemeImpl(org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) MProcRuleFactoryDefault(org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault) ProtocolIdentifierImpl(org.mobicents.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) SmscManagement(org.mobicents.smsc.domain.SmscManagement) UserDataImpl(org.mobicents.protocols.ss7.map.smstpdu.UserDataImpl) MAPProviderProxy(org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy) ProtocolIdentifier(org.mobicents.protocols.ss7.map.api.smstpdu.ProtocolIdentifier) SmppManagement(org.restcomm.smpp.SmppManagement) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) AddressStringImpl(org.mobicents.protocols.ss7.map.primitives.AddressStringImpl) AddressField(org.mobicents.protocols.ss7.map.api.smstpdu.AddressField) MoForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl) ForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) SM_RP_DAImpl(org.mobicents.protocols.ss7.map.service.sms.SM_RP_DAImpl) AddressFieldImpl(org.mobicents.protocols.ss7.map.smstpdu.AddressFieldImpl) MoForwardShortMessageRequest(org.mobicents.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest) ForwardShortMessageRequest(org.mobicents.protocols.ss7.map.api.service.sms.ForwardShortMessageRequest) SM_RP_OAImpl(org.mobicents.protocols.ss7.map.service.sms.SM_RP_OAImpl) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) Sms(org.mobicents.smsc.library.Sms) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA) MAPApplicationContext(org.mobicents.protocols.ss7.map.api.MAPApplicationContext) SmsSet(org.mobicents.smsc.library.SmsSet) SmsSubmitTpduImpl(org.mobicents.protocols.ss7.map.smstpdu.SmsSubmitTpduImpl) Test(org.testng.annotations.Test)

Aggregations

MProcRuleFactoryDefault (org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault)4 SmppManagement (org.restcomm.smpp.SmppManagement)4 Test (org.testng.annotations.Test)4 MProcManagement (org.mobicents.smsc.domain.MProcManagement)3 SmscManagement (org.mobicents.smsc.domain.SmscManagement)3 SmsSet (org.mobicents.smsc.library.SmsSet)3 Date (java.util.Date)2 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)2 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)2 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)2 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)2 Sms (org.mobicents.smsc.library.Sms)2 TargetAddress (org.mobicents.smsc.library.TargetAddress)2 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)2 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)2 SmppSessionsProxy (org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy)2 PduResponse (com.cloudhopper.smpp.pdu.PduResponse)1 SubmitSm (com.cloudhopper.smpp.pdu.SubmitSm)1 TlvConvertException (com.cloudhopper.smpp.tlv.TlvConvertException)1 ArrayList (java.util.ArrayList)1