Search in sources :

Example 11 with PreparedStatementCollection

use of org.mobicents.smsc.cassandra.PreparedStatementCollection in project smscgateway by RestComm.

the class MtTest method SuccessError3Test.

/**
 * MAP V3, SRI error absentSubscriber -> RSDS -> new delivery attempt -> SRI error absentSubscriber -> RSDS
 */
@Test(groups = { "Mt" })
public void SuccessError3Test() throws Exception {
    if (!this.cassandraDbInited)
        return;
    MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
    SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    MProcManagement.getInstance("Test");
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    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);
    assertNull(smsSet.getStatus());
    assertEquals(smsSet.getInSystem(), 0);
    assertNull(smsSet.getInSystemDate());
    assertEquals(smsSet.getDueDelay(), 0);
    assertNull(smsSet.getDueDate());
    assertFalse(smsSet.isAlertingSupported());
    // initial onSms message
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.onSms(event, null, null);
    MAPDialogSmsProxy dlg = serviceSri.getLastMAPDialogSms();
    // SRI response
    MAPErrorMessage mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
    ErrorComponent evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
    this.sriSbb.onErrorComponent(evt2, null);
    ISDNAddressStringImpl storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, msdnDig);
    MWStatusImpl mwStatus = new MWStatusImpl(false, true, false, true);
    InformServiceCentreRequestImpl evt4 = new InformServiceCentreRequestImpl(storedMSISDN, mwStatus, null, null, null);
    evt4.setMAPDialog(dlg);
    this.sriSbb.onDialogDelimiter(null, null);
    PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
    long l1 = 0;
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
        if (l1 != 0)
            break;
    }
    smsx1 = this.pers.obtainArchiveSms(l1, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
    assertEquals(smsSet.getStatus(), ErrorCode.ABSENT_SUBSCRIBER);
    // assertEquals(smsSet.getInSystem(), 1);
    // this.testDateEq(smsSet.getInSystemDate(), curDate);
    assertEquals(smsSet.getDueDelay(), SmscPropertiesManagement.getInstance().getSecondDueDelay());
    this.testDateEq(new Date(new Date().getTime() + SmscPropertiesManagement.getInstance().getSecondDueDelay() * 1000), smsSet.getDueDate());
    assertFalse(smsSet.isAlertingSupported());
    dlg = serviceRsds.getLastMAPDialogSms();
    // rsds response 2
    ReportSMDeliveryStatusResponseImpl evt7 = new ReportSMDeliveryStatusResponseImpl(2, null, null);
    evt7.setMAPDialog(dlg);
    this.rsdsSbb.onReportSMDeliveryStatusResponse(evt7, null);
    DialogClose dcl = new DialogClose(dlg);
    this.rsdsSbb.onDialogClose(dcl, null);
    // second delivery attempt **********************
    ArrayList<SmsSet> lst1 = this.pers.c2_getRecordList(l1);
    ArrayList<SmsSet> lst2 = this.pers.c2_sortRecordList(lst1);
    smsSet = lst2.get(0);
    // initial onSms message
    event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    this.sriSbb.makeDlvIsNotInited();
    this.sriSbb.onSms(event, null, null);
    dlg = serviceSri.getLastMAPDialogSms();
    // SRI response
    mapErrorMessage = new MAPErrorMessageAbsentSubscriberSMImpl(null, null, null);
    evt2 = new ErrorComponent(dlg, 0L, mapErrorMessage);
    this.sriSbb.onErrorComponent(evt2, null);
    storedMSISDN = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, msdnDig);
    mwStatus = new MWStatusImpl(false, true, false, true);
    evt4 = new InformServiceCentreRequestImpl(storedMSISDN, mwStatus, null, null, null);
    evt4.setMAPDialog(dlg);
    this.sriSbb.onDialogDelimiter(null, null);
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
        if (l1 != 0)
            break;
    }
    smsx1 = this.pers.obtainArchiveSms(l1, smsSet.getDestAddr(), smsId);
    assertNull(smsx1);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
    assertEquals(smsSet.getDueDelay(), 600);
    this.testDateEq(new Date(new Date().getTime() + 600 * 1000), smsSet.getDueDate());
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, taR.getTargetId());
        if (l1 != 0)
            break;
    }
    assertEquals(l1, 0);
