Search in sources :

Example 6 with HttpApiException

use of org.mobicents.smsc.slee.services.http.server.tx.exceptions.HttpApiException in project smscgateway by RestComm.

the class HttpRequestUtilsTest method testExtractParametersFromPost.

/**
 * Test extract parameters from post.
 */
@Test
public void testExtractParametersFromPost() {
    LOG.info("Starting test: testExtractParametersFromPost.");
    try {
        final Map<String, String[]> result01 = convert(HTTP_POST_BODY_O1);
        assertNotNull(result01);
        assertEquals(result01.size(), 0);
        final Map<String, String[]> result02 = convert(HTTP_POST_BODY_O2);
        assertNotNull(result02);
        assertEquals(result02.size(), 0);
        final Map<String, String[]> result03 = convert(HTTP_POST_BODY_ARABIC_OK_DATA_FILE_BYTES, new FileInputStream(HTTP_POST_BODY_ARABIC_OK_DATA_FILE));
        assertNotNull(result03);
        assertEquals(result03.size(), HTTP_POST_BODY_ARABIC_OK_PARAMETERS);
        assertEquals("e$services@HMG123", result03.get(HttpRequestUtils.P_PASSWORD)[0]);
        assertEquals("966500866422", result03.get(HttpRequestUtils.P_TO)[0]);
    } catch (FileNotFoundException e) {
        fail("Unexpected test error. Message: " + e.getMessage() + ".", e);
    } catch (HttpApiException e) {
        fail("Unexpected test error. Message: " + e.getMessage() + ".", e);
    }
}
Also used : HttpApiException(org.mobicents.smsc.slee.services.http.server.tx.exceptions.HttpApiException) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream) Test(org.testng.annotations.Test)

Aggregations

HttpApiException (org.mobicents.smsc.slee.services.http.server.tx.exceptions.HttpApiException)6 IOException (java.io.IOException)4 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 UnauthorizedException (org.mobicents.smsc.slee.services.http.server.tx.exceptions.UnauthorizedException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.testng.annotations.Test)1