throws Exception {
// Create the menu item to test.
final ConcreteElementDetails elementDetails =
createTestElementDetails();
final ConcreteMenuItem item = new ConcreteMenuItem(
elementDetails, new MenuLabelStub());
item.setHref(new LiteralLinkAssetReference("the href"));
item.setShortcut(new LiteralTextAssetReference("the shortcut"));
// Create the renderer we are to test.
final TestDeprecatedExternalLinkOutput externalLinkOutput =
new TestDeprecatedExternalLinkOutput();
final VDXMLExternalLinkMenuItemRenderer renderer =
new VDXMLExternalLinkMenuItemRenderer(externalLinkOutput,
spanMenuItemRenderer);
// Do a render.
final String actualNormal = getRenderOutputAsString(renderer, item,
"[test delegate]");
//System.out.println(actualNormal);
final String actualExternal = externalLinkOutput.getResult();
//System.out.println(actualExternal);
// Assemble the expected value which was rendered normally.
String expectedNormal;
// If we have a span renderer
if (spanMenuItemRenderer != null) {
// then it should render something.
expectedNormal =
"<span " +
// "class=\"the style class\"" + " " +
">" +
"[test delegate]" +
"</span>";
expectedNormal = DOMUtilities.provideDOMNormalizedString(
expectedNormal);
} else {
// otherwise it can't render the span.
expectedNormal = "[test delegate]" ;
}
// Compare the expected value we calculated with the actual value
// which was rendered.
assertEquals("Normal not as expected",
expectedNormal, actualNormal);
// Assemble the expected value which was rendered externally.
String expectedExternal =
"<external-link " +
"href=\"" + item.getHref().getURL() + "\" " +
"shortcut=\"" + item.getShortcut().getText(TextEncoding.PLAIN) + "\" " +
// style attributes ignored here
"/>";
expectedExternal = DOMUtilities.provideDOMNormalizedString(
expectedExternal);