// we do no test here rsds response 2 - it is the same
}
Also used : MWStatusImpl(org.restcomm.protocols.ss7.map.service.sms.MWStatusImpl) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ReportSMDeliveryStatusResponseImpl(org.restcomm.protocols.ss7.map.service.sms.ReportSMDeliveryStatusResponseImpl) ArrayList(java.util.ArrayList) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) Date(java.util.Date) ErrorComponent(org.restcomm.slee.resource.map.events.ErrorComponent) MAPErrorMessageAbsentSubscriberSMImpl(org.restcomm.protocols.ss7.map.errors.MAPErrorMessageAbsentSubscriberSMImpl) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) DialogClose(org.restcomm.slee.resource.map.events.DialogClose) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) Sms(org.mobicents.smsc.library.Sms) UUID(java.util.UUID) InformServiceCentreRequestImpl(org.restcomm.protocols.ss7.map.service.sms.InformServiceCentreRequestImpl) SmsSet(org.mobicents.smsc.library.SmsSet) MAPErrorMessage(org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessage) Test(org.testng.annotations.Test)

Example 12 with PreparedStatementCollection

use of org.mobicents.smsc.cassandra.PreparedStatementCollection in project smscgateway by RestComm.

the class MoSbbTest method testMo4_Gsm8.

@Test(groups = { "Mo" })
public void testMo4_Gsm8() throws Exception {
    if (!this.cassandraDbInited)
        return;
    // 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(4);
    UserDataHeader decodedUserDataHeader = new UserDataHeaderImpl();
    UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 55, 3, 1);
    decodedUserDataHeader.addInformationElement(informationElement);
    UserData userData = new UserDataImpl("abc 01234567890", dataCodingScheme, decodedUserDataHeader, isoCharset);
    SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
    // isoCharset
    SmsSignalInfo sm_RP_UI_0 = new SmsSignalInfoImpl(tpdu, null);
    ForwardShortMessageRequestImpl event0 = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI_0, false);
    AsnOutputStream aos = new AsnOutputStream();
    event0.encodeAll(aos);
    ForwardShortMessageRequestImpl event = new ForwardShortMessageRequestImpl();
    AsnInputStream ais = new AsnInputStream(aos.toByteArray());
    ais.readTag();
    event.decodeAll(ais);
    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(), 4);
    assertNull(sms.getOrigEsmeName());
    assertNull(sms.getOrigSystemId());
    assertNull(sms.getServiceType());
    assertEquals(sms.getEsmClass() & 0xFF, 67);
    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(), "abc 01234567890");
    assertEquals(sms.getShortMessageBin(), decodedUserDataHeader.getEncodedData());
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserDataHeaderImpl(org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl) AsnInputStream(org.mobicents.protocols.asn.AsnInputStream) 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) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ProtocolIdentifierImpl(org.restcomm.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) UserDataHeaderElement(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeaderElement) 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) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) 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) ConcatenatedShortMessagesIdentifierImpl(org.restcomm.protocols.ss7.map.smstpdu.ConcatenatedShortMessagesIdentifierImpl) 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) 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) AsnOutputStream(org.mobicents.protocols.asn.AsnOutputStream) 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 13 with PreparedStatementCollection

use of org.mobicents.smsc.cassandra.PreparedStatementCollection in project smscgateway by RestComm.

the class MtTest method onDeliveryErrorTest.

/**
 * onDeliveryError test
 */
