Search in sources :

Example 46 with ActivityContextInterface

use of javax.slee.ActivityContextInterface in project smscgateway by RestComm.

the class DeliveryCommonSbb method rescheduleDeliveryTimer.

// *********
// Methods for managing of delivery timeout
protected void rescheduleDeliveryTimer(int smsSetSize) {
    this.cancelDeliveryTimer();
    if (this.timerFacility != null) {
        int multiplier = getMaxMessagesPerStep() != null ? Math.min(smsSetSize, getMaxMessagesPerStep()) : smsSetSize;
        int adaptedDeliveryTimeout = smscPropertiesManagement.getDeliveryTimeout() + smscPropertiesManagement.getDeliveryTimeoutDeltaPerMessage() * multiplier;
        long startTime = System.currentTimeMillis() + 1000 * adaptedDeliveryTimeout;
        TimerOptions options = new TimerOptions();
        ActivityContextInterface activity = getSchedulerActivityContextInterface();
        TimerID timer = this.timerFacility.setTimer(activity, null, startTime, options);
        setDeliveryTimerID(timer);
    }
}
Also used : ActivityContextInterface(javax.slee.ActivityContextInterface) TimerID(javax.slee.facilities.TimerID) TimerOptions(javax.slee.facilities.TimerOptions)

Example 47 with ActivityContextInterface

use of javax.slee.ActivityContextInterface in project smscgateway by RestComm.

the class MtCommonSbb method setupReportSMDeliveryStatusRequest.

protected void setupReportSMDeliveryStatusRequest(String destinationAddress, int ton, int npi, SMDeliveryOutcome sMDeliveryOutcome, String targetId, int networkId, String mtLocalSccpGt, Integer mtRemoteSccpTt) {
    RsdsSbbLocalObject rsdsSbbLocalObject = this.getRsdsSbbObject();
    if (rsdsSbbLocalObject != null) {
        ActivityContextInterface schedulerActivityContextInterface = this.getSchedulerActivityContextInterface();
        schedulerActivityContextInterface.attach(rsdsSbbLocalObject);
        SendRsdsEvent event = new SendRsdsEvent();
        event.setMsisdn(this.getCalledPartyISDNAddressString(destinationAddress, ton, npi));
        event.setServiceCentreAddress(getServiceCenterAddressString(networkId));
        event.setSMDeliveryOutcome(sMDeliveryOutcome);
        SccpAddress destinationAddr = this.convertAddressFieldToSCCPAddress(destinationAddress, ton, npi, mtRemoteSccpTt);
        event.setDestAddress(destinationAddr);
        event.setMapApplicationContext(this.getSRIMAPApplicationContext(MAPApplicationContextVersion.getInstance(this.getSriMapVersion())));
        event.setTargetId(targetId);
        event.setNetworkId(networkId);
        event.setMtLocalSccpGt(mtLocalSccpGt);
        this.fireSendRsdsEvent(event, schedulerActivityContextInterface, null);
    }
}
Also used : SccpAddress(org.restcomm.protocols.ss7.sccp.parameter.SccpAddress) ActivityContextInterface(javax.slee.ActivityContextInterface) SendRsdsEvent(org.mobicents.smsc.slee.services.smpp.server.events.SendRsdsEvent)

Example 48 with ActivityContextInterface

use of javax.slee.ActivityContextInterface in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm_BadCodingSchema.

