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");
}
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");
}
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);
}
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);
}
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");
}
Aggregations