@Test(groups = { "Mt" })
public void onDeliveryErrorTest() throws Exception {
    if (!this.cassandraDbInited)
        return;
    MAPServiceSmsProxy serviceSri = (MAPServiceSmsProxy) this.sriSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceMt = (MAPServiceSmsProxy) this.mtSbb.mapProvider.getMAPServiceSms();
    MAPServiceSmsProxy serviceRsds = (MAPServiceSmsProxy) this.rsdsSbb.mapProvider.getMAPServiceSms();
    SmscPropertiesManagement smscPropertiesManagement = SmscPropertiesManagement.getInstance();
    MProcManagement.getInstance("Test");
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.valididtyPeriodIsOver = true;
    sd1.msg = "a1";
    lst.add(sd1);
    SmsDef sd2 = new SmsDef();
    sd2.valididtyPeriodIsOver = true;
    sd2.msg = "a2";
    lst.add(sd2);
    SmsDef sd3 = new SmsDef();
    sd3.msg = "b1";
    lst.add(sd3);
    SmsSet smsSet = prepareDatabase(lst);
    Sms sms1 = smsSet.getSms(0);
    Sms sms2 = smsSet.getSms(1);
    Sms sms3 = smsSet.getSms(2);
    UUID smsId1 = sms1.getDbId();
    UUID smsId2 = sms2.getDbId();
    UUID smsId3 = sms3.getDbId();
    SmsProxy smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId1);
    SmsProxy smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId2);
    SmsProxy smsx3 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId3);
    assertNull(smsx1);
    assertNull(smsx2);
    assertNull(smsx3);
    SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNotNull(smsSetX);
    Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[0]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[1]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId[2]);
    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);
    this.mtSbb.setTargetId(smsSet.getTargetId());
    // SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason, boolean removeSmsSet
    this.sriSbb.onDeliveryError(smsSet, ErrorAction.subscriberBusy, ErrorCode.ABSENT_SUBSCRIBER, "X error", true, null, false, ProcessingType.SS7_MT);
    PreparedStatementCollection[] pscc = this.pers.c2_getPscList();
    long l1 = 0;
    for (PreparedStatementCollection psc : pscc) {
        l1 = this.pers.c2_getDueSlotForTargetId(psc, procTargetId);
        if (l1 != 0)
            break;
    }
    smsx1 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId1);
    smsx2 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId2);
    smsx3 = this.pers.obtainArchiveSms(procDueSlot, smsSet.getDestAddr(), smsId3);
    assertNotNull(smsx1);
    assertNotNull(smsx2);
    assertNull(smsx3);
    smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
    assertNull(smsSetX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[0]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[1]);
    assertNull(smsX);
    smsX = this.pers.obtainLiveSms(l1, procTargetId, procId[2]);
    assertEquals(smsX.getSmsSet().getInSystem(), 0);
    assertEquals(SmsSetCache.getInstance().getProcessingSmsSetSize(), 0);
}
Also used : MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ArrayList(java.util.ArrayList) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmscPropertiesManagement(org.mobicents.smsc.domain.SmscPropertiesManagement) SmsProxy(org.mobicents.smsc.slee.resources.persistence.SmsProxy) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) Sms(org.mobicents.smsc.library.Sms) UUID(java.util.UUID) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 14 with PreparedStatementCollection

use of org.mobicents.smsc.cassandra.PreparedStatementCollection in project smscgateway by RestComm.

the class CassandraTest method testOldFormatMessage.

