Examples of DOMOutputBuffer


Examples of com.volantis.mcs.protocols.DOMOutputBuffer

    /**
     * Test the doMenuItem method to ensure that menu items are being correctly
     * processed.
     */
    public void testDoMenuItem() throws Exception {
        DOMOutputBuffer buffer = getNewDOMOutputBuffer();

        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);
        actual = DOMUtilities.toString(
                buffer.getRoot(), protocol.getCharacterEncoder());

        assertEquals("the processed DOM is not as expected.",
                     expectedDOMAsString, actual);
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

    /**
     * Test the protocols doImplicitValue
     */
    public void testDoImplicitValue() throws Exception {
        DOMOutputBuffer buffer = getNewDOMOutputBuffer();

        TestMarinerPageContext context = new TestMarinerPageContext();
        protocol.setMarinerPageContext(context);

        XMLReader reader = DOMUtilities.getReader();

        XFImplicitAttributes attributes = new XFImplicitAttributes();
        final String xfName = "xfImplicitAtributesName";
        final String xfValue = "xfImplicitAtributesValue";
        attributes.setName(xfName);
        attributes.setValue(xfValue);

        XFFormAttributes formAttributes = new XFFormAttributes();
        String name = "This is the name";
        formAttributes.setName(name);
        Form form = new Form(new CanvasLayout());
        FormInstance formInstance = new FormInstance(
                NDimensionalIndex.ZERO_DIMENSIONS);
        formInstance.setFormat(form);

        formAttributes.setFormData(formInstance);
        attributes.setFormAttributes(formAttributes);
        attributes.setFormData(formInstance);

        protocol.doImplicitValue(attributes);

        String actual = DOMUtilities.toString(
                buffer.getRoot(), protocol.getCharacterEncoder());

        String expected = "<var expr=\"'" + xfValue +
            "'\" name=\"" + xfName + "\"/>";
        Document expectedDom = DOMUtilities.read(reader, expected);
        String expectedDOMAsString =
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

                                 "</sayas></prompt></block>",
                                 "string");
    }

    public void testAddPhoneNumberContentsPopulatedDom() throws Exception {
        DOMOutputBuffer contentDom = new DOMOutputBuffer();
        contentDom.initialise();
        contentDom.openElement("content");
        contentDom.addElement("example");
        contentDom.appendEncoded("with text");
        contentDom.closeElement("content");

        doPhoneNumberContentTest(contentDom,
                                 "<block><prompt><content>" +
                                 "<example/>with text</content>" +
                                 "<sayas class=\"literal\">" + phoneNumber +
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

                                 "</sayas></prompt></block>",
                                 "DOM");
    }

    public void testAddPhoneNumberContentsEmptyDom() throws Exception {
        DOMOutputBuffer contentDom = new DOMOutputBuffer();
        contentDom.initialise();

        doPhoneNumberContentTest(contentDom,
                                 "<block><prompt>" +
                                 "<sayas class=\"literal\">" + phoneNumber +
                                 "</sayas></prompt></block>",
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     * @throws ProtocolException
     */
    public void testAnchorNameIdentification() throws ProtocolException, RepositoryException {
        // Set up the protocol and dependent objects.
        privateSetUp();
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        // Initialise our protocol attributes with an id attribute.
        String idValue = "the identifier value";
        AnchorAttributes attributes = new AnchorAttributes();
        attributes.setId(idValue);

        // Create the expected value for the name attribute output.
        String expectedNameValue = null;
        if (protocol.enableNameIdentification) {
            expectedNameValue = idValue;
        }

        // Open and close the anchor to generate the markup.
        protocol.openAnchor(buffer, attributes);
        protocol.closeAnchor(buffer, attributes);

        // Check that the element generated has appropriate id and name
        // attributes.
        Element root = buffer.getCurrentElement();
        Element element = (Element) root.getHead();
//        // Handle the case where some protocols wrap the tag in another tag.
//        if (!element.getName().equals("a")) {
//            element = (Element) element.getHead();
//        }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

    /**
     * Check encoding from the quote table
     */
    public void testElementEncoding() throws ProtocolException, RepositoryException {
        privateSetUp();
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        buffer.openElement("p");
        buffer.appendEncoded("start ");
        buffer.appendEncoded("\u009f");
        buffer.appendEncoded(VolantisProtocol.NBSP);
        buffer.appendEncoded("\u00a1");
        buffer.appendEncoded(" finish");
        buffer.closeElement("p");

        assertEquals("Incorrect Encoding",
              "<p>start \u009f&nbsp;\u00a1 finish</p>", bufferToString(buffer));
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     * @throws ProtocolException
     */
    public void testImageNameIdentification() throws ProtocolException, RepositoryException {
        // Set up the protocol and dependent objects.
        privateSetUp();
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        // Initialise our protocol attributes with an id attribute.
        String idValue = "the identifier value";
        ImageAttributes attributes = new ImageAttributes();
        attributes.setId(idValue);
        attributes.setSrc("required");

        // Create the expected value for the name attribute output.
        String expectedNameValue = null;
        if (protocol.enableNameIdentification) {
            expectedNameValue = idValue;
        }

        // Oo the image to generate the markup.
        protocol.doImage(buffer, attributes);

        // Check that the element generated has appropriate id and name
        // attributes.
        Element root = buffer.getCurrentElement();
        Element element = (Element) root.getHead();
//        // Handle the case where some protocols wrap the tag in another tag.
//        if (!element.getName().equals("img")) {
//            element = (Element) element.getHead();
//        }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

                = new TestMarinerRequestContext();
        TestMarinerPageContext context = new TestMarinerPageContext();
        context.pushRequestContext(requestContext);
        protocol.setMarinerPageContext(context);

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        context.setCurrentOutputBuffer(buffer);

        SpatialFormatIteratorAttributes attributes =
                new SpatialFormatIteratorAttributes();
        attributes.setStyles(StylesBuilder.getDeprecatedStyles());

        Pane pane = new Pane(canvasLayout);
        attributes.setFormat(pane);

        // Open and then close the row.
        protocol.writeOpenSpatialFormatIteratorRow(attributes);
        protocol.writeCloseSpatialFormatIteratorRow(attributes);

        // Retrieve and test the row's containing tag.
        String containingTag = DOMUtilities.toString(buffer.getRoot());
        assertEquals("Spatial iterator row should be contained within <p> " +
                "tags", containingTag, "<BLOCK/>");
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

        containerInstanceBufferMap.put(containerInstance, buffer);
    }

    protected DOMOutputBuffer getCurrentBuffer(
            ContainerInstance containerInstance) {
        DOMOutputBuffer buffer = (DOMOutputBuffer)
                containerInstanceBufferMap.get(containerInstance);
        return (null != buffer) ? buffer :
                super.getCurrentBuffer(containerInstance);
    }
View Full Code Here

Examples of com.volantis.mcs.protocols.DOMOutputBuffer

     */
    public void testOpenDissectingPane() {
        privateSetUp();

        // Set the protocol to allow tranformations
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        DissectingPaneAttributes atts = setupDissectingPaneTests();

        protocol.setDissecting(true);
        protocol.openDissectingPane(buffer, atts);

        Element el = null;
        try {
            el = buffer.closeElement
                    (DissectionConstants.DISSECTABLE_CONTENTS_ELEMENT);
        } catch (IllegalStateException ise) {
            fail(DissectionConstants.DISSECTABLE_CONTENTS_ELEMENT +
                    " element not found.");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.