/**
   * Load only the given set of context files.
   *
   * @param contextFiles The set of context file to be loaded.
   * @throws IllegalArgumentException If one of the given files has an invalid name.
   */
  public void loadContexts(Set<File> contextFiles) {
    for (File file : contextFiles) {
      ContextConfiguration contextConfiguration;

      String[] split = file.getName().split("\\.");
      if (split.length < 3
          || !(split[0].equals(FILE_PREFIX))
          || !(split[split.length - 1].equals(FILE_POSTFIX))) {
        throw new IllegalArgumentException("Wrong file format");
      }

      try {
        contextConfiguration = ContextConfiguration.loadFromFile(file);
      } catch (InvalidConfigurationException e) {
        throw new IllegalStateException("Invalid configuration in file: " + file.getName(), e);
      } catch (FileNotFoundException e) {
        throw new IllegalStateException(
            "No context file with given name found: " + file.getName(), e);
      }

      List<String> id = Arrays.asList(split).subList(1, split.length - 1);

      testContexts.insertIntoTree(
          id.iterator(),
          new TestContext(
              Joiner.on("").join(id),
              this.distributionResolver,
              this.distributionExtractor,
              contextConfiguration));
    }
  }
  /**
   * Returns the context with the given name. Contexts have to be loaded with {@link
   * #loadContexts()} or {@link #loadContexts(Set)} beforehand.
   *
   * @param contextName
   * @return Context with the given name.
   * @throws IllegalArgumentException If no context with the given name is available.
   */
  public TestContext getTestContext(String contextName) {
    OS osName = OS.current();
    Arch osArch = Arch.current();

    TestContext testContext =
        testContexts.loadFromTree(
            Arrays.asList(new String[] {contextName, osName.toString(), osArch.toString()})
                .iterator());

    if (null == testContext) {
      throw new IllegalArgumentException("No context with this name available: " + contextName);
    }

    return testContext;
  }
  /**
   * Returns the default context for the current operating system and architecture. The
   * corresponding file name has to be of the form endtoend.*os*.*arch*.properties. For possible
   * values of *os* and *arch* see the classes {@link OS} and {@link Arch}. Contexts have to be
   * loaded with {@link #loadContexts()} or {@link #loadContexts(Set)} beforehand.
   *
   * @return Default context for the current operating system and architecture.
   * @throws IllegalStateException If no context for the current operating system and architecture
   *     is available.
   */
  public TestContext getDefaultTestContext() {
    OS osName = OS.current();
    Arch osArch = Arch.current();

    TestContext testContext =
        testContexts.loadFromTree(
            Arrays.asList(new String[] {osName.toString(), osArch.toString()}).iterator());

    if (null == testContext) {
      throw new IllegalStateException(
          "No context for current operation system and architecture found: "
              + osName
              + ", "
              + osArch);
    }

    return testContext;
  }