use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testUSim.
@Test(groups = { "TxSmppServer" })
public void testUSim() 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.setDataCoding((byte) 246);
event.setEsmClass((byte) 0x43);
event.setShortMessage(msgUSim);
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);
// 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);
}
use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy 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.slee.resources.persistence.SmppSessionsProxy 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.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testSubmitSm_createSmsEvent.
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_createSmsEvent() throws Exception {
if (!this.cassandraDbInited)
return;
this.smppSess = new SmppSessionsProxy();
this.sbb.setSmppServerSessions(smppSess);
TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Utf8);
SmscPropertiesManagement spm = SmscPropertiesManagement.getInstance("Test");
String sMsgA = "������Hel";
// only message part
Charset utf8 = Charset.forName("UTF-8");
ByteBuffer bb = utf8.encode(sMsgA);
byte[] aMsgA = new byte[bb.limit()];
bb.get(aMsgA);
Charset ucs2 = Charset.forName("UTF-16BE");
bb = ucs2.encode(sMsgA);
byte[] aMsgAA = new byte[bb.limit()];
bb.get(aMsgAA);
com.cloudhopper.smpp.pdu.SubmitSm event = new com.cloudhopper.smpp.pdu.SubmitSm();
Address addr = new Address();
addr.setNpi((byte) 1);
addr.setTon((byte) 1);
addr.setAddress("2222");
event.setSourceAddress(addr);
Address addr2 = new Address();
addr2.setNpi((byte) 1);
addr2.setTon((byte) 1);
addr2.setAddress("5555");
event.setDestAddress(addr2);
event.setDataCoding((byte) 8);
event.setShortMessage(aMsgA);
Esme origEsme = new Esme();
TargetAddress ta = ta1;
Sms sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), sMsgA);
// message part and UDH
byte[] udh = new byte[] { 0x05, 0x00, 0x03, 0x29, 0x02, 0x02 };
byte[] aMsgB = new byte[aMsgA.length + udh.length];
System.arraycopy(udh, 0, aMsgB, 0, udh.length);
System.arraycopy(aMsgA, 0, aMsgB, udh.length, aMsgA.length);
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 8);
event.setShortMessage(aMsgB);
event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), sMsgA);
assertEquals(sms.getShortMessageBin(), udh);
// binary GSM8
String s1 = "Optic xxx";
Charset iso = Charset.forName("ISO-8859-1");
byte[] aMsgC = s1.getBytes(iso);
byte[] aMsgCC = new byte[aMsgC.length + udh.length];
System.arraycopy(udh, 0, aMsgCC, 0, udh.length);
System.arraycopy(aMsgC, 0, aMsgCC, udh.length, aMsgC.length);
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 4);
event.setShortMessage(aMsgCC);
event.setEsmClass(SmppConstants.ESM_CLASS_UDHI_MASK);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), s1);
assertEquals(sms.getShortMessageBin(), udh);
// GSM7
event = new com.cloudhopper.smpp.pdu.SubmitSm();
event.setSourceAddress(addr);
event.setDestAddress(addr2);
event.setDataCoding((byte) 0);
event.setShortMessage(aMsgC);
sms = this.sbb.createSmsEvent(event, origEsme, ta, this.pers);
assertEquals(sms.getShortMessageText(), s1);
assertNull(sms.getShortMessageBin());
}
use of org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy in project smscgateway by RestComm.
the class TxSmppServerSbbTest method testUcs2Udh.
@Test(groups = { "TxSmppServer" })
public void testUcs2Udh() 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.setDataCoding((byte) 8);
event.setEsmClass((byte) 0x40);
event.setShortMessage(msgUcs2Udh);
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);
// 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);
}
Aggregations