// @Test(groups = { "TxSmppServer" })
// public void testSubmitMulti_BadAddr() 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, -1, -1);
// ActivityContextInterface aci = new SmppTransactionProxy(esme);
// 
// SubmitMulti event = new SubmitMulti();
// Date curDate = new Date();
// this.fillSm(event, curDate, true);
// event.setShortMessage(msgUcs2);
// 
// Address destAddr = new Address();
// destAddr.setAddress("5555");
// destAddr.setTon(SmppConstants.TON_SUBSCRIBER);
// destAddr.setNpi(SmppConstants.NPI_E164);
// event.addDestAddresses(destAddr);
// Address destAddr2 = new Address();
// destAddr2.setAddress("5556");
// destAddr2.setTon(SmppConstants.TON_INTERNATIONAL);
// destAddr2.setNpi(SmppConstants.NPI_E164);
// event.addDestAddresses(destAddr2);
// 
// 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);
// b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
// b2 = this.pers.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
// assertEquals(b1, 0);
// assertEquals(b2, 0L);
// 
// TxSmppServerSbb.smscPropertiesManagement.setSmppEncodingForUCS2(SmppEncoding.Unicode);
// this.sbb.onSubmitMulti(event, aci);
// 
// b1 = this.pers.checkSmsExists(dueSlot, ta1.getTargetId());
// assertEquals(b1, 0);
// b1 = this.pers.checkSmsExists(dueSlot, ta2.getTargetId());
// assertEquals(b1, 1);
// 
// SubmitMultiResp resp = (SubmitMultiResp)this.smppSess.getRespList().get(0);
// assertEquals(resp.getCommandStatus(), 0);
// assertEquals(resp.getOptionalParameterCount(), 0);
// assertEquals(resp.getUnsucessfulSmes().size(), 1);
// assertEquals(resp.getUnsucessfulSmes().get(0).getAddress().getAddress(), "5555");
// }
@Test(groups = { "TxSmppServer" })
public void testSubmitSm_BadCodingSchema() 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(msgUtf8);
    DataCodingSchemeImpl dcss = new DataCodingSchemeImpl(DataCodingGroup.GeneralGroup, null, null, null, CharacterSet.GSM7, true);
    // DataCodingGroup dataCodingGroup, DataCodingSchemaMessageClass
    // messageClass,
    // DataCodingSchemaIndicationType dataCodingSchemaIndicationType,
    // Boolean setIndicationActive,
    // CharacterSet characterSet, boolean isCompressed
    event.setDataCoding((byte) 12);
    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.Utf8);
    this.sbb.onSubmitSm(event, aci);
    b2 = this.pers.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
    assertEquals(b2, 0);
    assertEquals(this.smppSess.getReqList().size(), 0);
    assertEquals(this.smppSess.getRespList().size(), 1);
    PduResponse resp = this.smppSess.getRespList().get(0);
    assertEquals(resp.getCommandStatus(), 260);
    assertEquals(resp.getOptionalParameterCount(), 1);
    Tlv tlvr = resp.getOptionalParameter(SmppConstants.TAG_ADD_STATUS_INFO);
    String errMsg = tlvr.getValueAsString();
    assertEquals(errMsg, "TxSmpp DataCoding scheme does not supported: 12 - Only GSM7, GSM8 and USC2 are supported");
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) Esme(org.restcomm.smpp.Esme) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) Tlv(com.cloudhopper.smpp.tlv.Tlv) Test(org.testng.annotations.Test)

Example 49 with ActivityContextInterface

use of javax.slee.ActivityContextInterface in project smscgateway by RestComm.

the class TxSmppServerSbbTest method testSubmitSm.

@Test(groups = { "TxSmppServer" })
public void testSubmitSm() 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(msgUcs2);
    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);
    // msgUcs2
    assertEquals(sms.getShortMessageText(), sMsg);
    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);
}
Also used : PduResponse(com.cloudhopper.smpp.pdu.PduResponse) ActivityContextInterface(javax.slee.ActivityContextInterface) SubmitSm(com.cloudhopper.smpp.pdu.SubmitSm) Esme(org.restcomm.smpp.Esme) Sms(org.mobicents.smsc.library.Sms) SmppSessionsProxy(org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 50 with ActivityContextInterface

use of javax.slee.ActivityContextInterface in project smscgateway by RestComm.

the class TxHttpServerSbbTest method sendMessagePOSTStringSuccessTest.

@Test
public void sendMessagePOSTStringSuccessTest() {
    System.out.println("sendMessagePOSTStringSuccessTest");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildSendMessageRequest(METHOD_POST, URL_SEND_MESSAGE, USER_DEFAULT, PASSWORD_DEFAULT, MESSAGE_DEFAULT, FORMAT_STRING, ENCODING_GSM7, BODY_ENCODING_UTF8, SENDER_ID_DEFAULT, SENDER_TON_DEFAULT, SENDER_NPI_DEFAULT, TO_ONE);
    event.setRequest(request);
    MockHttpServletResponse response = new MockHttpServletResponse();
    event.setResponse(response);
    // perform the action
    this.sbb.onHttpPost(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertTrue(isValid(resp, FORMAT_STRING, true, 1), "Response is not valid");
}
Also used : ActivityContextInterface(javax.slee.ActivityContextInterface) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.testng.annotations.Test)

Aggregations

ActivityContextInterface (javax.slee.ActivityContextInterface)67 Test (org.testng.annotations.Test)45 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)33 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)33 SmsSet (org.mobicents.smsc.library.SmsSet)11 Date (java.util.Date)9 Esme (org.restcomm.smpp.Esme)9 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)8 SmppSessionsProxy (org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy)8 Sms (org.mobicents.smsc.library.Sms)7 SubmitSm (com.cloudhopper.smpp.pdu.SubmitSm)6 ArrayList (java.util.ArrayList)6 PduResponse (com.cloudhopper.smpp.pdu.PduResponse)5 DeliverSmResp (com.cloudhopper.smpp.pdu.DeliverSmResp)4 EventContext (javax.slee.EventContext)4 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)4 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)4 MAPException (org.restcomm.protocols.ss7.map.api.MAPException)4 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)4 Tlv (com.cloudhopper.smpp.tlv.Tlv)3