@Test(groups = { "cassandra" })
public void testOldFormatMessage(TargetAddress ta, DataCodingScheme dcs, String msg, UserDataHeader udh, int size) throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    TargetAddress lock = this.sbb.obtainSynchroObject(ta);
    long dueSlot;
    Sms sms;
    try {
        synchronized (lock) {
            SmsSet smsSet = new SmsSet();
            smsSet.setDestAddr(ta.getAddr());
            smsSet.setDestAddrNpi(ta.getAddrNpi());
            smsSet.setDestAddrTon(ta.getAddrTon());
            smsSet.setCorrelationId("CI=0000");
            smsSet.setNetworkId(9);
            sms = new Sms();
            sms.setSmsSet(smsSet);
            sms.setDbId(UUID.randomUUID());
            sms.setSourceAddr("11112");
            sms.setSourceAddrTon(1);
            sms.setSourceAddrNpi(1);
            sms.setMessageId(8888888);
            sms.setOrigNetworkId(49);
            sms.setDataCoding(dcs.getCode());
            sms.setShortMessageText(msg);
            if (udh != null) {
                sms.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
                sms.setShortMessageBin(udh.getEncodedData());
            }
            dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta.getTargetId());
            if (dueSlot == 0 || dueSlot <= sbb.c2_getCurrentDueSlot()) {
                dueSlot = sbb.c2_getDueSlotForNewSms();
                sbb.c2_updateDueSlotForTargetId(ta.getTargetId(), dueSlot);
            }
            sms.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    lock = this.sbb.obtainSynchroObject(ta);
    try {
        synchronized (lock) {
            sbb.c2_registerDueSlotWriting(dueSlot);
            ArrayList<SmsSet> lst0, lst;
            try {
                lst0 = sbb.c2_getRecordList(dueSlot);
                lst = sbb.c2_sortRecordList(lst0);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
            assertEquals(lst.size(), size);
            SmsSet smsSet;
            if (size == 0) {
                // messages are not in res because smsSet is already in processing
                smsSet = SmsSetCache.getInstance().getProcessingSmsSet(ta.getTargetId());
            } else {
                smsSet = lst.get(0);
            }
            assertEquals(smsSet.getNetworkId(), 9);
            assertEquals(sms.getOrigNetworkId(), 49);
            for (Sms sms1 : smsSet.getRawListLastSegment()) {
                if (sms1.getDbId().equals(sms.getDbId())) {
                    assertEquals(sms1.getDataCoding(), dcs.getCode());
                    if (msg != null)
                        assertEquals(sms1.getShortMessageText(), msg);
                    else
                        assertNull(sms1.getShortMessageText());
                    if (udh != null)
                        assertEquals(sms1.getShortMessageBin(), udh.getEncodedData());
                    else
                        assertNull(sms1.getShortMessageBin());
                    assertEquals(smsSet.getCorrelationId(), "CI=0000");
                }
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 15 with PreparedStatementCollection

use of org.mobicents.smsc.cassandra.PreparedStatementCollection in project smscgateway by RestComm.

the class CassandraTest method testingDueSlotForTargetId.

@Test(groups = { "cassandra" })
public void testingDueSlotForTargetId() throws Exception {
    if (!this.cassandraDbInited)
        return;
    Date dt = new Date();
    String targetId = "111333";
    String targetId2 = "111444";
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    long l1 = sbb.c2_getDueSlotForTargetId(psc, targetId);
    long l2 = sbb.c2_getDueSlotForTargetId(psc, targetId2);
    assertEquals(l1, 0);
    assertEquals(l2, 0);
    long newDueSlot = sbb.c2_getDueSlotForNewSms();
    sbb.c2_updateDueSlotForTargetId(targetId, newDueSlot);
    l1 = sbb.c2_getDueSlotForTargetId(psc, targetId);
    l2 = sbb.c2_getDueSlotForTargetId(psc, targetId2);
    assertEquals(l1, newDueSlot);
    assertEquals(l2, 0);
}
Also used : Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) Test(org.testng.annotations.Test)

Aggregations

PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)28 Date (java.util.Date)24 Test (org.testng.annotations.Test)22 Sms (org.mobicents.smsc.library.Sms)21 SmsSet (org.mobicents.smsc.library.SmsSet)20 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)11 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)11 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)10 SmppSessionsProxy (org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy)9 ActivityContextInterface (javax.slee.ActivityContextInterface)8 TargetAddress (org.mobicents.smsc.library.TargetAddress)8 ArrayList (java.util.ArrayList)7 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)7 SubmitSm (com.cloudhopper.smpp.pdu.SubmitSm)6 UUID (java.util.UUID)6 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)6 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)6 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)6 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)6 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)6