use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testDataSm.
@Test(groups = { "TxSmppServer" })
public void testDataSm() 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);
DataSm event = new DataSm();
Date curDate = new Date();
this.fillSm(event, curDate, false);
Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, msgUtf8);
event.addOptionalParameter(tlv);
tlv = new Tlv(SmppConstants.TAG_SAR_MSG_REF_NUM, msg_ref_num);
event.addOptionalParameter(tlv);
tlv = new Tlv(SmppConstants.TAG_SAR_SEGMENT_SEQNUM, new byte[] { 1 });
event.addOptionalParameter(tlv);
tlv = new Tlv(SmppConstants.TAG_SAR_TOTAL_SEGMENTS, new byte[] { 2 });
event.addOptionalParameter(tlv);
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);
TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Utf8);
this.sbb.onDataSm(event, aci);
b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
dueSlot = b2;
b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
assertEquals(b1, 1);
assertEquals(b2, dueSlot);
SmsSet smsSet = this.pers.c2_getRecordListForTargeId(dueSlot, ta1.getTargetId());
this.checkSmsSet(smsSet, curDate, false);
Sms sms = smsSet.getSms(0);
// msgUcs2
assertEquals(sms.getShortMessageText(), sMsg);
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);
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testSubmitSm_Gsm7Enc.
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_Gsm7Enc() 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(msgGsm7);
event.setDataCoding((byte) 0);
event.setEsmClass((byte) 3);
// byte[] bbb = new byte[25500];
// bbb[0] = 6;
// bbb[1] = 36;
// bbb[2] = 1;
// bbb[3] = 13;
// bbb[4] = 37;
// bbb[5] = 1;
// bbb[6] = 13;
// for (int i = 7; i < 25500; i++) {
// bbb[i] = 0x41;
// }
// event.setShortMessage(null);
// Tlv tlv = new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, bbb);
// event.addOptionalParameter(tlv);
// TxSmppServerSbb.smscPropertiesManagement.setNationalLanguageLockingShift(13);
// TxSmppServerSbb.smscPropertiesManagement.setNationalLanguageSingleShift(13);
// event.setEsmClass((byte) 67);
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.setSmppEncodingForGsm7(SmppEncoding.Gsm7);
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);
// msgGsm7
assertEquals(sms.getShortMessageText(), sMsg_4);
assertNull(sms.getShortMessageBin());
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);
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class DBOperations method c2_getRecordListForTargeId.
public SmsSet c2_getRecordListForTargeId(long dueSlot, String targetId) throws PersistenceException {
PreparedStatementCollection psc = getStatementCollection(dueSlot);
SmsSet result = null;
try {
PreparedStatement ps = psc.getRecordData2;
BoundStatement boundStatement = new BoundStatement(ps);
boundStatement.bind(dueSlot, targetId);
ResultSet res = session.execute(boundStatement);
for (Row row : res) {
result = this.createSms(row, result, psc.getShortMessageNewStringFormat(), psc.getAddedCorrId(), psc.getAddedNetworkId(), psc.getAddedOrigNetworkId(), psc.getAddedPacket1(), false);
}
} catch (Exception e1) {
String msg = "Failed getRecordListForTargeId()";
throw new PersistenceException(msg, e1);
}
return result;
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class DBOperations method c2_sortRecordList.
public ArrayList<SmsSet> c2_sortRecordList(ArrayList<SmsSet> sourceLst) {
FastMap<String, SmsSet> res = new FastMap<String, SmsSet>();
// aggregating messages for one targetId
for (SmsSet smsSet : sourceLst) {
SmsSet smsSet2 = null;
try {
smsSet2 = res.get(smsSet.getTargetId());
} catch (Throwable e) {
int dd = 0;
}
if (smsSet2 != null) {
smsSet2.addSms(smsSet.getSms(0));
if (smsSet2.getCorrelationId() == null) {
// filling correcationId if not all SmsSet are filled
smsSet2.setCorrelationId(smsSet.getCorrelationId());
}
} else {
res.put(smsSet.getTargetId(), smsSet);
}
}
// adding into SmsSetCashe
ArrayList<SmsSet> res2 = new ArrayList<SmsSet>();
// 60 min timeout
Date timeOutDate = new Date(new Date().getTime() - 1000 * 60 * 30);
for (SmsSet smsSet : res.values()) {
smsSet.resortSms();
TargetAddress lock = SmsSetCache.getInstance().addSmsSet(new TargetAddress(smsSet));
try {
SmsSet smsSet2;
synchronized (lock) {
smsSet2 = SmsSetCache.getInstance().getProcessingSmsSet(smsSet.getTargetId());
if (smsSet2 != null) {
if (smsSet2.getLastUpdateTime().after(timeOutDate)) {
smsSet2.addSmsSet(smsSet);
// for (int i1 = 0; i1 < smsSet.getSmsCount(); i1++) {
// Sms smsx = smsSet.getSms(i1);
// if (!smsSet2.checkSmsPresent(smsx)) {
// smsSet2.addSmsSet(smsx);
// }
// }
} else {
logger.warn("Timeout of SmsSet in ProcessingSmsSet: targetId=" + smsSet2.getTargetId() + ", messageCount=" + smsSet2.getSmsCount());
smsSet2 = smsSet;
SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout);
}
} else {
smsSet2 = smsSet;
SmsSetCache.getInstance().addProcessingSmsSet(smsSet2.getTargetId(), smsSet2, processingSmsSetTimeout);
}
}
res2.add(smsSet2);
} finally {
SmsSetCache.getInstance().removeSmsSet(lock);
}
}
return res2;
}
use of org.mobicents.smsc.library.SmsSet in project smscgateway by RestComm.
the class DBOperations method c2_getRecordArchiveForMessageId.
public Sms c2_getRecordArchiveForMessageId(long messageId) throws PersistenceException {
Sms sms = SmsSetCache.getInstance().getDeliveredMsgValue(messageId);
if (sms != null)
return sms;
SmsSet result = null;
try {
// first step - today search
Date date = new Date();
PreparedStatementCollection psc = getStatementCollection(date);
result = this.doGetArchiveMsg(messageId, psc);
if (result == null) {
// second step - yesterday search
Date date2 = new Date(date.getTime() - 1000 * 3600 * 24);
psc = getStatementCollection(date2);
result = this.doGetArchiveMsg(messageId, psc);
}
} catch (Exception e1) {
String msg = "Failed getRecordArchiveForMessageId()";
throw new PersistenceException(msg, e1);
}
if (result != null)
return result.getSms(0);
else
return null;
}
Aggregations