Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.TestDOMOutputBuffer


     * This tests the start and end methods with no content between them to
     * ensure correct output generation.
     */
    public void testEmptyStartAndEnd() throws Exception {
        // Create the test buffer
        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        // Create the renderer
        DefaultNumericShortcutEmulationRenderer renderer =
                new DefaultNumericShortcutEmulationRenderer(customisation);

        // Test the start call
        renderer.start(buffer);

        // Test the end call
        renderer.end(buffer);

        // Create expected
        String required = "<" + AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT + "/>";
        String expected = DOMUtilities.provideDOMNormalizedString(required);

        // Check state of buffer
        assertFalse("Should be contents in the buffer", buffer.isEmpty());

        // Extract the output from the menu rendering as a string.
        String actual = DOMUtilities.toString(buffer.getRoot());
        assertNotNull("The actual string should exist", actual);

        // Compare state and expected
        assertEquals("Strings should match", expected, actual);
    }
View Full Code Here


        // Href string
        final String testHref = "/path/to/stuff_here";

        // Create the test buffer
        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        // Create the renderer
        DefaultNumericShortcutEmulationRenderer renderer =
                new DefaultNumericShortcutEmulationRenderer(customisation);

        // Start the call
        renderer.start(buffer);

        // Add some content...
        Element element = buffer.openElement("a");
        element.setAttribute("href", testHref);
        element.setAttribute("accesskey", renderer.getShortcut().getText(TextEncoding.PLAIN));
        buffer.appendEncoded(testContent);
        buffer.closeElement(element);

        // End the call
        renderer.end(buffer);

        // Create expected
        String required = "<" + AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT +
                          "><a href=\"" + testHref + "\" accesskey=\"" +
                          renderer.getShortcut().getText(TextEncoding.PLAIN) + "\">" + testContent +
                          "</a></" + AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT + ">";

        String expected = DOMUtilities.provideDOMNormalizedString(required);

        // Check state of buffer
        assertFalse("Should be contents in the buffer", buffer.isEmpty());

        // Extract the output from the menu rendering as a string.
        String actual = DOMUtilities.toString(buffer.getRoot());
        assertNotNull("The actual string should exist", actual);

        // Compare state and expected
        assertEquals("Strings should match", expected, actual);
    }
View Full Code Here

    private void checkAccessKeyPrefix(boolean autoAccessKeyPrefix)
            throws Exception {

        // Create the test buffer
        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        customisation.setAutomaticallyDisplaysAccessKey(autoAccessKeyPrefix);

        // Create the renderer
        DefaultNumericShortcutEmulationRenderer renderer =
                new DefaultNumericShortcutEmulationRenderer(customisation);

        // Start the call
        renderer.start(buffer);

        // Add some content...
        renderer.outputPrefix(buffer);

        // End the call
        renderer.end(buffer);

        String prefix;
        if (autoAccessKeyPrefix) {
            prefix = "";
        } else {
            prefix = "x";
        }

        // Create expected (note whitespace after prefix will be eaten)
        String required = "<" + AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT +
                          ">" + prefix +
                          "</" + AccesskeyConstants.ACCESSKEY_ANNOTATION_ELEMENT + ">";

        String expected = DOMUtilities.provideDOMNormalizedString(required);

        // Extract the output from the menu rendering as a string.
        String actual = DOMUtilities.toString(buffer.getRoot());

        assertEquals("Access key prefix mismatch", expected, actual);
    }
View Full Code Here

    public TestRendererContext(AssetResolver assetResolver,
                               OutputBufferResolver outputBufferResolver,
                               OutputBufferFactory outputBufferFactory) {

        if (outputBufferResolver == null) {
            DOMOutputBuffer buffer = new TestDOMOutputBuffer();
            outputBufferResolver = new TestOutputBufferResolver(buffer);
        }
        if (outputBufferFactory == null) {
            outputBufferFactory = new TestDOMOutputBufferFactory();
        }
View Full Code Here

     *
     * @param elementDetails The elementDetails to use for the text
     * @return A menu text
     */
    public MenuText createTestMenuText(ElementDetails elementDetails) {
        return createTestMenuText(elementDetails, new TestDOMOutputBuffer());
    }
View Full Code Here

    public static String getRenderOutputAsString(MenuItemComponentRenderer renderer,
                                                 MenuItem item)
            throws RendererException, IOException {

        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();

        renderer.render(buffer, item);

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

        return DOMUtilities.toString(buffer.getRoot());
    }

    protected MenuText createMenuText() {
        ConcreteMenuText text = new ConcreteMenuText(new ElementDetailsStub());
        DOMOutputBuffer textBuffer = new TestDOMOutputBuffer();
        textBuffer.writeText("[text]");
        text.setText(textBuffer);
        return text;
    }
View Full Code Here

     */
    public void testRender() throws Exception {
        String testTextString = "test menu item";

        // Create the test DOM for the text buffer
        TestDOMOutputBuffer textBuffer = new TestDOMOutputBuffer();
        Element b = textBuffer.allocateElement("b");
        Text textElement = domFactory.createText();
        textElement.append(testTextString);
        b.addTail(textElement);
        textBuffer.addElement(b);

        // Create the test text, label, and then the menu item
        MenuText text = entity.createTestMenuText(textBuffer);
        MenuLabel label = entity.createTestMenuLabel(text);
        MenuItem item = entity.createTestMenuItem(label);
View Full Code Here

                              String expected) throws Exception {
        // Surrounding element to allow successful normalization
        String element = "div";

        // Create the test buffer
        TestDOMOutputBuffer testBuffer = new TestDOMOutputBuffer();

        // Start element
        testBuffer.openElement(element);

        // Render using the test buffer
        renderer.render(testBuffer);

        // End element
        testBuffer.closeElement(element);

        // Extract the output from the rendering as a string.
        String actual = DOMUtilities.toString(testBuffer.getRoot());
        assertNotNull("The actual string should exist", actual);

        // Normalise expected - this requires that all input strings contain
        // some markup otherwise the test will fail on this string conversion!
        expected = DOMUtilities.provideDOMNormalizedString("<" + element + ">"
View Full Code Here

     * an i-mode attribute for td.
     */
    public void testStyleVerticalAlignTD() throws Throwable {
        privateSetUp();
        protocol.setMarinerPageContext(pageContext);
        TestDOMOutputBuffer buffer = new TestDOMOutputBuffer();
        buffer.initialise();

        MutablePropertyValues tableCellProperties = createPropertyValues();
        tableCellProperties.setComputedValue(
                StylePropertyDetails.VERTICAL_ALIGN,
                VerticalAlignKeywords.BOTTOM);
View Full Code Here

TOP

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

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.