use of org.restcomm.protocols.ss7.map.primitives.AddressStringImpl in project smscgateway by RestComm.
the class MoSbbTest method testMo3_Usc2.
@Test(groups = { "Mo" })
public void testMo3_Usc2() throws Exception {
if (!this.cassandraDbInited)
return;
// this.clearDatabase();
// 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(8);
UserData userData = new UserDataImpl(new String("������"), dataCodingScheme, null, null);
// String decodedMessage, DataCodingScheme dataCodingScheme, UserDataHeader decodedUserDataHeader, Charset gsm8Charset
SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
// boolean rejectDuplicates, boolean replyPathExists, boolean statusReportRequest, int messageReference,
// AddressField destinationAddress, ProtocolIdentifier protocolIdentifier, ValidityPeriod validityPeriod, UserData userData
// tpdu.encodeData();
SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(tpdu, null);
ForwardShortMessageRequest event = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, false);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msg);
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(), 8);
assertNull(sms.getOrigEsmeName());
assertNull(sms.getOrigSystemId());
assertNull(sms.getServiceType());
assertEquals(sms.getEsmClass() & 0xFF, 3);
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);
// assertDateEq(smsSet.getDueDate(), new Date(curDate.getTime() + 1 * 60 * 1000));
// Charset ucs2Charset = Charset.forName("UTF-16BE");
// ByteBuffer bb = ByteBuffer.wrap(sms.getShortMessage());
// CharBuffer bf = ucs2Charset.decode(bb);
// String s = bf.toString();
// assertEquals(s, "������");
assertEquals(sms.getShortMessageText(), "������");
assertNull(sms.getShortMessageBin());
}
use of org.restcomm.protocols.ss7.map.primitives.AddressStringImpl in project smscgateway by RestComm.
the class AlertTest method testAlert1_Gsm1.
@Test(groups = { "Alert" })
public void testAlert1_Gsm1() throws Exception {
if (!this.cassandraDbInited)
return;
this.prepareDatabase();
SmsSet smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
assertNull(smsSetX);
Sms smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId);
assertEquals(smsX.getSmsSet().getInSystem(), 0);
// boolean b1 = this.pers.checkSmsSetExists(ta1);
// assertTrue(b1);
// SmsSet smsSet = this.pers.obtainSmsSet(ta1);
// assertEquals(smsSet.getInSystem(), 1);
// assertEquals(smsSet.getDueDate(), farDate);
Thread.sleep(1000);
Date curDate = new Date();
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "5555");
AddressString serviceCentreAddress = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1111");
AlertServiceCentreRequest evt = new AlertServiceCentreRequestImpl(msisdn, serviceCentreAddress);
MAPProviderProxy proxy = new MAPProviderProxy();
MAPApplicationContext appCntx = MAPApplicationContext.getInstance(MAPApplicationContextName.shortMsgAlertContext, MAPApplicationContextVersion.version2);
MAPDialogSmsProxy dialog = new MAPDialogSmsProxy(new MAPServiceSmsProxy(proxy), appCntx, null, null);
evt.setMAPDialog(dialog);
this.sbb.onAlertServiceCentreRequest(evt, null);
smsSetX = SmsSetCache.getInstance().getProcessingSmsSet(procTargetId);
// assertNotNull(smsSetX); TODO: this will work after alert is with direct Activities sending
smsX = this.pers.obtainLiveSms(procDueSlot, procTargetId, procId);
// assertNull(smsX);
// b1 = this.pers.checkSmsSetExists(ta1);
// assertTrue(b1);
// smsSet = this.pers.obtainSmsSet(ta1);
// assertEquals(smsSet.getInSystem(), 1);
// this.testDateEq(smsSet.getDueDate(), curDate);
}
use of org.restcomm.protocols.ss7.map.primitives.AddressStringImpl in project smscgateway by RestComm.
the class SmsSetCacheTest method testSmppShellExecutor.
@Test(groups = { "SmsSet" })
public void testSmppShellExecutor() throws Exception {
int correlationIdLiveTime = 2;
int sriResponseLiveTime = 3;
int deliveredMsgLiveTime = 3;
SmsSetCache.start(correlationIdLiveTime, sriResponseLiveTime, deliveredMsgLiveTime);
SmsSetCache ssc = SmsSetCache.getInstance();
String remoteMessageId = "0000100001";
String destId = "esme_33";
Long messageId = 3000031L;
String correlationID = "000000000011111";
ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111");
AddressString serviceCentreAddress = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222");
CorrelationIdValue elem = new CorrelationIdValue(correlationID, msisdn, serviceCentreAddress, 0, null);
ssc.putCorrelationIdCacheElement(elem, correlationIdLiveTime);
Sms sms = new Sms();
long mId = 222L;
sms.setMessageId(mId);
sms.setShortMessageText("textxxx");
ssc.putDeliveredMsgValue(sms, deliveredMsgLiveTime);
ssc.putDeliveredRemoteMsgIdValue(remoteMessageId, destId, messageId, deliveredMsgLiveTime);
String targetID = "22222_1_1_2";
LocationInfoWithLMSI locationInfoWithLMSI = null;
SriResponseValue srv = new SriResponseValue(targetID, 2, "22222", 1, 1, locationInfoWithLMSI, "0000011111000000");
ssc.putSriResponseValue(srv, sriResponseLiveTime);
Thread.sleep(2500);
CorrelationIdValue v1 = ssc.getCorrelationIdCacheElement(correlationID);
assertNotNull(v1);
SriResponseValue vv1 = ssc.getSriResponseValue(targetID);
assertNotNull(vv1);
Sms sms2 = ssc.getDeliveredMsgValue(mId);
assertNotNull(sms2);
Long msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertEquals((long) msgId2, (long) messageId);
Thread.sleep(2500);
CorrelationIdValue v2 = ssc.getCorrelationIdCacheElement(correlationID);
assertNull(v2);
SriResponseValue vv2 = ssc.getSriResponseValue(targetID);
assertNotNull(vv2);
sms2 = ssc.getDeliveredMsgValue(mId);
assertNotNull(sms2);
msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertEquals((long) msgId2, (long) messageId);
Thread.sleep(2000);
CorrelationIdValue v3 = ssc.getCorrelationIdCacheElement(correlationID);
assertNull(v3);
SriResponseValue vv3 = ssc.getSriResponseValue(targetID);
assertNull(vv3);
sms2 = ssc.getDeliveredMsgValue(mId);
assertNull(sms2);
msgId2 = ssc.getDeliveredRemoteMsgIdValue(remoteMessageId, destId);
assertNull(msgId2);
SmsSetCache.stop();
}
Aggregations