Examples of AgentInfo


Examples of org.jivesoftware.smackx.workgroup.packet.AgentInfo

     * @param newName the new name of the agent.
     * @throws XMPPException if the agent is not allowed to change his name or no response was
     *                       obtained from the server.
     */
    public void setName(String newName) throws XMPPException {
        AgentInfo agentInfo = new AgentInfo();
        agentInfo.setType(IQ.Type.SET);
        agentInfo.setTo(workgroupJID);
        agentInfo.setFrom(getUser());
        agentInfo.setName(newName);
        PacketCollector collector = connection.createPacketCollector(new PacketIDFilter(agentInfo.getPacketID()));
        // Send the request
        connection.sendPacket(agentInfo);

        IQ response = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());

View Full Code Here

Examples of org.ngrinder.model.AgentInfo

  @Before
  public void before() {
  }

  public AgentInfo createAgentInfo(String region, boolean approved, AgentControllerState status) {
    AgentInfo agentInfo1 = new AgentInfo();
    agentInfo1.setRegion(region);
    agentInfo1.setApproved(approved);
    agentInfo1.setState(status);
    return agentInfo1;
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

  @Autowired
  private Config config;

  @Test
  public void testSaveGetDeleteAgent() {
    AgentInfo agent = saveAgent("save");
    AgentInfo agent2 = agentManagerService.getOne(agent.getId());
    Assert.assertNotNull(agent2);

    List<AgentInfo> agentListDB = agentManagerService.getAllLocal();
    Assert.assertNotNull(agentListDB);
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    Collection<AgentInfo> agents = (Collection<AgentInfo>) model.get("agents");
  }

  @Test
  public void testApproveAgent() {
    AgentInfo agent = new AgentInfo();
    agent.setApproved(false);
    agent.setName("Test-Host");
    agent.setIp("127.0.0.1");
    agent.setState(AgentControllerState.READY);
    agentManagerRepository.save(agent);

    ModelMap model = new ModelMap();
    // test get agent
    agentController.getOne(agent.getId(), model);
    AgentInfo agentInDB = (AgentInfo) model.get("agent");
    assertThat(agentInDB.getName(), is(agent.getName()));
    assertThat(agentInDB.getIp(), is(agent.getIp()));
    assertThat(agentInDB.isApproved(), is(false));

    // test approve agent
    model.clear();
    agentController.approve(agentInDB.getId());
    agentController.getOne(agent.getId(), model);
    agentInDB = (AgentInfo) model.get("agent");
    assertThat(agentInDB.isApproved(), is(true));

    // test un-approve
    model.clear();
    agentController.disapprove(agentInDB.getId());
    agentController.getOne(agent.getId(), model);
    agentInDB = (AgentInfo) model.get("agent");
    assertThat(agentInDB.isApproved(), is(false));
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    addAgent("hello", "world1");

  }

  private void addAgent(String name, String region) {
    agentInfo = new AgentInfo();
    agentInfo.setName(name);
    agentInfo.setIp("127.0.0.1");
    agentInfo.setRegion(region);
    agentInfo.setState(AgentControllerState.BUSY);
    agentInfo.setApproved(false);
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    agentRepository.save(agentInfo);
  }

  @Test
  public void testGetByIp() {
    AgentInfo findByIp = agentRepository.findByIp("127.0.0.1");
    assertThat(findByIp.isApproved(), is(false));
    findByIp.setApproved(true);
    agentRepository.save(findByIp);
    findByIp = agentRepository.findByIp("127.0.0.1");
    assertThat(findByIp.isApproved(), is(true));
    assertThat(findByIp, notNullValue());
    assertThat(findByIp.getName(), is("hello"));
    assertThat(findByIp.getRegion(), is("world1"));
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    agent2 = agentManagerService.getOne(agent.getId());
    Assert.assertNull(agent2);
  }

  private AgentInfo saveAgent(String key) {
    AgentInfo agent = new AgentInfo();
    agent.setIp("1.1.1.1");
    agent.setName("testAppName" + key);
    agent.setPort(8080);
    agent.setRegion("testRegion" + key);
    agent.setState(AgentControllerState.BUSY);
    agentRepository.save(agent);
    return agent;
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

  public void testGetUserAvailableAgentCount() {
    Map<String, MutableInt> countMap = agentManagerService.getAvailableAgentCountMap(getTestUser());
    String currRegion = config.getRegion();
    int oriCount = countMap.get(currRegion).intValue();

    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setName("localhost");
    agentInfo.setRegion(config.getRegion());
    agentInfo.setIp("127.127.127.127");
    agentInfo.setPort(1);
    agentInfo.setState(AgentControllerState.READY);
    agentInfo.setApproved(true);
    agentRepository.save(agentInfo);
    localAgentService.expireCache();
    countMap = agentManagerService.getAvailableAgentCountMap(getTestUser());

    int newCount = countMap.get(config.getRegion()).intValue();
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

    assertThat(newCount, is(oriCount + 1));
  }

  @Test
  public void testCheckAgentState() {
    AgentInfo agentInfo = new AgentInfo();
    agentInfo.setName("localhost");
    agentInfo.setRegion(config.getRegion());
    agentInfo.setIp("127.127.127.127");
    agentInfo.setPort(1);
    agentInfo.setState(AgentControllerState.READY);
    agentRepository.save(agentInfo);
    localAgentService.expireCache();
    agentManagerService.checkAgentState();

    AgentInfo agentInDB = agentRepository.findOne(agentInfo.getId());
    assertThat(agentInDB.getIp(), is(agentInfo.getIp()));
    assertThat(agentInDB.getName(), is(agentInfo.getName()));
    assertThat(agentInDB.getState(), is(AgentControllerState.INACTIVE));
  }
View Full Code Here

Examples of org.ngrinder.model.AgentInfo

  @Test
  public void testCache() {
    List<AgentInfo> info = cachedLocalAgentService.getLocalAgents();
    int previousSize = info.size();
    info.add(new AgentInfo());
    assertThat(cachedLocalAgentService.getLocalAgents().size()).isEqualTo(previousSize);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.