/**
   * Actually does the test given the specified input markup and the expected output markup.
   *
   * @param input the markup (including real and pseudo markup)
   * @param expected the expected VDXML markup
   */
  protected void doTest(String input, String expected) throws Exception {

    InternalDevice internalDevice = InternalDeviceTestHelper.createTestDevice();

    ProtocolBuilder builder = new ProtocolBuilder();
    DOMProtocol protocol =
        (DOMProtocol)
            builder.build(new TestProtocolRegistry.TestDOMProtocolFactory(), internalDevice);

    Document document = DOMUtilities.read(DOMUtilities.getReader(), input);

    createTransformer().transform(protocol, document);

    String actual = DOMUtilities.toString(document, protocol.getCharacterEncoder());
    expected = DOMUtilities.provideDOMNormalizedString(expected, protocol.getCharacterEncoder());

    assertEquals("input: " + expected + " actual: " + actual, expected, actual);
  }
  /** Invoke the renderer using the item text as content and return the result as a String. */
  public static String getRenderOutputAsString(MenuItemBracketingRenderer renderer, MenuItem item)
      throws RendererException {

    TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

    if (renderer.open(buffer, item)) {

      buffer.transferContentsFrom(item.getLabel().getText().getText());

      renderer.close(buffer, item);
    }

    // Extract the output from the menu item rendering as a string.
    return DOMUtilities.toString(buffer.getRoot());
  }