Package org.asteriskjava.fastagi

Examples of org.asteriskjava.fastagi.AgiRequest


    @SuppressWarnings("deprecation")
    @Test
    public void testBuildRequestCallerIdAsterisk12WithUnknownCallerIdName()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_callerid: 1234");
        lines.add("agi_calleridname: unknown");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect callerId", "1234", request.getCallerId());
        assertEquals("incorrect callerIdNumber", "1234", request.getCallerIdNumber());
        assertNull("callerIdName must not be set if \"unknown\"", request.getCallerIdName());
    }
View Full Code Here


    @Test
    public void testBuildRequestCallerIdWithUnknownDnid()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_dnid: unknown");

        request = new AgiRequestImpl(lines);

        assertNull("dnid must not be set if \"unknown\"", request.getDnid());
    }
View Full Code Here

    @Test
    public void testBuildRequestCallerIdWithUnknownRdnis()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_rdnis: unknown");

        request = new AgiRequestImpl(lines);

        assertNull("rdnis must not be set if \"unknown\"", request.getRdnis());
    }
View Full Code Here

    @Test
    public void testBuildRequestWithUnusualInput()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("var without agi prefix: a value");
        lines.add("agi_without_colon another value");
        lines.add("agi_without_space_after_colon:");
        lines.add("agi_channel: SIP/1234-a892");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect channel", "SIP/1234-a892", request.getChannel());
    }
View Full Code Here

    @Test
    public void testBuildRequestWithoutParameters()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi");
        lines.add("agi_request: agi://host/myscript.agi");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL());
        assertEquals("incorrect value for unset parameter 'param1'", null, request.getParameter("param1"));
        assertNotNull("getParameterValues() must not return null", request.getParameterValues("param1"));
        assertEquals("incorrect size of values for unset parameter 'param1'", 0, request.getParameterValues("param1").length);
        assertNotNull("getParameterMap() must not return null", request.getParameterMap());
        assertEquals("incorrect size of getParameterMap()", 0, request.getParameterMap().size());
    }
View Full Code Here

    @Test
    public void testBuildRequestWithSingleValueParameters()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi?param1=value1&param2=value2");
        lines.add("agi_request: agi://host/myscript.agi?param1=value1&param2=value2");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=value1&param2=value2", request.getRequestURL());
        assertEquals("incorrect value for parameter 'param1'", "value1", request.getParameter("param1"));
        assertEquals("incorrect value for parameter 'param2'", "value2", request.getParameter("param2"));
        assertEquals("incorrect value for unset parameter 'param3'", null, request.getParameter("param3"));
        assertEquals("incorrect size of getParameterMap()", 2, request.getParameterMap().size());
        assertEquals("incorrect value for parameter 'param1' when obtained from map", "value1", ((String[]) request
                .getParameterMap().get("param1"))[0]);
    }
View Full Code Here

    @Test
    public void testBuildRequestWithMultiValueParameter()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi?param1=value1&param1=value2");
        lines.add("agi_request: agi://host/myscript.agi?param1=value1&param1=value2");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=value1&param1=value2", request.getRequestURL());
        assertEquals("incorrect number of values for parameter 'param1'", 2, request.getParameterValues("param1").length);
        assertEquals("incorrect value[0] for parameter 'param1'", "value1", request.getParameterValues("param1")[0]);
        assertEquals("incorrect value[1] for parameter 'param1'", "value2", request.getParameterValues("param1")[1]);
    }
View Full Code Here

    @Test
    public void testBuildRequestWithEmptyValueParameter()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi?param1");
        lines.add("agi_request: agi://host/myscript.agi?param1");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1", request.getRequestURL());
        assertEquals("incorrect value for parameter 'param1'", "", request.getParameter("param1"));
        assertEquals("incorrect number of values for parameter 'param1'", 1, request.getParameterValues("param1").length);
        assertEquals("incorrect value[0] for parameter 'param1'", "", request.getParameterValues("param1")[0]);
    }
View Full Code Here

    @Test
    public void testBuildRequestWithUrlEncodedParameter()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi?param1=my%20value");
        lines.add("agi_request: agi://host/myscript.agi?param1=my%20value");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=my%20value", request.getRequestURL());
        assertEquals("incorrect value for parameter 'param1'", "my value", request.getParameter("param1"));
    }
View Full Code Here

    @Test
    public void testGetParameter()
    {
        List<String> lines;
        AgiRequest request;

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi?param1=my%20value");
        lines.add("agi_request: agi://host/myscript.agi?param1=my%20value");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect requestURL", "agi://host/myscript.agi?param1=my%20value", request.getRequestURL());
        assertEquals("incorrect value for parameter 'param1'", "my value", request.getParameter("param1"));
    }
View Full Code Here

TOP

Related Classes of org.asteriskjava.fastagi.AgiRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.