@After
  public void clearRepo() {

    log.info("Clearing resource repo");

    IResource[] toRemove = new IResource[repository.listResources().size()];
    toRemove = repository.listResources().toArray(toRemove);

    for (IResource resource : toRemove) {
      if (resource.getState().equals(State.ACTIVE)) {
        try {
          repository.stopResource(resource.getResourceIdentifier().getId());
        } catch (ResourceException e) {
          log.error(
              "Failed to remove resource "
                  + resource.getResourceIdentifier().getId()
                  + " from repository.");
        }
      }
      try {
        repository.removeResource(resource.getResourceIdentifier().getId());
      } catch (ResourceException e) {
        log.error(
            "Failed to remove resource "
                + resource.getResourceIdentifier().getId()
                + " from repository.");
      }
    }

    log.info("Resource repo cleared!");
  }
Ejemplo n.º 2
0
  /**
   * Stop and remove the network resource
   *
   * @throws ResourceException
   * @throws ProtocolException
   */
  @After
  public void stopResource() throws ResourceException, ProtocolException {
    resourceManager.stopResource(networkResource.getResourceIdentifier());
    resourceManager.removeResource(networkResource.getResourceIdentifier());

    // remove remaining if any
    List<IResource> toRemove = resourceManager.listResources();

    for (IResource resource : toRemove) {
      if (resource.getState().equals(State.ACTIVE)) {
        resourceManager.stopResource(resource.getResourceIdentifier());
      }
      resourceManager.removeResource(resource.getResourceIdentifier());
    }
  }