Search in sources :

Example 61 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test3_2.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test3_2() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.msg = "Msg 1";
    sd1.stored = true;
    lst.add(sd1);
    SmsDef sd2 = new SmsDef();
    sd2.msg = "Msg 2";
    sd2.stored = true;
    lst.add(sd2);
    SmsDef sd3 = new SmsDef();
    sd3.msg = "Msg 3";
    sd3.stored = true;
    lst.add(sd3);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    // eventResp.setCommandStatus(2);
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    // eventResp.setSequenceNumber(10001);
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
    eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onPduRequestTimeoutParent(null, aci, eventContext);
// this.sbb.onDeliverSmResp(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Example 62 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbbTest method testSubmitSm_test1_2.

@Test(groups = { "RxSmppServer" })
public void testSubmitSm_test1_2() throws Exception {
    if (!this.cassandraDbInited)
        return;
    ArrayList<SmsDef> lst = new ArrayList<SmsDef>();
    SmsDef sd1 = new SmsDef();
    sd1.stored = true;
    lst.add(sd1);
    SmsSet smsSet = prepareDatabase(lst);
    SmsSetEvent event = new SmsSetEvent();
    event.setSmsSet(smsSet);
    EventContext eventContext = null;
    ActivityContextInterface aci = new SmppTransactionProxy(esme);
    this.sbb.onDeliverSm(event, aci, eventContext);
    DeliverSmResp eventResp = new DeliverSmResp();
    eventResp.setSequenceNumber(sbb.getNextSentSequenseId());
    this.sbb.onDeliverSmRespParent(eventResp, aci, eventContext);
}
Also used : EventContext(javax.slee.EventContext) SmsSetEvent(org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent) ActivityContextInterface(javax.slee.ActivityContextInterface) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) DeliverSmResp(com.cloudhopper.smpp.pdu.DeliverSmResp) Test(org.testng.annotations.Test)

Example 63 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class RxSmppServerSbbTest method prepareDatabase.

