/**
   * Tests resource optimization with the {@link PSDocumentHandler}.
   *
   * @throws Exception if an error occurs
   */
  public void testResourceOptimizationWithIF() throws Exception {
    FOUserAgent ua = fopFactory.newFOUserAgent();
    PSDocumentHandler handler = new PSDocumentHandler();
    handler.setContext(new IFContext(ua));
    // This is the important part: we're enabling resource optimization
    handler.getPSUtil().setOptimizeResources(true);
    ua.setDocumentHandlerOverride(handler);

    // Prepare output file
    File outputFile =
        renderFile(ua, "ps-resources.fo", "-if-l" + handler.getPSUtil().getLanguageLevel());
    verifyPostScriptFile(outputFile);
  }