Search in sources :

Example 6 with SmppSessionsProxy

use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy 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 7 with SmppSessionsProxy

use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitMulti.

@Test(groups = { "TxSmppServer" })
public void testSubmitMulti() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.smppSess = new SmppSessionsProxy();
    this.sbb.setSmppServerSessions(smppSess);
    int windowSize = SmppConstants.DEFAULT_WINDOW_SIZE;
    long connectTimeout = SmppConstants.DEFAULT_CONNECT_TIMEOUT;
    long clientBindTimeout = SmppConstants.DEFAULT_BIND_TIMEOUT;
    long requestExpiryTimeout = SmppConstants.DEFAULT_REQUEST_EXPIRY_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);
    SubmitMulti event = new SubmitMulti();
    Date curDate = new Date();
    this.fillSm(event, curDate, true);
    event.setShortMessage(msgUcs2);
    Address destAddr = new Address();
    destAddr.setAddress("5555");
    destAddr.setTon(SmppConstants.TON_INTERNATIONAL);
    destAddr.setNpi(SmppConstants.NPI_E164);
    event.addDestAddresses(destAddr);
    Address destAddr2 = new Address();
    destAddr2.setAddress("5556");
    destAddr2.setTon(SmppConstants.TON_INTERNATIONAL);
    destAddr2.setNpi(SmppConstants.NPI_E164);
    event.addDestAddresses(destAddr2);
    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);
    b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
    assertEquals(b1, 0);
    assertEquals(b2, 0L);
    TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
    this.sbb.onSubmitMulti(event, aci);
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
    assertEquals(b1, 1);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    this.checkSmsSet(smsSet, curDate, true);
    Sms sms = smsSet.getSms(0);
    // msgUcs2
    assertEquals(sms.getShortMessageText(), sMsg);
    assertEquals(sms.getShortMessageBin(), udhCode);
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    SubmitMultiResp resp = (SubmitMultiResp) this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 0);
    assertEquals(resp.getOptionalParameterCount(), 0);
    assertEquals(resp.getUnsucessfulSmes().size(), 0);
}
Also used : TargetAddress(org.mobicents.smsc.library.TargetAddress) Address(com.cloudhopper.smpp.type.Address) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SubmitMultiResp(com.cloudhopper.smpp.pdu.SubmitMultiResp) Sms(org.mobicents.smsc.library.Sms) SubmitMulti(com.cloudhopper.smpp.pdu.SubmitMulti) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 8 with SmppSessionsProxy

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

Example 9 with SmppSessionsProxy

use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm_BadCodingSchema.

// @Test(groups = { "TxSmppServer" })
// public void testSubmitMulti_BadAddr() throws Exception {
// 
// if (!this.cassandraDbInited)
// return;
// 
// 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, -1, -1);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// 
// SubmitMulti event = new SubmitMulti();
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msgUcs2);
// 
// Address destAddr = new Address();
// destAddr.setAddress("5555");
// destAddr.setTon(SmppConstants.TON_SUBSCRIBER);
// destAddr.setNpi(SmppConstants.NPI_E164);
// event.addDestAddresses(destAddr);
// Address destAddr2 = new Address();
// destAddr2.setAddress("5556");
// destAddr2.setTon(SmppConstants.TON_INTERNATIONAL);
// destAddr2.setNpi(SmppConstants.NPI_E164);
// event.addDestAddresses(destAddr2);
// 
// 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);
// b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
// b2 = this.pers.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
// assertEquals(b1, 0);
// assertEquals(b2, 0L);
// 
// TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
// this.sbb.onSubmitMulti(event, aci);
// 
// b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
// assertEquals(b1, 0);
// b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
// assertEquals(b1, 1);
// 
// SubmitMultiResp resp = (SubmitMultiResp)this.smppSess.getRespList().get(0);
// assertEquals(resp.getCommandStatus(), 0);
// assertEquals(resp.getOptionalParameterCount(), 0);
// assertEquals(resp.getUnsucessfulSmes().size(), 1);
// assertEquals(resp.getUnsucessfulSmes().get(0).getAddress().getAddress(), "5555");
// }
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_BadCodingSchema() throws Exception {
    if (!this.cassandraDbInited)
        return;
    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(msgUtf8);
    DataCodingSchemeImpl dcss = new DataCodingSchemeImpl(DataCodingGroup.GeneralGroup, null, null, null, CharacterSet.GSM7, true);
    // DataCodingGroup dataCodingGroup, DataCodingSchemaMessageClass
    // messageClass,
    // DataCodingSchemaIndicationType dataCodingSchemaIndicationType,
    // Boolean setIndicationActive,
    // CharacterSet characterSet, boolean isCompressed
    event.setDataCoding((byte) 12);
    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.Utf8);
    this.sbb.onSubmitSm(event, aci);
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    assertEquals(b2, 0);
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    PduResponse resp = this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 260);
    assertEquals(resp.getOptionalParameterCount(), 1);
    Tlv tlvr = resp.getOptionalParameter(SmppConstants.TAG_ADD_STATUS_INFO);
    String errMsg = tlvr.getValueAsString();
    assertEquals(errMsg, "TxSmpp DataCoding scheme does not supported: 12 - Only GSM7, GSM8 and USC2 are supported");
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) Tlv(com.cloudhopper.smpp.tlv.Tlv) Test(org.testng.annotations.Test)

Example 10 with SmppSessionsProxy

use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm.

@Test(groups = { "TxSmppServer" })
public void testSubmitSm() throws Exception {
    if (!this.cassandraDbInited)
        return;
    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);
    b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
    assertEquals(b1, 1);
    SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
    this.checkSmsSet(smsSet, curDate, true);
    Sms sms = smsSet.getSms(0);
    // msgUcs2
    assertEquals(sms.getShortMessageText(), sMsg);
    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);
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) Esme(org.restcomm.smpp.Esme) Sms(org.mobicents.smsc.library.Sms) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Aggregations

SmppSessionsProxy (org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy)10 Test (org.testng.annotations.Test)10 Date (java.util.Date)9 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)9 Esme (org.restcomm.smpp.Esme)9 ActivityContextInterface (javax.slee.ActivityContextInterface)8 SubmitSm (com.cloudhopper.smpp.pdu.SubmitSm)7 Sms (org.mobicents.smsc.library.Sms)6 SmsSet (org.mobicents.smsc.library.SmsSet)6 PduResponse (com.cloudhopper.smpp.pdu.PduResponse)5 TargetAddress (org.mobicents.smsc.library.TargetAddress)4 Tlv (com.cloudhopper.smpp.tlv.Tlv)2 Address (com.cloudhopper.smpp.type.Address)2 MProcManagement (org.mobicents.smsc.domain.MProcManagement)2 SmscManagement (org.mobicents.smsc.domain.SmscManagement)2 MProcRuleFactoryDefault (org.mobicents.smsc.mproc.impl.MProcRuleFactoryDefault)2 DataCodingSchemeImpl (org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl)2 DataSm (com.cloudhopper.smpp.pdu.DataSm)1 SubmitMulti (com.cloudhopper.smpp.pdu.SubmitMulti)1 SubmitMultiResp (com.cloudhopper.smpp.pdu.SubmitMultiResp)1