Package org.rhq.enterprise.communications.command.client

Examples of org.rhq.enterprise.communications.command.client.ClientCommandSenderStateListener


     */
    public boolean waitForServer(long wait_ms) throws AgentNotSupportedException {
        final CountDownLatch latch = new CountDownLatch(1);

        // when the sender has started, it means the RHQ Server has come up - here's our listener for that
        ClientCommandSenderStateListener listener = new ClientCommandSenderStateListener() {
            public boolean startedSending(ClientCommandSender sender) {
                latch.countDown();
                return false; // no need to keep listening
            }

View Full Code Here


    public void testClientCommandSenderStateListener() throws Exception {
        AgentMain agent1 = m_agent1Test.createAgent(true);
        m_agent2Test.createAgent(true);

        final Boolean[] state = new Boolean[1];
        ClientCommandSenderStateListener listener = new ClientCommandSenderStateListener() {
            public boolean stoppedSending(ClientCommandSender sender) {
                state[0] = Boolean.FALSE;
                return true;
            }

            public boolean startedSending(ClientCommandSender sender) {
                state[0] = Boolean.TRUE;
                return true;
            }
        };

        assert state[0] == null : "This was just to prove we are null at the start - very weird for this to fail";
        assert agent1.getClientCommandSender().isSending() : "Setup of this test should have started the sender";

        agent1.getClientCommandSender().addStateListener(listener, false);
        assert state[0] == null : "We told it not to notify us immediately - should not have called the listener";
        agent1.getClientCommandSender().removeStateListener(listener);

        agent1.getClientCommandSender().addStateListener(listener, true);
        assert state[0].booleanValue() : "Listener should have been told the sender is sending";
        agent1.getClientCommandSender().stopSending(false);
        assert !state[0].booleanValue() : "Listener should have told us we are no longer sending";
        agent1.getClientCommandSender().startSending();
        assert state[0].booleanValue() : "Listener should have told us we are sending again";
        agent1.getClientCommandSender().removeStateListener(listener);

        ClientCommandSenderStateListener one_time_listener = new ClientCommandSenderStateListener() {
            public boolean stoppedSending(ClientCommandSender sender) {
                state[0] = Boolean.FALSE;
                return false;
            }
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.communications.command.client.ClientCommandSenderStateListener

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.