Search in sources :

Example 16 with PreparedStatementCollection

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

the class CassandraTest method createTestSms.

private Sms createTestSms(int num, String number, UUID id) throws Exception {
    PreparedStatementCollection psc = sbb.getStatementCollection(new Date());
    SmsSet smsSet = new SmsSet();
    smsSet.setDestAddr(number);
    smsSet.setDestAddrNpi(1);
    smsSet.setDestAddrTon(5);
    smsSet.setNetworkId(9);
    if (num == 1)
        smsSet.setCorrelationId("CI=100001000022222");
    Sms sms = new Sms();
    // sms.setSmsSet(smsSet);
    smsSet.addSms(sms);
    // sms.setDbId(UUID.randomUUID());
    sms.setDbId(id);
    sms.setSourceAddr("11112_" + num);
    sms.setSourceAddrTon(14 + num);
    sms.setSourceAddrNpi(11 + num);
    sms.setMessageId(8888888 + num);
    sms.setMoMessageRef(102 + num);
    sms.setOrigNetworkId(49);
    sms.setOrigEsmeName("esme_" + num);
    sms.setOrigSystemId("sys_" + num);
    sms.setSubmitDate(new GregorianCalendar(2013, 1, 15, 12, 00 + num).getTime());
    sms.setDeliveryDate(new GregorianCalendar(2013, 1, 15, 12, 15 + num).getTime());
    sms.setServiceType("serv_type__" + num);
    sms.setEsmClass(11 + num);
    sms.setProtocolId(12 + num);
    sms.setPriority(13 + num);
    sms.setRegisteredDelivery(14 + num);
    sms.setReplaceIfPresent(15 + num);
    sms.setDataCoding(16 + num);
    sms.setDefaultMsgId(17 + num);
    // sms.setShortMessage(new byte[] { (byte)(21 + num), 23, 25, 27, 29 });
    if (num != 2)
        sms.setShortMessageText("Mes text" + num);
    if (num != 3)
        sms.setShortMessageBin(new byte[] { (byte) (21 + num), 23, 25, 27, 29 });
    sms.setScheduleDeliveryTime(new GregorianCalendar(2013, 1, 20, 10, 00 + num).getTime());
    sms.setValidityPeriod(new GregorianCalendar(2013, 1, 23, 13, 33 + num).getTime());
    // short tag, byte[] value, String tagName
    Tlv tlv = new Tlv((short) 5, new byte[] { (byte) (1 + num), 2, 3, 4, 5 });
    sms.getTlvSet().addOptionalParameter(tlv);
    tlv = new Tlv((short) 6, new byte[] { (byte) (6 + num), 7, 8 });
    sms.getTlvSet().addOptionalParameter(tlv);
    smsSet.setDueDelay(510);
    sms.setDeliveryCount(9);
    sms.setOriginatorSccpAddress("11224455");
    sms.setStatusReportRequest(true);
    sms.setDeliveryAttempt(321);
    sms.setUserData("userdata");
    sms.setMprocNotes("mproc notes xxx");
    // sms.setExtraData("extradata_1");
    sms.setExtraData_2("extradata_2");
    sms.setExtraData_3("extradata_3");
    sms.setExtraData_4("extradata_4");
    return sms;
}
Also used : Sms(org.mobicents.smsc.library.Sms) GregorianCalendar(java.util.GregorianCalendar) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) Date(java.util.Date) SmsSet(org.mobicents.smsc.library.SmsSet) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 17 with PreparedStatementCollection

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

the class CassandraTest method addingNewMessages2.

public void addingNewMessages2(long dueSlot) throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    // adding an extra messages for "1111"
    TargetAddress lock = this.sbb.obtainSynchroObject(ta1);
    try {
        synchronized (lock) {
            Sms sms_a5 = this.createTestSms(5, ta1.getAddr(), id5);
            sms_a5.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms_a5);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } 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)

Example 18 with PreparedStatementCollection

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

the class CassandraTest method addingNewMessages.

public long addingNewMessages() throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    // adding 3 messages for "1111"
    TargetAddress lock = this.sbb.obtainSynchroObject(ta1);
    long dueSlot;
    try {
        synchronized (lock) {
            Sms sms_a1 = this.createTestSms(1, ta1.getAddr(), id1);
            Sms sms_a2 = this.createTestSms(2, ta1.getAddr(), id2);
            Sms sms_a3 = this.createTestSms(3, ta1.getAddr(), id3);
            dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
            if (dueSlot == 0 || dueSlot <= sbb.c2_getCurrentDueSlot()) {
                dueSlot = sbb.c2_getDueSlotForNewSms();
                sbb.c2_updateDueSlotForTargetId(ta1.getTargetId(), dueSlot);
            }
            sms_a1.setDueSlot(dueSlot);
            sms_a2.setDueSlot(dueSlot);
            sms_a3.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms_a1);
                sbb.c2_createRecordCurrent(sms_a2);
                sbb.c2_createRecordCurrent(sms_a3);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    // adding a messages for "1112"
    lock = this.sbb.obtainSynchroObject(ta2);
    try {
        synchronized (lock) {
            Sms sms_a1 = this.createTestSms(4, ta2.getAddr(), id4);
            sbb.c2_updateDueSlotForTargetId(ta2.getTargetId(), dueSlot);
            sms_a1.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms_a1);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    return dueSlot;
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection)

Example 19 with PreparedStatementCollection

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

the class CassandraTest method testingTableDeleting.

@Test(groups = { "cassandra" })
public void testingTableDeleting() throws Exception {
    if (!this.cassandraDbInited)
        return;
    Date dt0 = new Date();
    Date dt = new Date(dt0.getTime() - 3 * 24 * 3600 * 1000);
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    long newDueSlot = sbb.c2_getDueSlotForTime(dt);
    sbb.c2_updateDueSlotForTargetId("222222_1_11", newDueSlot);
    sbb.c2_deleteLiveTablesForDate(dt);
    // dt = new Date(114, 3, 16);
    sbb.c2_deleteArchiveTablesForDate(dt);
}
Also used : Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) Test(org.testng.annotations.Test)

Example 20 with PreparedStatementCollection

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

the class CassandraTest method readAlertMessage.

public void readAlertMessage() throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    // reading "1112" for Alert
    TargetAddress lock = this.sbb.obtainSynchroObject(ta2);
    try {
        synchronized (lock) {
            long dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
            if (dueSlot == 0) {
                fail("Bad dueSlot for reading of ta2");
            }
            sbb.c2_registerDueSlotWriting(dueSlot);
            SmsSet smsSet;
            try {
                smsSet = sbb.c2_getRecordListForTargeId(dueSlot, ta2.getTargetId());
                ArrayList<SmsSet> lst0 = new ArrayList<SmsSet>();
                lst0.add(smsSet);
                ArrayList<SmsSet> lst = sbb.c2_sortRecordList(lst0);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
            assertEquals(smsSet.getSmsCount(), 1);
            Sms sms = smsSet.getSms(0);
            assertEquals(sms.getDueSlot(), dueSlot);
            this.checkTestSms(4, sms, id4, false);
            sbb.c2_updateInSystem(sms, DBOperations.IN_SYSTEM_INPROCESS, false);
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
}
Also used : ArrayList(java.util.ArrayList) 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)

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