Package org.asteriskjava.manager.response

Examples of org.asteriskjava.manager.response.ManagerResponse


    }

    @Test
    public void testBuildChallengeResponse()
    {
        ManagerResponse response;

        attributes.put("response", "Success");
        attributes.put("challenge", "131494410");

        response = responseBuilder.buildResponse(ChallengeResponse.class, attributes);
        assertEquals("Response of wrong type", ChallengeResponse.class, response.getClass());
        assertEquals("Challenge not set correctly", "131494410", ((ChallengeResponse) response).getChallenge());
    }
View Full Code Here


    }

    @Test
    public void testBuildMailboxStatusResponse()
    {
        ManagerResponse response;

        attributes.put("response", "Success");
        attributes.put("message", "Mailbox Status");
        attributes.put("mailbox", "123");
        attributes.put("waiting", "1");

        response = responseBuilder.buildResponse(MailboxStatusResponse.class, attributes);
        assertEquals("Response of wrong type", MailboxStatusResponse.class, response.getClass());

        MailboxStatusResponse mailboxStatusResponse = (MailboxStatusResponse) response;
        assertEquals("Mailbox not set correctly", "123", mailboxStatusResponse.getMailbox());
        assertEquals("Waiting not set correctly", Boolean.TRUE, mailboxStatusResponse.getWaiting());
    }
View Full Code Here

    }

    @Test
    public void testBuildMailboxStatusResponseWithNoWaiting()
    {
        ManagerResponse response;

        attributes.put("response", "Success");
        attributes.put("message", "Mailbox Status");
        attributes.put("mailbox", "123,user2");
        attributes.put("waiting", "0");

        response = responseBuilder.buildResponse(MailboxStatusResponse.class, attributes);
        assertEquals("Response of wrong type", MailboxStatusResponse.class, response.getClass());

        MailboxStatusResponse mailboxStatusResponse = (MailboxStatusResponse) response;
        assertEquals("Mailbox not set correctly", "123,user2", mailboxStatusResponse.getMailbox());
        assertEquals("Waiting not set correctly", Boolean.FALSE, mailboxStatusResponse.getWaiting());
    }
View Full Code Here

    }

    @Test
    public void testBuildMailboxCountResponse()
    {
        ManagerResponse response;

        attributes.put("response", "Success");
        attributes.put("message", "Mailbox Message Count");
        attributes.put("mailbox", "123@myctx");
        attributes.put("newmessages", "2");
        attributes.put("oldmessages", "5");

        response = responseBuilder.buildResponse(MailboxCountResponse.class, attributes);
        assertEquals("Response of wrong type", MailboxCountResponse.class, response.getClass());

        MailboxCountResponse mailboxCountResponse = (MailboxCountResponse) response;
        assertEquals("Mailbox not set correctly", "123@myctx", mailboxCountResponse.getMailbox());
        assertEquals("New messages not set correctly", Integer.valueOf(2), mailboxCountResponse.getNewMessages());
        assertEquals("Old messages set correctly", Integer.valueOf(5), mailboxCountResponse.getOldMessages());
View Full Code Here

    }

    @Test
    public void testBuildExtensionStateResponse()
    {
        ManagerResponse response;

        attributes.put("response", "Success");
        attributes.put("message", "Extension Status");
        attributes.put("exten", "1");
        attributes.put("context", "default");
        attributes.put("hint", "");
        attributes.put("status", "-1");

        response = responseBuilder.buildResponse(ExtensionStateResponse.class, attributes);
        assertEquals("Response of wrong type", ExtensionStateResponse.class, response.getClass());

        ExtensionStateResponse extensionStateResponse = (ExtensionStateResponse) response;
        assertEquals("Exten not set correctly", "1", extensionStateResponse.getExten());
        assertEquals("Context not set correctly", "default", extensionStateResponse.getContext());
        assertEquals("Hint not set correctly", "", extensionStateResponse.getHint());
View Full Code Here

    @Test
    public void testSendAction() throws Exception
    {
        StatusAction statusAction;
        ManagerResponse response;

        statusAction = new StatusAction();
        statusAction.setActionId("123");

        // fake connect
        mc.connect();
        mc.setState(ManagerConnectionState.CONNECTED);
        response = mc.sendAction(statusAction);

        assertEquals("incorrect actionId in action", "123", statusAction.getActionId());
        assertEquals("incorrect actionId in response", "123", response.getActionId());
        assertEquals("incorrect response", "Success", response.getResponse());

        assertEquals("other actions not sent 1 time", 1, mockWriter.otherActionsSent);
    }
View Full Code Here

    }

    @Test
    public void testDispatchResponseUnexpectedResponse()
    {
        ManagerResponse response;

        response = new ManagerResponse();
        // internalActionId: 123_0
        response.setActionId("123_0-abc");
        response.setResponse("Success");

        // expected result is ignoring the response and logging
        mc.dispatchResponse(response);
    }
View Full Code Here

    }

    @Test
    public void testDispatchResponseMissingInternalActionId()
    {
        ManagerResponse response;

        response = new ManagerResponse();
        response.setActionId("abc");
        response.setResponse("Success");

        // expected result is ignoring the response and logging
        mc.dispatchResponse(response);
    }
View Full Code Here

    }

    @Test
    public void testDispatchResponseNullActionId()
    {
        ManagerResponse response;

        response = new ManagerResponse();
        response.setActionId(null);
        response.setResponse("Success");

        // expected result is ignoring the response and logging
        mc.dispatchResponse(response);
    }
View Full Code Here

            loginActionsSent++;

            if (sendResponse)
            {
                ManagerResponse loginResponse;

                // let testReconnectWithKeepAliveAfterAuthenticationFailure
                // succeed after
                // 3 unsuccessful attempts
                if (key.equals(expectedKey) || loginActionsSent > 2)
                {
                    loginResponse = new ManagerResponse();
                    loginResponse.setResponse("Success");
                }
                else
                {
                    loginResponse = new ManagerError();
                    loginResponse.setResponse("Error");
                    loginResponse.setMessage("Authentication failed");
                }
                loginResponse.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId));
                dispatchLater(loginResponse);
            }
        }
        else if (action instanceof LogoffAction)
        {
            logoffActionsSent++;

            if (sendResponse)
            {
                ManagerResponse response;

                response = new ManagerResponse();
                response.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId));
                response.setResponse("Success");
                dispatchLater(response);
            }
        }
        else
        {
            otherActionsSent++;

            if (sendResponse)
            {
                ManagerResponse response;

                response = new ManagerResponse();
                response.setActionId(ManagerUtil.addInternalActionId(action.getActionId(), internalActionId));
                response.setResponse("Success");
                dispatchLater(response);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.asteriskjava.manager.response.ManagerResponse

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.