@Test
  @SuppressWarnings("unchecked")
  public void findAndValidateUpgradePacks() throws Exception {

    IOFileFilter filter = new IOFileFilter() {
      @Override
      public boolean accept(File dir, String name) {
        return false;
      }

      @Override
      public boolean accept(File file) {
        // file has the folder named 'upgrades', ends with '.xml' and is NOT 'config-upgrade.xml'
        if (file.getAbsolutePath().contains("upgrades") &&
            file.getAbsolutePath().endsWith(".xml") &&
            !file.getAbsolutePath().contains("config-upgrade.xml")) {

          return true;
        }

        return false;
      }
    };

    List<File> files = new ArrayList<>();

    files.addAll(FileUtils.listFiles(new File("src/main/resources/stacks"), filter,
      FileFilterUtils.directoryFileFilter()));

    files.addAll(FileUtils.listFiles(new File("src/test/resources/stacks"), filter,
        FileFilterUtils.directoryFileFilter()));

    files.addAll(FileUtils.listFiles(new File("src/test/resources/stacks_with_upgrade_cycle"), filter,
        FileFilterUtils.directoryFileFilter()));

    ModuleFileUnmarshaller unmarshaller = new ModuleFileUnmarshaller();

    for (File file : files) {
      String fileContent = FileUtils.readFileToString(file, "UTF-8");

      // these things must be in upgrade packs for them to work anyway
      if (fileContent.contains("<upgrade") && fileContent.contains("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"")) {
        if (!fileContent.contains("xsi:noNamespaceSchemaLocation=\"upgrade-pack.xsd\"")) {
          String msg = String.format("File %s appears to be an upgrade pack, but does not define 'upgrade-pack.xsd' as its schema",
              file.getAbsolutePath());
          Assert.fail(msg);
        } else {
          unmarshaller.unmarshal(UpgradePack.class, file, true);
        }
      }
    }
  }
Tests parsing upgrade packs in the entire codebase.  This does not use Guice
initialization, which will parse upgrade packs itself.
ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackParsingTest.java