Exemple #1
0
 /**
  * Returns full summary.
  *
  * @return The test summary of all events
  */
 public String summary() {
   final List<String> msgs = new LinkedList<String>();
   for (final AuditEvent event : this.events) {
     msgs.add(String.format("%s:%s", event.getLine(), event.getMessage()));
   }
   return StringUtils.join(msgs, "; ");
 }
  /** {@inheritDoc} */
  public boolean accept(AuditEvent aEvent) {
    // file and check match?
    if ((aEvent.getFileName() == null)
        || !mFileRegexp.matcher(aEvent.getFileName()).find()
        || (aEvent.getLocalizedMessage() == null)
        || ((mModuleId != null) && !mModuleId.equals(aEvent.getModuleId()))
        || ((mCheckRegexp != null) && !mCheckRegexp.matcher(aEvent.getSourceName()).find())) {
      return true;
    }

    // reject if no line/column matching
    if ((mLineFilter == null) && (mColumnFilter == null)) {
      return false;
    }

    // reject if line matches a line CSV value.
    if (mLineFilter != null) {
      if (mLineFilter.accept(aEvent.getLine())) {
        return false;
      }
    }

    // reject if column matches a column CSV value.
    if (mColumnFilter != null) {
      if (mColumnFilter.accept(aEvent.getColumn())) {
        return false;
      }
    }
    return true;
  }
Exemple #3
0
 /**
  * Do we have this message for this line?
  *
  * @param line The number of the line
  * @param msg The message we're looking for
  * @return This message was reported for the give line?
  */
 public boolean has(final Integer line, final String msg) {
   boolean has = false;
   for (final AuditEvent event : this.events) {
     if (event.getLine() == line && event.getMessage().equals(msg)) {
       has = true;
       break;
     }
   }
   return has;
 }
Exemple #4
0
 @Override
 public void addError(AuditEvent evt) {
   if (evt.getSeverityLevel() != SeverityLevel.IGNORE) {
     writer.print("<error" + " line=\"" + evt.getLine() + "\"");
     if (evt.getColumn() > 0) {
       writer.print(" column=\"" + evt.getColumn() + "\"");
     }
     writer.print(" severity=\"" + evt.getSeverityLevel().getName() + "\"");
     writer.print(" message=\"" + encode(evt.getMessage()) + "\"");
     writer.println(" source=\"" + encode(evt.getSourceName()) + "\"/>");
   }
 }
    /**
     * Determines whether the source of an audit event matches the text of this tag.
     *
     * @param event the {@code AuditEvent} to check.
     * @return true if the source of event matches the text of this tag.
     */
    public boolean isMatch(AuditEvent event) {
      final int line = event.getLine();
      boolean match = false;

      if (line >= firstLine && line <= lastLine) {
        final Matcher tagMatcher = tagCheckRegexp.matcher(event.getSourceName());

        if (tagMatcher.find()) {
          match = true;
        } else if (tagMessageRegexp == null) {
          if (event.getModuleId() != null) {
            final Matcher idMatcher = tagCheckRegexp.matcher(event.getModuleId());
            match = idMatcher.find();
          }
        } else {
          final Matcher messageMatcher = tagMessageRegexp.matcher(event.getMessage());
          match = messageMatcher.find();
        }
      }
      return match;
    }