Search in sources :

Example 1 with AsnInputStream

use of org.mobicents.protocols.asn.AsnInputStream in project smscgateway by RestComm.

the class MoSbbTest method testMo4_Gsm8.

@Test(groups = { "Mo" })
public void testMo4_Gsm8() throws Exception {
    if (!this.cassandraDbInited)
        return;
    // 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(4);
    UserDataHeader decodedUserDataHeader = new UserDataHeaderImpl();
    UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 55, 3, 1);
    decodedUserDataHeader.addInformationElement(informationElement);
    UserData userData = new UserDataImpl("abc 01234567890", dataCodingScheme, decodedUserDataHeader, isoCharset);
    SmsTpdu tpdu = new SmsSubmitTpduImpl(false, false, false, 150, destinationAddress, protocolIdentifier, null, userData);
    // isoCharset
    SmsSignalInfo sm_RP_UI_0 = new SmsSignalInfoImpl(tpdu, null);
    ForwardShortMessageRequestImpl event0 = new ForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI_0, false);
    AsnOutputStream aos = new AsnOutputStream();
    event0.encodeAll(aos);
    ForwardShortMessageRequestImpl event = new ForwardShortMessageRequestImpl();
    AsnInputStream ais = new AsnInputStream(aos.toByteArray());
    ais.readTag();
    event.decodeAll(ais);
    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(), 4);
    assertNull(sms.getOrigEsmeName());
    assertNull(sms.getOrigSystemId());
    assertNull(sms.getServiceType());
    assertEquals(sms.getEsmClass() & 0xFF, 67);
    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);
    assertEquals(sms.getShortMessageText(), "abc 01234567890");
    assertEquals(sms.getShortMessageBin(), decodedUserDataHeader.getEncodedData());
}
Also used : DataCodingScheme(org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserDataHeaderImpl(org.mobicents.protocols.ss7.map.smstpdu.UserDataHeaderImpl) AsnInputStream(org.mobicents.protocols.asn.AsnInputStream) MAPServiceSmsProxy(org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) SmsTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) SmsSignalInfoImpl(org.mobicents.protocols.ss7.map.service.sms.SmsSignalInfoImpl) DataCodingSchemeImpl(org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ProtocolIdentifierImpl(org.mobicents.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) SmsSignalInfo(org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo) UserDataHeaderElement(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeaderElement) UserDataImpl(org.mobicents.protocols.ss7.map.smstpdu.UserDataImpl) MAPProviderProxy(org.mobicents.smsc.slee.resources.persistence.MAPProviderProxy) ProtocolIdentifier(org.mobicents.protocols.ss7.map.api.smstpdu.ProtocolIdentifier) UserDataHeader(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader) ISDNAddressStringImpl(org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) AddressStringImpl(org.mobicents.protocols.ss7.map.primitives.AddressStringImpl) AddressField(org.mobicents.protocols.ss7.map.api.smstpdu.AddressField) ConcatenatedShortMessagesIdentifierImpl(org.mobicents.protocols.ss7.map.smstpdu.ConcatenatedShortMessagesIdentifierImpl) MoForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl) ForwardShortMessageRequestImpl(org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl) SM_RP_DAImpl(org.mobicents.protocols.ss7.map.service.sms.SM_RP_DAImpl) AddressFieldImpl(org.mobicents.protocols.ss7.map.smstpdu.AddressFieldImpl) SM_RP_OAImpl(org.mobicents.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.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl) AsnOutputStream(org.mobicents.protocols.asn.AsnOutputStream) Sms(org.mobicents.smsc.library.Sms) SM_RP_DA(org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA) MAPApplicationContext(org.mobicents.protocols.ss7.map.api.MAPApplicationContext) SmsSet(org.mobicents.smsc.library.SmsSet) SmsSubmitTpduImpl(org.mobicents.protocols.ss7.map.smstpdu.SmsSubmitTpduImpl) Test(org.testng.annotations.Test)

Aggregations

Date (java.util.Date)1 AsnInputStream (org.mobicents.protocols.asn.AsnInputStream)1 AsnOutputStream (org.mobicents.protocols.asn.AsnOutputStream)1 MAPApplicationContext (org.mobicents.protocols.ss7.map.api.MAPApplicationContext)1 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)1 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)1 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)1 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)1 AddressField (org.mobicents.protocols.ss7.map.api.smstpdu.AddressField)1 DataCodingScheme (org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme)1 ProtocolIdentifier (org.mobicents.protocols.ss7.map.api.smstpdu.ProtocolIdentifier)1 SmsTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu)1 UserData (org.mobicents.protocols.ss7.map.api.smstpdu.UserData)1 UserDataHeader (org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader)1 UserDataHeaderElement (org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeaderElement)1 AddressStringImpl (org.mobicents.protocols.ss7.map.primitives.AddressStringImpl)1 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)1 ForwardShortMessageRequestImpl (org.mobicents.protocols.ss7.map.service.sms.ForwardShortMessageRequestImpl)1 MoForwardShortMessageRequestImpl (org.mobicents.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl)1 SM_RP_DAImpl (org.mobicents.protocols.ss7.map.service.sms.SM_RP_DAImpl)1