Package net.grinder

Examples of net.grinder.AgentDaemon


  }

  @Test
  public void testConsole() throws GrinderException, InterruptedException {
    agentThread1 = new AgentDaemon(agentConfig1);
    agentThread1.run(console1.getConsolePort());
    agentThread2 = new AgentDaemon(agentConfig2);
    agentThread2.run(console1.getConsolePort());
    // Wait until all agents are started. They will connect main console.
    sleep(4000);

    assertThat("There must be 2 agents connecting console1", console1.getAllAttachedAgents().size(), is(2));

    // if we shut down one agent.
    agentThread2.addListener(new AgentShutDownSynchronizeListener(condition));
    agentThread2.shutdown();
    sleep(5000);
    waitOnCondition(condition, 5000);

    assertThat("There must be 1 agents connecting console1", console1.getAllAttachedAgents().size(), is(1));

    // If we connect console1 again
    agentThread2.run(console1.getConsolePort());
    sleep(4000);

    assertThat("There must be 2 agents connecting console1", console1.getAllAttachedAgents().size(), is(2));

    // enable one agent more.
    agentThread3 = new AgentDaemon(agentConfig3);
    agentThread3.run(console2.getConsolePort());

    Thread.sleep(4000);

    // Now it should be 2 agents
View Full Code Here


  }

  @Test
  public void testConnection() throws InterruptedException {
    // Try to connect any port
    AgentDaemon agent = new AgentDaemon(agentConfig1);
    agent.run(getFreePort());
    sleep(1000);
  }
View Full Code Here

  Condition condition = new Condition();

  @Test(timeout = 3000)
  public void testIfAgentDeadWellWhenConsoleIsShutdown() {
    // After connecting agent daemon,
    AgentDaemon agent = new AgentDaemon(agentConfig1);
    agent.run(console1.getConsolePort());
    agent.addListener(new AgentShutDownSynchronizeListener(condition));
    // Shutdown console
    console1.shutdown();
    waitOnCondition(condition, 2100);
  }
View Full Code Here

  }

  @Test
  public void testAgentReconnect() {
    // After connecting agent daemon,
    AgentDaemon agent = new AgentDaemon(agentConfig1);
    agent.run(console1.getConsolePort());
    agent.addListener(new AgentShutDownSynchronizeListener(condition));
    // Shutdown console
    sleep(3000);
    assertThat(console1.getAllAttachedAgentsCount(), is(1));

    // shutdown twice
    agent.shutdown();
    sleep(5000);
    assertThat(console1.getAllAttachedAgentsCount(), is(0));
    agent.shutdown();
    sleep(5000);
    assertThat(console1.getAllAttachedAgentsCount(), is(0));

    // Even shutdown twice, agent is well connected into console.
    agent.run(console1.getConsolePort());
    sleep(2000);

    assertThat(console1.getAllAttachedAgentsCount(), is(1));

  }
View Full Code Here

  }

  @Test
  public void testStartAgentAndTest() throws InterruptedException, PersistenceException {
    AgentConfig agentConfig1 = Mockito.spy(agentConfig);
    AgentDaemon agent = new AgentDaemon(agentConfig1);
    URL scriptUrl = this.getClass().getResource("/grinder.properties");
    File scriptFile = new File(scriptUrl.getFile());
    GrinderProperties properties = new GrinderProperties(scriptFile);
    agent.run(properties);
    ThreadUtils.sleep(10000);
  }
View Full Code Here

TOP

Related Classes of net.grinder.AgentDaemon

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.