Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.TestMarinerPageContext


    /**
     * Initialise the context objects that this test uses, including a
     * new TestMarinerPageContext
     */
    private void initialiseContexts() {
        initialiseContexts(new TestMarinerPageContext());
    }
View Full Code Here


            PAPIException {
        //create a page context which does not throw an exception when the
        //peekSelectState method is called. This will act as if there is
        //a value in the stack of SelectState items because otherwise
        //an EmptyStackException would be thrown.
        TestMarinerPageContext pageContext = new TestMarinerPageContext() {
            public SelectState peekSelectState() {
                return null;
            }
        };
        initialiseContexts(pageContext);

        ProtocolBuilder builder = new ProtocolBuilder();
        VolantisProtocol protocol = builder.build(
                new TestProtocolRegistry.VDXMLVersion2_0Factory(),
                InternalDeviceTestHelper.createTestDevice());
        protocol.setMarinerPageContext(pageContext);
        pageContext.setProtocol(protocol);

        attributes.setPane("TestPane");
        attributes.setTargetLocation("pane");

View Full Code Here

            throws RepositoryException, PAPIException {
        //create a page context which does not throw an exception when the
        //peekSelectState method is called. This will act as if there is
        //a value in the stack of SelectState items because otherwise
        //an EmptyStackException would be thrown.
        TestMarinerPageContext pageContext = new TestMarinerPageContext() {
            public SelectState peekSelectState() {
                return null;
            }
        };
        initialiseContexts(pageContext);

        ProtocolBuilder builder = new ProtocolBuilder();
        VolantisProtocol protocol = builder.build(
                new TestProtocolRegistry.TestXHTMLBasicFactory(),
                InternalDeviceTestHelper.createTestDevice());
        protocol.setMarinerPageContext(pageContext);
        pageContext.setProtocol(protocol);

        attributes.setPane("TestPane");
        attributes.setTargetLocation("pane");

View Full Code Here

    public void testXHTMLBasicNativeSupportWithoutSelectItems()
            throws RepositoryException, PAPIException {
        //create a page context which throws an exception when the
        //peekSelectState method is called. This will act as if there are no
        //values in the stack of SelectState items.
        TestMarinerPageContext pageContext = new TestMarinerPageContext() {
            public SelectState peekSelectState() {
                throw new EmptyStackException();
            }
        };
        initialiseContexts(pageContext);

        ProtocolBuilder builder = new ProtocolBuilder();
        VolantisProtocol protocol = builder.build(
                new TestProtocolRegistry.TestXHTMLBasicFactory(),
                InternalDeviceTestHelper.createTestDevice());
        protocol.setMarinerPageContext(pageContext);
        pageContext.setProtocol(protocol);

        attributes.setPane("TestPane");
        attributes.setTargetLocation("pane");

View Full Code Here

     * Set up the member variables required for the tests.
     * @throws Exception if a problem occured setting up the member variables
     */
    protected void setUp() throws Exception {
        super.setUp();
        context = new TestMarinerPageContext();
        context.pushRequestContext(requestContext);
        context.setDeviceName("Master");
        context.pushDeviceLayoutContext(new DeviceLayoutContext());

        internalDevice = InternalDeviceTestHelper.createTestDevice();
View Full Code Here

        // created.
        VolantisProtocolTestable testable = (VolantisProtocolTestable) protocol;
        setTestableProtocol(protocol, testable);
        // Prevent any null pointers when using devices or css emulation
        // as these will be delegated to the page context
        TestMarinerPageContext context = new TestMarinerPageContext();
        context.setDeviceName("Unknown Device");
        context.setDevice(internalDevice);
        MarinerRequestContext requestContext;

//        Volantis volantisBean = new Volantis();
        requestContext = initialiseMarinerRequestContext(expectations);

        context.pushRequestContext(requestContext);
        protocol.setMarinerPageContext(context);
        protocol.initialise();
        context.setProtocol(protocol);
    }
View Full Code Here

    protected void doTest(TestCommand command) throws Exception {
        // Set up the element for testing
        PAPIElement element = createTestablePAPIElement();

        // Set up the common test environment
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        ProtocolBuilder builder = new ProtocolBuilder();
        DOMProtocol protocol = (DOMProtocol) builder.build(
                new TestProtocolRegistry.TestDOMProtocolFactory(),
                InternalDeviceTestHelper.createTestDevice());

        // Set up the protocol (needed for OutputBuffer management)
        // The test implementation avoids the need for an initialized volantis
        // bean, which is jolly handy in this case
        pageContext.setProtocol(protocol);

        // Set the Layout (needed for FormatReference and panes)
        CanvasLayout layout = new CanvasLayout();

        // Activate the device layout.
        RuntimeDeviceLayout runtimeDeviceLayout =
                RuntimeDeviceLayoutTestHelper.activate(layout);

        pageContext.setDeviceLayout(runtimeDeviceLayout);

        final PolicyReferenceResolverMock referenceResolverMock =
                new PolicyReferenceResolverMock("referenceResolverMock",
                        expectations);
        pageContext.setPolicyReferenceResolver(referenceResolverMock);

        // Link everything together
        ContextInternals.setMarinerPageContext(requestContext, pageContext);
        pageContext.pushRequestContext(requestContext);
        protocol.setMarinerPageContext(pageContext);

        // Finally, test the required method
        command.execute(pageContext, element);
    }
View Full Code Here

        // Activate the device layout.
        RuntimeDeviceLayout runtimeDeviceLayout =
                RuntimeDeviceLayoutTestHelper.activate(canvasLayout);

        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        context = new TestMarinerPageContext();
        context.pushRequestContext(requestContext);
        context.setDeviceLayout(runtimeDeviceLayout);
        DeviceLayoutContext deviceContext = new TestDeviceLayoutContext();

        deviceContext.setDeviceLayout(runtimeDeviceLayout);
View Full Code Here

    public void testElementStartAddsStyles() throws Throwable {
        MenuItemGroupElementImpl element =
                (MenuItemGroupElementImpl) createTestablePAPIElement();

        // configure MCS
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        MarinerRequestContext requestContext = new TestMarinerRequestContext();
        ProtocolBuilder builder = new ProtocolBuilder();
        DOMProtocol protocol = (DOMProtocol) builder.build(
                new TestProtocolRegistry.TestDOMProtocolFactory(),
                InternalDeviceTestHelper.createTestDevice());

        pageContext.pushRequestContext(requestContext);
        pageContext.setProtocol(protocol);

        ContextInternals.setMarinerPageContext(requestContext, pageContext);
        protocol.setMarinerPageContext(pageContext);

        // pane setup required by #exprElementStart
        Pane testPane =
                new Pane(new CanvasLayout());
        final String pane = "testPane";
        testPane.setName(pane);
        pageContext.addPaneMapping(testPane);

        PaneInstance paneInstance = new TestPaneInstance();
        paneInstance.setFormat(testPane);
        TestDeviceLayoutContext deviceLayoutContext =
                new TestDeviceLayoutContext();
        deviceLayoutContext.setFormatInstance(testPane,
                NDimensionalIndex.ZERO_DIMENSIONS, paneInstance);
        pageContext.pushDeviceLayoutContext(deviceLayoutContext);
        pageContext.setFormatInstance(paneInstance);

        MenuModelBuilder menuModelBuilder = pageContext.getMenuBuilder();
        //builder#startMenuGroup will fail unless this has been called
        menuModelBuilder.startMenu();

        // set up protocol attributes
        MenuItemGroupAttributes menuItemGroupAttrs =
View Full Code Here

     **/
    private class ElementStartEndInvoker {
        public int invokeElementStartEnd(MarinerRequestContext requestContext,
                                         ReturnsIntInvoker invoker)
                throws PAPIException {
            TestMarinerPageContext pageContext = (TestMarinerPageContext)
                    ((TestMarinerRequestContext) requestContext).getMarinerPageContext();
            VolantisProtocol newProtocol = new VolantisProtocolStub() {
                public void writeOpenSpan(com.volantis.mcs.protocols.SpanAttributes attributes) {
                    writeOpenMarkupHasBeenCalled = true;
                }

                public void writeCloseSpan(com.volantis.mcs.protocols.SpanAttributes attributes) {
                    writeCloseMarkupHasBeenCalled = true;
                }
            };
            VolantisProtocol origProtocol = pageContext.getProtocol();
            pageContext.setProtocol(newProtocol);

            int result = invoker.invoke();

            pageContext.setProtocol(origProtocol);

            return result;

        }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.context.TestMarinerPageContext

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.