Package org.asteriskjava.fastagi

Examples of org.asteriskjava.fastagi.AgiRequest


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

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi");
        lines.add("agi_request: agi://host/myscript.agi");
        lines.add("agi_arg_1: value1");
        lines.add("agi_arg_2: value2");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL());
        assertEquals("invalid number of arguments", 2, request.getArguments().length);
        assertEquals("incorrect value for first argument", "value1", request.getArguments()[0]);
        assertEquals("incorrect value for second argument", "value2", request.getArguments()[1]);
    }
View Full Code Here


  private static final long serialVersionUID = 1L;

  @Override
  public String intercept(ActionInvocation invocation) throws Exception {
    ActionContext context = invocation.getInvocationContext();
    AgiRequest request = AgiEntryPoint.getAgiRequest(context);
    Map<?, ?> r = request.getRequest();

    /**
     * This interceptor will be called multiple times in the course of
     * processing the actions for a call, so we only check the reset user param
     * once
 
View Full Code Here

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

        lines = new ArrayList<String>();

        lines.add("agi_network_script: myscript.agi");
        lines.add("agi_request: agi://host/myscript.agi");
        lines.add("agi_arg_1: value1");
        lines.add("agi_arg_2: ");
        lines.add("agi_arg_3: value3");

        request = new AgiRequestImpl(lines);

        assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL());
        assertEquals("invalid number of arguments", 3, request.getArguments().length);
        assertEquals("incorrect value for first argument", "value1", request.getArguments()[0]);
        assertEquals("incorrect value for second argument", null, request.getArguments()[1]);
        assertEquals("incorrect value for third argument", "value3", request.getArguments()[2]);
    }
View Full Code Here

    @Test
    public void testGetArgumentsWithNoArgumentsPassed()
    {
        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 requestURL", "agi://host/myscript.agi", request.getRequestURL());
        assertNotNull("getArguments() must never return null", request.getArguments());
        assertEquals("invalid number of arguments", 0, request.getArguments().length);
    }
View Full Code Here

    }

    @Test
    public void testReadRequest() throws Exception
    {
        AgiRequest request;

        expect(socket.readLine()).andReturn("agi_network: yes");
        expect(socket.readLine()).andReturn("agi_network_script: myscript.agi");
        expect(socket.readLine()).andReturn("agi_request: agi://host/myscript.agi");
        expect(socket.readLine()).andReturn("agi_channel: SIP/1234-d715");
        expect(socket.readLine()).andReturn("");

        byte[] ipLocal = new byte[4];
        ipLocal[0] = Integer.valueOf(192).byteValue();
        ipLocal[1] = Integer.valueOf(168).byteValue();
        ipLocal[2] = Integer.valueOf(0).byteValue();
        ipLocal[3] = Integer.valueOf(1).byteValue();
        expect(socket.getLocalAddress()).andReturn(InetAddress.getByAddress(ipLocal));
        expect(socket.getLocalPort()).andReturn(1234);

        byte[] ipRemote = new byte[4];
        ipRemote[0] = Integer.valueOf(192).byteValue();
        ipRemote[1] = Integer.valueOf(168).byteValue();
        ipRemote[2] = Integer.valueOf(0).byteValue();
        ipRemote[3] = Integer.valueOf(2).byteValue();
        expect(socket.getRemoteAddress()).andReturn(InetAddress.getByAddress(ipRemote));
        expect(socket.getRemotePort()).andReturn(1235);

        replay(socket);

        request = agiReader.readRequest();

        assertEquals("incorrect script", "myscript.agi", request.getScript());
        assertEquals("incorrect requestURL", "agi://host/myscript.agi", request.getRequestURL());
        assertEquals("incorrect channel", "SIP/1234-d715", request.getChannel());
        assertEquals("incorrect local address", ipLocal[0], request.getLocalAddress().getAddress()[0]);
        assertEquals("incorrect local address", ipLocal[1], request.getLocalAddress().getAddress()[1]);
        assertEquals("incorrect local address", ipLocal[2], request.getLocalAddress().getAddress()[2]);
        assertEquals("incorrect local address", ipLocal[3], request.getLocalAddress().getAddress()[3]);
        assertEquals("incorrect local port", 1234, request.getLocalPort());
        assertEquals("incorrect remote address", ipRemote[0], request.getRemoteAddress().getAddress()[0]);
        assertEquals("incorrect remote address", ipRemote[1], request.getRemoteAddress().getAddress()[1]);
        assertEquals("incorrect remote address", ipRemote[2], request.getRemoteAddress().getAddress()[2]);
        assertEquals("incorrect remote address", ipRemote[3], request.getRemoteAddress().getAddress()[3]);
        assertEquals("incorrect remote port", 1235, request.getRemotePort());

        verify(socket);
    }
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.