Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.DOMOutputBuffer


     * test open pane
     */
    public void testOpenPane() throws RepositoryException {
        privateSetUp();

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

        Element el = null;

        Pane pane = new Pane(null);
        pane.setName(PANE_NAME);
        pane.setBackgroundColour("#ff0000");
        pane.setBorderWidth("15");
        pane.setCellPadding("16");
        pane.setCellSpacing("17");

        final String cssValues = "background-color: #ff00ff; " +
                        "border-width: 5px; " +
                        "border-spacing: 7px";

        PaneAttributes attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getStyles(cssValues));
        attributes.setPane(pane);

        protocol.openPane(buffer, attributes);
        try {
            el = buffer.closeElement("td");
        } catch (IllegalStateException ise) {
            fail("td element not found.");
        }

        //@todo add actual tests.
View Full Code Here


        //@todo add actual tests.
    }

    public void testOpenPaneWithContainerCell() throws Exception {
        privateSetUp();
        DOMOutputBuffer dom = new DOMOutputBuffer();

        dom.initialise();

        dom.openElement("td");

        Pane pane1 = new Pane(null);
        pane1.setName(PANE_NAME);
        PaneAttributes attributes = new PaneAttributes();
        attributes.setStyles(StylesBuilder.getStyles(
                "background-color: #ff0000; border-width: 5px"));
        attributes.setPane(pane1);
        // Setting the border width to 5 will render the pane as a table
        // because the pane has no style class.

        protocol.setMarinerPageContext(context);
        protocol.openPane(dom, attributes);

        try {
            dom.closeElement("td");
            dom.closeElement("tr");
            dom.closeElement("table");
        } catch (IllegalStateException e) {
            fail("Expected table/tr/td elements not found");
        }

    }
View Full Code Here

     * test for the openDissectingPane method
     */
    public void testOpenDissectingPane() throws RepositoryException {
        privateSetUp();

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

        String inclusionPath = "TestInclusionPath";
        String paneName = "TestPaneName";
        String nextShortcut = "TestNextShardShortcut";
        String nextLink = "TestNextShardLink";
        String nextClass = "TestNextShardLinkClass";
        String prevShortcut = "TestPreviousShardShortcut";
        String prevLink = "TestPreviousShardLink";
        String prevClass = "TestPreviousShardLinkClass";
        String maxContentSize = "100";
        boolean nextLinkFirst = true;

        DissectingPane pane = new DissectingPane(canvasLayout);
        pane.setName(paneName);
        pane.setAttribute(FormatConstants.NEXT_SHARD_SHORTCUT_ATTRIBUTE,
                          nextShortcut);
        pane.setAttribute(FormatConstants.NEXT_SHARD_LINK_TEXT_ATTRIBUTE,
                          nextLink);
        pane.setAttribute(FormatConstants.NEXT_SHARD_LINK_CLASS_ATTRIBUTE,
                          nextClass);
        pane.setAttribute(FormatConstants.PREVIOUS_SHARD_SHORTCUT_ATTRIBUTE,
                          prevShortcut);
        pane.setAttribute(FormatConstants.PREVIOUS_SHARD_LINK_TEXT_ATTRIBUTE,
                          prevLink);
        pane.setAttribute(FormatConstants.PREVIOUS_SHARD_LINK_CLASS_ATTRIBUTE,
                          prevClass);
        pane.setAttribute(FormatConstants.MAXIMUM_CONTENT_SIZE_ATTRIBUTE, maxContentSize);

        DissectingPaneAttributes atts = new DissectingPaneAttributes();
        atts.setDissectingPane(pane);
        atts.setInclusionPath(inclusionPath);
        atts.setIsNextLinkFirst(nextLinkFirst);

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

        if (protocol.isDissectionSupported()) {
            Element el = null;
            try {
                el = buffer.closeElement
                    (DissectionConstants.DISSECTABLE_CONTENTS_ELEMENT);
            } catch (IllegalStateException ise) {
                fail(DissectionConstants.DISSECTABLE_CONTENTS_ELEMENT +
                " element not found.");
            }

            // check that all the attributes have been written out
            assertEquals("Invalid inclusion path attribute",
                    el.getAttributeValue
                    (DissectionConstants.INCLUSION_PATH_ATTRIBUTE),
                    atts.getInclusionPath());

            assertEquals("Invalid pane name attribute",
                    el.getAttributeValue
                    (DissectionConstants.DISSECTING_PANE_NAME_ATTRIBUTE),
                    atts.getDissectingPane().getName());

            assertEquals("Invalid next shard shortcut attribute",
                    el.getAttributeValue
                    (DissectionConstants.NEXT_SHARD_SHORTCUT_ATTRIBUTE),
                    nextShortcut);

            assertEquals("Invalid next shard link attribute",
                    el.getAttributeValue
                    (DissectionConstants.NEXT_SHARD_LINK_TEXT_ATTRIBUTE),
                    nextLink);

            assertEquals("Invalid previous shortcut attribute",
                    el.getAttributeValue
                    (DissectionConstants.PREVIOUS_SHARD_SHORTCUT_ATTRIBUTE),
                    prevShortcut);

            assertEquals("Invalid previous link attribute",
                    el.getAttributeValue
                    (DissectionConstants.PREVIOUS_SHARD_LINK_TEXT_ATTRIBUTE),
                    prevLink);

            assertEquals("Invalid next link first attribute",
                    el.getAttributeValue
                    (DissectionConstants.GENERATE_NEXT_LINK_FIRST_ATTRIBUTE),
                    String.valueOf(nextLinkFirst));

            assertEquals("Invalid max contents attribute",
                    el.getAttributeValue
                    (DissectionConstants.MAXIMUM_CONTENT_SIZE_ATTRIBUTE),
                    maxContentSize);
        } else {
            assertTrue("Protocol does not support dissection so no markup " +
                    "should have been generated", buffer.isEmpty());
        }
    }
