public void testLoadUnknounClassTag() {
   try {
     Yaml yaml = new Yaml();
     yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
     fail("Must fail because of unknown tag: !car");
   } catch (YAMLException e) {
     assertTrue(e.getMessage().contains("Invalid tag: !car"));
   }
 }
  @SuppressWarnings("unchecked")
  public void deploy(VFSDeploymentUnit unit) throws DeploymentException {
    TorqueBoxMetaData globalMetaData = unit.getAttachment(TorqueBoxMetaData.class);

    log.debug("Global torquebox.yml: " + globalMetaData);

    Object data = null;

    if (globalMetaData != null) {
      data = globalMetaData.getSection(getSectionName());
      log.debug("Global data section for " + getSectionName() + ": " + data);
    }

    if (data == null && isSupportsStandalone()) {
      VirtualFile metaDataFile = getMetaDataFile(unit, getFileName());

      if ((metaDataFile != null) && metaDataFile.exists()) {
        log.warn("Usage of " + getFileName() + " is deprecated.  Please use torquebox.yml.");
        InputStream in = null;
        try {
          in = metaDataFile.openStream();
          Yaml yaml = new Yaml();
          data = (Map<String, ?>) yaml.load(in);
        } catch (YAMLException e) {
          log.warn("Error parsing: " + metaDataFile + ": " + e.getMessage());
          data = null;
        } catch (IOException e) {
          throw new DeploymentException(e);
        } finally {
          if (in != null) {
            try {
              in.close();
            } catch (IOException e) {
              throw new DeploymentException(e);
            }
          }
        }
      }
    }

    if (data == null) {
      return;
    }

    try {
      parse(unit, data);
    } catch (DeploymentException e) {
      throw e;
    } catch (Exception e) {
      throw new DeploymentException(e);
    }
  }
  /**
   * Validate the response is in expected yaml format
   *
   * @param response response
   * @return Collection of job data maps if format is correct and there is no error
   * @throws com.dtolabs.client.services.CentralDispatcherServerRequestException if the format is
   *     incorrect, or the response indicates an error response.
   */
  private Collection<Map> validateJobsResponseYAML(final WebserviceResponse response)
      throws CentralDispatcherServerRequestException {
    if (null == response) {
      throw new CentralDispatcherServerRequestException("Response was null");
    }

    if (null != response.getResponseMessage()) {
      logger.info("Response: " + response.getResponseMessage());
    }
    String resultContentType = response.getResultContentType();
    if (resultContentType.contains(";")) {
      resultContentType = resultContentType.substring(0, resultContentType.indexOf(";"));
    }
    if (!resultContentType.endsWith("/yaml")) {
      throw new CentralDispatcherServerRequestException(
          "Expected YAML response, unexpected content type: " + response.getResultContentType());
    }
    final ArrayList<Map> dataset = new ArrayList<Map>();
    final Object resobj;
    try {
      final Yaml yaml = new Yaml(new SafeConstructor());
      resobj = yaml.load(response.getResults());
    } catch (YAMLException e) {
      throw new CentralDispatcherServerRequestException(
          "Failed to parse YAML: " + e.getMessage(), e);
    }
    if (resobj instanceof Collection) {
      dataset.addAll((Collection) resobj);
    } else {
      throw new CentralDispatcherServerRequestException(
          "Response had unexpected content type: " + resobj);
    }

    for (final Map map : dataset) {
      if (!map.containsKey("name") || !map.containsKey("id") && !map.containsKey("uuid")) {
        throw new CentralDispatcherServerRequestException(
            "Response had unexpected dataset: " + resobj);
      }
    }
    return dataset;
  }
  @SuppressWarnings("unchecked")
  protected void parse(
      VFSDeploymentUnit unit, VirtualFile file, RubyRuntimeMetaData runtimeMetaData)
      throws Exception {

    Yaml yaml = new Yaml();
    try {
      Map<String, Object> config = (Map<String, Object>) yaml.load(file.openStream());

      if (config != null) {
        Object version = config.get("version");
        if ("1.8".equals("" + version)) {
          runtimeMetaData.setVersion(RubyRuntimeMetaData.Version.V1_8);
        } else if ("1.9".equals("" + version)) {
          runtimeMetaData.setVersion(RubyRuntimeMetaData.Version.V1_9);
        }
      }
    } catch (YAMLException e) {
      log.error("Error parsing ruby.yml: " + e.getMessage());
    }
  }