コード例 #1
0
  /**
   * Check that regular error parser extension defined in plugin.xml is accessible.
   *
   * @throws Exception...
   */
  public void testExtension() throws Exception {
    // ErrorParserManager.getErrorParser
    {
      IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID);
      assertNotNull(errorParser);
      assertEquals(REGEX_ERRORPARSER_NAME, errorParser.getName());

      assertTrue(errorParser instanceof RegexErrorParser);
      RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
      assertEquals(REGEX_ERRORPARSER_ID, regexErrorParser.getId());
      assertEquals(REGEX_ERRORPARSER_NAME, regexErrorParser.getName());

      RegexErrorPattern[] patterns = regexErrorParser.getPatterns();
      assertEquals(1, patterns.length);

      RegexErrorPattern pattern = patterns[0];
      assertEquals(IMarker.SEVERITY_ERROR, pattern.getSeverity());
      assertEquals(true, pattern.isEatProcessedLine());
      assertEquals("(.*):(.*):regex (.*)", pattern.getPattern());
      assertEquals("$1", pattern.getFileExpression());
      assertEquals("$2", pattern.getLineExpression());
      assertEquals("$3", pattern.getDescriptionExpression());
      assertEquals("", pattern.getVarNameExpression());
    }

    // ErrorParserManager.getErrorParsers
    {
      IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(REGEX_ERRORPARSER_ID);
      assertTrue(errorParser instanceof RegexErrorParser);

      RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
      assertEquals(REGEX_ERRORPARSER_ID, regexErrorParser.getId());
      assertEquals(REGEX_ERRORPARSER_NAME, regexErrorParser.getName());
    }
  }
コード例 #2
0
  /**
   * Make sure special characters are serialized properly.
   *
   * @throws Exception...
   */
  public void testSerializeRegexErrorParserSpecialCharacters() throws Exception {

    final String TESTING_ID = "org.eclipse.cdt.core.test.regexerrorparser";
    final String TESTING_NAME = "<>\"'\\& Error Parser";
    final String TESTING_REGEX = "Pattern-<>\"'\\&";
    final String ALL_IDS =
        ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
    {
      // Create error parser with the same id as in eclipse registry
      RegexErrorParser regexErrorParser = new RegexErrorParser(TESTING_ID, TESTING_NAME);
      regexErrorParser.addPattern(
          new RegexErrorPattern(
              TESTING_REGEX,
              "line-<>\"'\\&",
              "file-<>\"'\\&",
              "description-<>\"'\\&",
              null,
              IMarkerGenerator.SEVERITY_WARNING,
              false));

      // Add to available parsers
      ErrorParserExtensionManager.setUserDefinedErrorParsersInternal(
          new IErrorParserNamed[] {regexErrorParser});
      assertNotNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));
      // And serialize in persistent storage
      ErrorParserExtensionManager.serializeUserDefinedErrorParsers();
    }

    {
      // Re-load from persistent storage and check it out
      ErrorParserExtensionManager.loadUserDefinedErrorParsers();
      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      assertTrue(all.contains(TESTING_ID));

      IErrorParser errorParser = ErrorParserManager.getErrorParserCopy(TESTING_ID);
      assertNotNull(errorParser);
      assertTrue(errorParser instanceof RegexErrorParser);
      RegexErrorParser regexErrorParser = (RegexErrorParser) errorParser;
      assertEquals(TESTING_ID, regexErrorParser.getId());
      assertEquals(TESTING_NAME, regexErrorParser.getName());

      RegexErrorPattern[] errorPatterns = regexErrorParser.getPatterns();
      assertEquals(1, errorPatterns.length);
      assertEquals(TESTING_REGEX, errorPatterns[0].getPattern());
    }
  }