Exemplo n.º 1
0
 public void assertFeatureInstalled(String featureName) {
   Feature[] features = featuresService.listInstalledFeatures();
   for (Feature feature : features) {
     if (featureName.equals(feature.getName())) {
       return;
     }
   }
   fail("Feature " + featureName + " should be installed but is not");
 }
  /**
   * Check if a feature is already installed locally.
   *
   * @param name the feature name.
   * @param version the feature version.
   * @return true if the feature is already installed locally, false else.
   */
  public Boolean isFeatureInstalledLocally(String name, String version) {
    if (featuresService != null) {
      try {
        Feature[] localFeatures = featuresService.listInstalledFeatures();

        if (localFeatures != null && localFeatures.length > 0) {
          for (Feature localFeature : localFeatures) {
            if (localFeature.getName().equals(name)
                && (localFeature.getVersion().equals(version) || version == null)) return true;
          }
        }
      } catch (Exception e) {
        LOGGER.warn(
            "CELLAR FEATURES: can't check if the feature {}/{} is installed locally",
            name,
            version,
            e);
      }
    }
    return false;
  }