Search in sources :

Example 26 with ActivityContextInterface

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

the class TxHttpServerSbbTest method sendMessageGETJsonSuccessTest.

@Test
public void sendMessageGETJsonSuccessTest() {
    System.out.println("sendMessageGETJsonSuccessTest");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildSendMessageRequest(METHOD_GET, URL_SEND_MESSAGE, USER_DEFAULT, PASSWORD_DEFAULT, MESSAGE_DEFAULT, FORMAT_JSON, 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.onHttpGet(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertTrue(isValid(resp, FORMAT_JSON, 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)

Example 27 with ActivityContextInterface

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

the class TxHttpServerSbbTest method getStatusGETJsonSuccessTest.

@Test
public void getStatusGETJsonSuccessTest() {
    System.out.println("getStatusGETJsonSuccessTest");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildGetMessageIdStatusRequest(METHOD_GET, URL_GET_MESSAGE_ID_STATUS, USER_DEFAULT, PASSWORD_DEFAULT, MESSAGE_ID, FORMAT_JSON);
    event.setRequest(request);
    MockHttpServletResponse response = new MockHttpServletResponse();
    event.setResponse(response);
    // perform the action
    this.sbb.onHttpGet(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertTrue(isValid(resp, FORMAT_JSON, true), "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)

Example 28 with ActivityContextInterface

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

the class TxHttpServerSbbTest method sendMessageGETStringErrorTest.

@Test
public void sendMessageGETStringErrorTest() throws UnsupportedEncodingException {
    System.out.println("sendMessageGETStringErrorTest");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildSendMessageRequest(METHOD_GET, URL_SEND_MESSAGE, null, PASSWORD_DEFAULT, URLEncoder.encode(MESSAGE_DEFAULT, "UTF-8"), FORMAT_STRING, ENCODING_UCS2, 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.onHttpGet(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertEquals(resp.getStatus(), HttpServletResponse.SC_UNAUTHORIZED);
}
Also used : ActivityContextInterface(javax.slee.ActivityContextInterface) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.testng.annotations.Test)

Example 29 with ActivityContextInterface

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

the class TxHttpServerSbbTest method sendMessageGETForbiddenTest.

@Test
public void sendMessageGETForbiddenTest() throws UnsupportedEncodingException {
    System.out.println("sendMessageGETForbiddenTest");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildSendMessageRequest(METHOD_GET, URL_SEND_MESSAGE, USER_DEFAULT, PASSWORD_DEFAULT, URLEncoder.encode(MESSAGE_DEFAULT, "UTF-8"), FORMAT_STRING, ENCODING_UCS2, 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.setForbidden(true);
    this.sbb.onHttpGet(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertFalse(isValid(resp, FORMAT_STRING, false), "Response is not valid");
    this.sbb.setForbidden(false);
}
Also used : ActivityContextInterface(javax.slee.ActivityContextInterface) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.testng.annotations.Test)

Example 30 with ActivityContextInterface

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

the class TxHttpServerSbbTest method multiplePlusEmptyToAddressTest_GET.

@Test
public void multiplePlusEmptyToAddressTest_GET() {
    System.out.println("multiplePlusEmptyToAddressTest_GET");
    if (!this.cassandraDbInited) {
        // Assert.fail("Cassandra DB is not inited");
        return;
    }
    // prepare
    ActivityContextInterface aci = new HttpActivityContextInterface();
    MockHttpServletRequestEvent event = new MockHttpServletRequestEvent();
    MockHttpServletRequest request = buildSendMessageRequest(METHOD_GET, URL_SEND_MESSAGE, USER_DEFAULT, PASSWORD_DEFAULT, MESSAGE_DEFAULT, FORMAT_JSON, ENCODING_UCS2, BODY_ENCODING_UTF8, SENDER_ID_DEFAULT, SENDER_TON_DEFAULT, SENDER_NPI_DEFAULT, TO_MULTIPLE_PLUS_EMPTY);
    event.setRequest(request);
    MockHttpServletResponse response = new MockHttpServletResponse();
    event.setResponse(response);
    // perform the action
    this.sbb.onHttpGet(event, aci);
    MockHttpServletResponse resp = (MockHttpServletResponse) event.getResponse();
    printResponseData(resp);
    Assert.assertTrue(isValid(resp, FORMAT_JSON, true, 3), "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