コード例 #1
0
 @Override
 public boolean matches(Object actual) {
   this.actual = actual;
   if (expected == null) return (actual == null);
   if (!(actual instanceof String)) {
     return false;
   }
   if (expected.equals(actual)) return true;
   String actualString = (String) actual;
   java.util.regex.Matcher m = pattern.matcher(actualString);
   while (m.find()) {
     actualLines.add(actualString.substring(m.start(), m.end()));
   }
   return expectedLines.equals(actualLines);
 }
コード例 #2
0
 public MultiLineStringMatcher(String expected, String ls) {
   this.expected = expected;
   if (ls.equals("\r")) {
     this.pattern = Pattern.compile(".+(\\r|$)");
   } else if (ls.equals("\n")) {
     this.pattern = Pattern.compile(".+(\\n|$)");
   } else {
     this.pattern = Pattern.compile(".+(\\r\\n|$)");
   }
   if (expected != null) {
     java.util.regex.Matcher m = pattern.matcher(expected);
     while (m.find()) {
       expectedLines.add(expected.substring(m.start(), m.end()));
     }
   }
 }
コード例 #3
0
    public InProcessExecutionFailure(
        List<String> tasks,
        Set<String> skippedTasks,
        OutputScrapingExecutionFailure outputFailure,
        GradleException failure) {
      super(tasks, skippedTasks, outputFailure);
      this.outputFailure = outputFailure;
      this.failure = failure;

      // Chop up the exception message into its expected parts
      java.util.regex.Matcher matcher = LOCATION_PATTERN.matcher(failure.getMessage());
      if (matcher.find()) {
        fileName = matcher.group(1);
        lineNumber = matcher.group(3);
        description = failure.getMessage().substring(matcher.end()).trim();
      } else {
        fileName = "";
        lineNumber = "";
        description = failure.getMessage().trim();
      }
    }