protected void assertValid(XmlModel x) {
   ValidationHandler handler;
   try {
     handler = x.validate();
   } catch (Exception e) {
     throw new RuntimeException(e.getMessage(), e);
   }
   List<SAXParseException> errors = handler.getErrors();
   assertTrue("errors were: " + errors, errors.size() == 0);
 }
Exemplo n.º 2
0
  /**
   * {@inheritDoc}
   *
   * @see org.komodo.spi.repository.ValidationManager#validateRules(java.io.File)
   */
  @Override
  public List<String> validateRules(final File rulesXmlFile) throws KException {
    ArgCheck.isNotNull(rulesXmlFile, "rulesXmlFile"); // $NON-NLS-1$

    try {
      if (_parser == null) {
        setupValidationParser();
      }

      ValidationHandler handler = new ValidationHandler();
      _parser.parse(rulesXmlFile, handler);

      // return any errors
      List<String> result = new ArrayList<>();
      result.addAll(handler.getFatalErrors());
      result.addAll(handler.getErrors());
      return result;
    } catch (final Exception e) {
      throw new KException(e);
    }
  }