/**
   * Test setting/retrieval of user defined error parsers.
   *
   * @throws Exception...
   */
  public void testUserDefinedErrorParsers() throws Exception {
    final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
    final String TESTING_NAME = "An error parser";
    // reset parsers
    {
      ErrorParserManager.setUserDefinedErrorParsers(null);
      String[] userDefinedIds = ErrorParserManager.getUserDefinedErrorParserIds();
      assertNull(userDefinedIds);

      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      String extensions =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserExtensionIds());
      assertEquals(all, extensions);
    }
    {
      ErrorParserManager.setUserDefinedErrorParsers(
          new IErrorParserNamed[] {
            new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, new DummyErrorParser()),
          });
      String userDefinedIds =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getUserDefinedErrorParserIds());
      assertEquals(TESTING_ID, userDefinedIds);

      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      String extensions =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserExtensionIds());
      assertFalse(all.equals(extensions));
    }
  }
  /**
   * Make sure extensions contributed through extension point are sorted by name unless deprecated
   * or contributed by test plugin.
   *
   * @throws Exception...
   */
  public void testExtensionsSorting() throws Exception {
    {
      String[] ids = ErrorParserManager.getErrorParserExtensionIds();
      String lastName = "";
      boolean lastIsDeprecated = false;
      boolean lastIsTestPlugin = false;
      // first regular error parsers
      // then deprecated ones
      // then contributed by test plugin
      for (String id : ids) {
        String name = ErrorParserManager.getErrorParserCopy(id).getName();
        boolean isDeprecated = name.contains("(Deprecated)");
        boolean isTestPlugin = id.startsWith(CTestPlugin.PLUGIN_ID);
        String message = "Parser [" + lastName + "] preceeds [" + name + "]";

        // inside the same category sorted by names
        if (lastIsDeprecated == isDeprecated && lastIsTestPlugin == isTestPlugin) {
          assertTrue(message, lastName.compareTo(name) <= 0);
        }
        // deprecated follow non-deprecated (unless parsers from test plugin show up)
        if (lastIsTestPlugin == isTestPlugin) {
          assertFalse(message, lastIsDeprecated == true && isDeprecated == false);
        }
        // error parsers from test plugin are the last
        assertFalse(message, lastIsTestPlugin == true && isTestPlugin == false);

        lastName = name;
        lastIsDeprecated = isDeprecated;
        lastIsTestPlugin = isTestPlugin;
      }
    }
  }