Example #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, "; ");
 }
Example #2
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;
 }
Example #3
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;
    }