TestMarinerPageContext context = new TestMarinerPageContext();
protocol.setMarinerPageContext(context);
XMLReader reader = DOMUtilities.getReader();
MenuItem item1 = new MenuItem();
item1.setText("Website Index.");
item1.setHref("http://www.volantis.com/index.jsp");
item1.setShortcut(new LiteralTextAssetReference("9"));
MenuAttributes attributes = new MenuAttributes();
attributes.setManualDTMF(true);
protocol.doMenuItem(buffer, attributes, item1);
String actual = DOMUtilities.toString(
buffer.getRoot(), protocol.getCharacterEncoder());
String expected = "<choice next=\"http://www.volantis.com/index." +
"jsp\" dtmf=\"9\">Website Index.</choice>";
Document expectedDom = DOMUtilities.read(reader, expected);
String expectedDOMAsString =
DOMUtilities.toString(
expectedDom, protocol.getCharacterEncoder());
assertEquals("the processed DOM is not as expected.",
expectedDOMAsString, actual);
// Same again but with manualDTMF set to false.
buffer = getNewDOMOutputBuffer();
expected = "<choice next=\"http://www.volantis.com/index.jsp\">" +
"Website Index.</choice>";
expectedDom = DOMUtilities.read(reader, expected);
expectedDOMAsString = DOMUtilities.toString(
expectedDom, protocol.getCharacterEncoder());
attributes.setManualDTMF(false);
protocol.doMenuItem(buffer, attributes, item1);
actual = DOMUtilities.toString(
buffer.getRoot(), protocol.getCharacterEncoder());
assertEquals("the processed DOM is not as expected.",
expectedDOMAsString, actual);
// With a prompt in the source this time. Demonstrates that the text
// attribute is overriden by the prompt attribute.
buffer = getNewDOMOutputBuffer();
MenuItem item2 = new MenuItem();
item2.setText("Website Index.");
item2.setHref("http://www.volantis.com/index.jsp");
item2.setPrompt(new LiteralTextAssetReference("<prompt><audio src=\"rtsp://www.volantis" +
".com/mysticmeg.wav\">Mystic Megs Astrology</audio>" +
"</prompt>"));
expected = "<choice next=\"http://www.volantis.com/index.jsp\">" +
"<prompt><audio src=\"rtsp://www.volantis.com/mysticmeg" +
".wav\">Mystic Megs Astrology</audio></prompt></choice>";
expectedDom = DOMUtilities.read(reader, expected);
expectedDOMAsString = DOMUtilities.toString(
expectedDom, protocol.getCharacterEncoder());
attributes.setManualDTMF(true);
protocol.doMenuItem(buffer, attributes, item2);
actual = DOMUtilities.toString(
buffer.getRoot(), protocol.getCharacterEncoder());
assertEquals("the processed DOM is not as expected.",
expectedDOMAsString, actual);
// Null Href - there should be no output from the doMenuItem method.
buffer = getNewDOMOutputBuffer();
MenuItem item3 = new MenuItem();
item3.setText("Some arbitrary text.");
item3.setShortcut(new LiteralTextAssetReference("5"));
expectedDOMAsString = "";
attributes.setManualDTMF(true);
protocol.doMenuItem(buffer, attributes, item3);