View Full Code Here

    }

    public void testShardLinkStyleClass() throws Exception {
        privateSetUp();

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        ShardLinkAttributes attributes = new ShardLinkAttributes();
        Element anchor;
        Node node;
        String styleClass;

        buffer.initialise();
        attributes.setHref("http://www.volantis.com/page");
        attributes.setLinkText("Next");
        attributes.setShortcut("N");
        // todo XDIME-CP style dissection correctly.
//        attributes.setStyleClass("shardlink");

        protocol.doShardLink(buffer, attributes);

        node = buffer.getCurrentElement().getHead();

        assertNotNull("Should have found a node", node);

        assertTrue("Node should be an element",
                node instanceof Element);
View Full Code Here

     * test the getFormatStyleClass method.
     */
    public void notestGetFormatStyleClass() throws Exception {
        privateSetUp();

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

        // Demonstrate that this device layout isn't used
        context.setDeviceLayout(null);

//        context.setStyleClassName(CLASS_NAME);
View Full Code Here

    /**
     * Test that we are rendering the type of action inputs properly.
     */
    protected void checkActionInputType() throws ProtocolException {

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        // Setup test for normal behaviour for input tag generation (submit)
        String name = "My Name";
        String actionType = "submit";
        String caption = "This is my caption";
        String value = "This is my value";

        attributes.setName(name);
        attributes.setType(actionType);
        attributes.setCaption(new LiteralTextAssetReference(caption));
        attributes.setValue(value);

        protocol.doActionInput(buffer, attributes);
        String actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" type=\"submit\" "+
                "value=\"" + caption + "\"/>", actualResult);

        // Setup test for normal behaviour for input tag generation (perform)
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "perform";
        attributes.setType(actionType);       
        protocol.doActionInput(buffer, attributes);
        actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
                "type=\"submit\" value=\"" + caption  + "\"/>",
                actualResult);

        // Setup test for normal behaviour for input tag generation (perform)
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "reset";
        attributes.setType(actionType);
        protocol.doActionInput(buffer, attributes);
        actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
                "type=\"reset\" value=\"" + caption  + "\"/>",
                actualResult);

        // Setup test for abnormal behaviour - garbage actionType
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "GARBAGE";
        attributes.setType(actionType);
        try {
            protocol.doActionInput(buffer, attributes);
            fail("Should have thrown an IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

        // Setup test for abnormal behaviour - garbage actionType
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "submit";
        attributes.setType(actionType);
        attributes.setTabindex("1");
        protocol.doActionInput(buffer, attributes);
        assertTrue(protocol.supportsTabindex);
View Full Code Here

        String name = "My Name";
        String actionType = "submit";
        String caption = "The caption";
        String value = "This is my value";

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

        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        attributes.setName(name);
View Full Code Here

        }
    }

    protected void checkActionInputShortcut() throws ProtocolException {

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        // Setup test for normal behaviour for input tag generation (submit)
        String shortcut = "1";
View Full Code Here

        //           entryBuffer == captionBuffer != null
        selector = protocol.createBufferSelector(
                entry, caption, null, null, null);
        doTestBufferSelector(selector, caption, entry, true, true, false);

        DOMOutputBuffer dom = new DOMOutputBuffer();
        selector = protocol.createBufferSelector(
                null, null, null, null, dom);
        doTestBufferSelector(selector, null, null, true, true, true);

        DOMOutputBuffer entryBuffer = new DOMOutputBuffer();
        DOMOutputBuffer captionBuffer = new DOMOutputBuffer();
        selector = protocol.createBufferSelector(
                null, null, null, captionBuffer, null);
        doTestBufferSelector(selector, null, null, true, true, true);

        selector = protocol.createBufferSelector(
View Full Code Here

    /**
     * Test the method doImage
     */
    public void testDoImage() throws Exception {
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        // Needed to allow the call to getTextFromReference within doImage to work
        context = new TestMarinerPageContext();

        protocol.setMarinerPageContext(context);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.DOMOutputBuffer

Copyright © 2018 www.massapicom. 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.