private SmsSet prepareDatabase(ArrayList<SmsDef> lst) throws PersistenceException {
    SmsSet smsSet = createEmptySmsSet(ta1);
    int i1 = 1;
    procDueSlot = -1;
    for (SmsDef smsDef : lst) {
        Sms sms = this.prepareSms(smsSet, i1, smsDef);
        if (sms.getStored()) {
            this.pers.c2_scheduleMessage_ReschedDueSlot(sms, false, true);
            procDueSlot = sms.getDueSlot();
        } else {
            smsSet.addSms(sms);
        }
        i1++;
    }
    if (procDueSlot != -1) {
        ArrayList<SmsSet> lst1 = this.pers.c2_getRecordList(procDueSlot);
        ArrayList<SmsSet> lst2 = this.pers.c2_sortRecordList(lst1);
        if (lst2.size() > 0) {
            SmsSet res = lst2.get(0);
            curDate = new Date();
            procTargetId = res.getTargetId();
            procId = new UUID[(int) res.getSmsCount()];
            for (i1 = 0; i1 < res.getSmsCount(); i1++) {
                procId[i1] = res.getSms(i1).getDbId();
            }
            return res;
        } else {
            return null;
        }
    } else {
        procTargetId = smsSet.getTargetId();
        procId = new UUID[(int) smsSet.getSmsCount()];
        for (i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
            procId[i1] = smsSet.getSms(i1).getDbId();
        }
        SmsSetCache.getInstance().addProcessingSmsSet(smsSet.getTargetId(), smsSet, 1000);
        return smsSet;
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Date(java.util.Date)

Example 64 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class DeliveryCommonSbbTest method testFailureLists.

@Test(groups = { "DeliveryCommonSbb" })
public void testFailureLists() {
    if (!this.cassandraDbInited)
        return;
    SmsSetCache.SMSSET_MSG_PRO_SEGMENT_LIMIT = 3;
    DeliveryCommonSbbProxy sbb = initiateSbb(null);
    loadSbb(sbb);
    SmsSet smsSet = new SmsSet();
    for (int i1 = 0; i1 < 20; i1++) {
        Sms sms = createSms(i1);
        SmsSet smsSet2 = new SmsSet();
        smsSet2.addSms(sms);
        smsSet.addSmsSet(smsSet2);
    }
    smsSet.getSms(3).setStoringAfterFailure(true);
    smsSet.getSms(5).setStoringAfterFailure(true);
    Date curDate = new Date();
    int year = curDate.getYear();
    smsSet.getSms(1).setStored(true);
    // validity period is too far (more then several days)
    smsSet.getSms(1).setValidityPeriod(new Date(year + 1, 1, 1));
    smsSet.getSms(2).setStored(true);
    smsSet.getSms(2).setValidityPeriod(new Date(year - 1, 1, 1));
    smsSet.getSms(6).setStored(true);
    smsSet.getSms(6).setValidityPeriod(new Date(year - 1, 1, 1));
    smsSet.getSms(7).setStored(true);
    // validity period is not far - 20 min
    smsSet.getSms(7).setValidityPeriod(new Date(curDate.getTime() + 20 * 60 * 1000));
    smsSet.getSms(8).setStored(true);
    // validity period is not far - 10 min
    smsSet.getSms(8).setValidityPeriod(new Date(curDate.getTime() + 10 * 60 * 1000));
    sbb.addInitialMessageSet(smsSet);
    SmsSetCache.getInstance().addProcessingSmsSet(smsSet.getTargetId(), smsSet, 0);
    storeSbb(sbb);
    // 02
    sbb = initiateSbb(sbb);
    loadSbb(sbb);
    int cnt = sbb.obtainNextMessagesSendingPool(5, ProcessingType.SMPP);
    sbb.registerMessageInSendingPool(0, 100, null);
    sbb.registerMessageInSendingPool(1, 101, null);
    sbb.registerMessageInSendingPool(2, 102, null);
    sbb.registerMessageInSendingPool(3, 103, null);
    sbb.registerMessageInSendingPool(4, 104, null);
    sbb.endRegisterMessageInSendingPool();
    assertEquals(sbb.getCurrentMsgNumValue(), 6);
    assertEquals(sbb.getSendingPoolMessageCount(), 5);
    assertEquals(sbb.getTotalUnsentMessageCount(), 19);
    assertEquals(sbb.getUnconfirmedMessageCountInSendingPool(), 5);
    assertEquals(sbb.getMessageInSendingPool(0).getMessageId(), 0);
    assertEquals(sbb.getMessageInSendingPool(1).getMessageId(), 1);
    assertEquals(sbb.getMessageInSendingPool(2).getMessageId(), 3);
    assertEquals(sbb.getMessageInSendingPool(3).getMessageId(), 4);
    assertEquals(sbb.getMessageInSendingPool(4).getMessageId(), 5);
    assertNull(sbb.getMessageInSendingPool(5));
    sbb.confirmMessageInSendingPool(100);
    sbb.confirmMessageInSendingPool(102);
    ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
    ArrayList<Sms> lstTempFailured = new ArrayList<Sms>();
    sbb.createFailureLists(lstPermFailured, lstTempFailured, ErrorAction.temporaryFailure, new Date(curDate.getTime() + 30 * 60 * 1000));
    assertEquals(lstTempFailured.size(), 3);
    assertEquals(lstPermFailured.size(), 14);
    assertEquals(lstTempFailured.get(0).getMessageId(), 1);
    assertEquals(lstTempFailured.get(1).getMessageId(), 5);
    assertEquals(lstTempFailured.get(2).getMessageId(), 7);
    assertEquals(lstPermFailured.get(0).getMessageId(), 4);
    assertEquals(lstPermFailured.get(1).getMessageId(), 6);
    assertEquals(lstPermFailured.get(2).getMessageId(), 8);
    assertEquals(lstPermFailured.get(3).getMessageId(), 9);
    assertEquals(lstPermFailured.get(13).getMessageId(), 19);
}
Also used : Sms(org.mobicents.smsc.library.Sms) ArrayList(java.util.ArrayList) SmsSet(org.mobicents.smsc.library.SmsSet) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 65 with SmsSet

use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.

the class NN_DBOper method getSmsSetForTargetId.

public SmsSet getSmsSetForTargetId(Date[] dtt, NN_LoadedTargetId ti) throws PersistenceException {
    SmsSet smsSet = null;
    for (Date dt : dtt) {
        PreparedStatementCollection2 psc = getStatementCollection(dt);
        ArrayList<UUID> lst2 = new ArrayList<UUID>();
        try {
            PreparedStatement ps = psc.getIdListDests;
            BoundStatement boundStatement = new BoundStatement(ps);
            boundStatement.bind(ti.getTargetId());
            ResultSet res = session.execute(boundStatement);
            for (Row row : res) {
                UUID id = row.getUUID(0);
                boolean sent = row.getBool(1);
                if (!sent)
                    lst2.add(id);
            }
        } catch (Exception e1) {
            String msg = "Failed reading a set of ID from DESTS for targetId " + ti.getTargetId() + " !";
            throw new PersistenceException(msg, e1);
        }
        try {
            for (UUID id : lst2) {
                PreparedStatement ps = psc.getSms;
                BoundStatement boundStatement = new BoundStatement(ps);
                boundStatement.bind(ti.getTargetId(), id);
                ResultSet res = session.execute(boundStatement);
                for (Row row : res) {
                    Sms sms = createSms(row, smsSet);
                    smsSet = sms.getSmsSet();
                }
            }
        } catch (Exception e1) {
            String msg = "Failed reading SmsSet for " + ti.getTargetId() + " !";
            throw new PersistenceException(msg, e1);
        }
    }
    if (smsSet != null)
        smsSet.resortSms();
    else {
        // no message records - removing TARGET_ID from SLOTS
        PreparedStatementCollection2 psc = getStatementCollection(ti.getDtx());
        PreparedStatement ps = psc.deleteRecordSlots;
        BoundStatement boundStatement = new BoundStatement(ps);
        boundStatement.bind(ti.getDueSlot(), ti.getTargetId());
        ResultSet res = session.execute(boundStatement);
    }
    return smsSet;
}
Also used : ArrayList(java.util.ArrayList) PreparedStatement(com.datastax.driver.core.PreparedStatement) Date(java.util.Date) XMLStreamException(javolution.xml.stream.XMLStreamException) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) InvalidQueryException(com.datastax.driver.core.exceptions.InvalidQueryException) ResultSet(com.datastax.driver.core.ResultSet) PersistenceException(org.mobicents.smsc.cassandra.PersistenceException) Sms(org.mobicents.smsc.library.Sms) Row(com.datastax.driver.core.Row) UUID(java.util.UUID) BoundStatement(com.datastax.driver.core.BoundStatement) SmsSet(org.mobicents.smsc.library.SmsSet)

Aggregations

SmsSet (org.mobicents.smsc.library.SmsSet)116 Sms (org.mobicents.smsc.library.Sms)61 Test (org.testng.annotations.Test)45 ArrayList (java.util.ArrayList)36 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)35 Date (java.util.Date)32 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)28 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)28 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)28 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)26 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)25 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)25 UUID (java.util.UUID)23 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)21 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)19 MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)18 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)17 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)17