Search in sources :

Example 6 with AddressStringImpl

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());
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) SmsTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsTpdu) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) SmsSignalInfoImpl(org.restcomm.protocols.ss7.map.service.sms.SmsSignalInfoImpl) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ProtocolIdentifierImpl(org.restcomm.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) SmsSignalInfo(org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo) UserDataImpl(org.restcomm.protocols.ss7.map.smstpdu.UserDataImpl) MAPProviderProxy(org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy) ProtocolIdentifier(org.restcomm.protocols.ss7.map.api.smstpdu.ProtocolIdentifier) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) AddressStringImpl(org.restcomm.protocols.ss7.map.primitives.AddressStringImpl) AddressField(org.restcomm.protocols.ss7.map.api.smstpdu.AddressField) ForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) MoForwardShortMessageRequestImpl(org.restcomm.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl) SM_RP_DAImpl(org.restcomm.protocols.ss7.map.service.sms.SM_RP_DAImpl) AddressFieldImpl(org.restcomm.protocols.ss7.map.smstpdu.AddressFieldImpl) ForwardShortMessageRequest(org.restcomm.protocols.ss7.map.api.service.sms.ForwardShortMessageRequest) MoForwardShortMessageRequest(org.restcomm.protocols.ss7.map.api.service.sms.MoForwardShortMessageRequest) SM_RP_OAImpl(org.restcomm.protocols.ss7.map.service.sms.SM_RP_OAImpl) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) Sms(org.mobicents.smsc.library.Sms) SM_RP_DA(org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA) MAPApplicationContext(org.restcomm.protocols.ss7.map.api.MAPApplicationContext) SmsSet(org.mobicents.smsc.library.SmsSet) SmsSubmitTpduImpl(org.restcomm.protocols.ss7.map.smstpdu.SmsSubmitTpduImpl) Test(org.testng.annotations.Test)

Example 7 with AddressStringImpl

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);
}
Also used : AlertServiceCentreRequestImpl(org.restcomm.protocols.ss7.map.service.sms.AlertServiceCentreRequestImpl) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) Date(java.util.Date) MAPDialogSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) MAPProviderProxy(org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy) Sms(org.mobicents.smsc.library.Sms) AlertServiceCentreRequest(org.restcomm.protocols.ss7.map.api.service.sms.AlertServiceCentreRequest) SmsSet(org.mobicents.smsc.library.SmsSet) MAPApplicationContext(org.restcomm.protocols.ss7.map.api.MAPApplicationContext) AddressStringImpl(org.restcomm.protocols.ss7.map.primitives.AddressStringImpl) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) Test(org.testng.annotations.Test)

Example 8 with AddressStringImpl

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();
}
Also used : LocationInfoWithLMSI(org.restcomm.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) AddressStringImpl(org.restcomm.protocols.ss7.map.primitives.AddressStringImpl) ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)8 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)7 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)7 AddressStringImpl (org.restcomm.protocols.ss7.map.primitives.AddressStringImpl)7 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)7 Date (java.util.Date)6 Sms (org.mobicents.smsc.library.Sms)6 SmsSet (org.mobicents.smsc.library.SmsSet)6 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)6 MAPProviderProxy (org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy)6 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)6 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)5 MAPApplicationContext (org.restcomm.protocols.ss7.map.api.MAPApplicationContext)5 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)5 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)5 AddressField (org.restcomm.protocols.ss7.map.api.smstpdu.AddressField)5 DataCodingScheme (org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme)5 ProtocolIdentifier (org.restcomm.protocols.ss7.map.api.smstpdu.ProtocolIdentifier)5 SmsTpdu (org.restcomm.protocols.ss7.map.api.smstpdu.SmsTpdu)5 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)5