@Test(dependsOnMethods = "testServerDiscovery")
  public void testServiceDiscovery() throws Exception {
    try {
      InventoryReport report =
          PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately();
      Resource platform = PluginContainer.getInstance().getInventoryManager().getPlatform();

      /*System.out.println("RUNTIME SERVERS: " + platform.getChildResources().size());
       * for (Resource server : platform.getChildResources()) { System.out.println("Server: " +
       * server.toString()); System.out.println("Found with " + server.getChildResources().size() + " child
       * services");}*/
    } catch (Exception e) {
      log.error("Failure to run discovery", e);
      throw e;
    }

    InventoryPrinter.outputInventory(new PrintWriter(System.out), false);
  }
Esempio n. 2
0
  /**
   * Tests that the JON Agent can be discovered.
   *
   * @throws Exception
   */
  public void testServerDiscovery() throws Exception {
    InventoryReport report = pc.getInventoryManager().executeServerScanImmediately();
    assert report != null;

    Resource platform = pc.getInventoryManager().getPlatform();
    Set<Resource> servers = platform.getChildResources();
    assert servers.size() > 0;

    Resource agent_resource = servers.iterator().next();
    assert agent_resource.getName().indexOf("RHQ Agent") > -1
        : "Bad name: " + agent_resource.getName();
    assert agent_resource.getResourceType().getName().equals(AGENT_RESOURCE_TYPE_NAME)
        : "Bad type: " + agent_resource.getResourceType();
    assert agent_resource.getResourceType().getCategory() == ResourceCategory.SERVER
        : "Bad type: " + agent_resource.getResourceType();

    pc.getInventoryManager().executeServiceScanImmediately();

    InventoryPrinter.outputInventory(new PrintWriter(System.out), false);
  }