/**
   * 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));
    }
  }
  @Override
  protected void tearDown() throws Exception {
    ResourceHelper.cleanUp();
    fProject = null;

    ErrorParserManager.setUserDefinedErrorParsers(null);
  }
  /**
   * Test setting/retrieval of error parsers and their IDs.
   *
   * @throws Exception...
   */
  public void testAvailableErrorParsers() throws Exception {
    final String TESTING_ID = "org.eclipse.cdt.core.test.errorparser";
    final String TESTING_NAME = "An error parser";

    final String[] availableParserIds = ErrorParserManager.getErrorParserAvailableIds();
    assertNotNull(availableParserIds);
    assertTrue(availableParserIds.length > 0);
    final String firstId = ErrorParserManager.getErrorParserAvailableIds()[0];
    final IErrorParserNamed firstErrorParser = ErrorParserManager.getErrorParserCopy(firstId);
    assertNotNull(firstErrorParser);
    assertEquals(firstId, firstErrorParser.getId());
    final String firstName = firstErrorParser.getName();
    // Preconditions
    {
      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      assertEquals(false, all.contains(TESTING_ID));
      assertEquals(true, all.contains(firstId));

      assertNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));

      IErrorParserNamed retrieved2 = ErrorParserManager.getErrorParserCopy(firstId);
      assertNotNull(retrieved2);
      assertEquals(firstErrorParser, retrieved2);
    }

    // set available parsers
    {
      IErrorParser dummy1 = new DummyErrorParser();
      IErrorParser dummy2 = new DummyErrorParser();
      ErrorParserManager.setUserDefinedErrorParsers(
          new IErrorParserNamed[] {
            // add brand new one
            new ErrorParserNamedWrapper(TESTING_ID, TESTING_NAME, dummy1),
            // override extension with another one
            new ErrorParserNamedWrapper(firstId, firstName, dummy2),
          });
      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      assertEquals(true, all.contains(TESTING_ID));
      assertEquals(true, all.contains(firstId));

      IErrorParserNamed retrieved1 = ErrorParserManager.getErrorParserCopy(TESTING_ID);
      assertNotNull(retrieved1);
      assertEquals(TESTING_NAME, retrieved1.getName());
      assertTrue(retrieved1 instanceof ErrorParserNamedWrapper);
      assertEquals(dummy1, ((ErrorParserNamedWrapper) retrieved1).getErrorParser());

      IErrorParserNamed retrieved2 = ErrorParserManager.getErrorParserCopy(firstId);
      assertNotNull(retrieved2);
      assertEquals(firstName, retrieved2.getName());
      assertTrue(retrieved2 instanceof ErrorParserNamedWrapper);
      assertEquals(dummy2, ((ErrorParserNamedWrapper) retrieved2).getErrorParser());

      IErrorParserNamed retrieved2_ext = ErrorParserManager.getErrorParserExtensionCopy(firstId);
      assertNotNull(retrieved2_ext);
      assertEquals(firstName, retrieved2_ext.getName());
      assertEquals(firstErrorParser, retrieved2_ext);
    }
    // reset available parsers
    {
      ErrorParserManager.setUserDefinedErrorParsers(null);
      String[] userDefinedIds = ErrorParserManager.getUserDefinedErrorParserIds();
      assertNull(userDefinedIds);

      String all =
          ErrorParserManager.toDelimitedString(ErrorParserManager.getErrorParserAvailableIds());
      assertEquals(false, all.contains(TESTING_ID));
      assertEquals(true, all.contains(firstId));

      assertNull(ErrorParserManager.getErrorParserCopy(TESTING_ID));

      IErrorParserNamed retrieved2 = ErrorParserManager.getErrorParserCopy(firstId);
      assertNotNull(retrieved2);
      assertEquals(firstErrorParser, retrieved2);
    }
  }