Package com.volantis.mcs.context

Examples of com.volantis.mcs.context.TestMarinerPageContext


     * Test creation of a script with a null value, should fail.
     *
     * @throws ProtocolException
     */
    public void testCreateNull() throws ProtocolException {
        TestMarinerPageContext context = new TestMarinerPageContext();
        try {
            createScript(context, null);
            fail("None scripts are invalid");
        } catch (NullPointerException e) {
            // Normal
View Full Code Here


     * null value from toString() should fail.
     *
     * @throws ProtocolException
     */
    public void testCreateSimpleNull() throws ProtocolException {
        TestMarinerPageContext context = new TestMarinerPageContext();

        final ScriptAssetReferenceMock scriptMock =
                new ScriptAssetReferenceMock("scriptMock",
                        expectations);
        scriptMock.expects.getScript().returns(null).any();
View Full Code Here

     *
     * @throws ProtocolException
     */
    public void testCreateSimple() throws ProtocolException {
        ScriptAssetReference expected = getDefaultScriptValue();
        TestMarinerPageContext context = new TestMarinerPageContext();
        Script script = createScript(context, expected);
        String actual = script.stringValue();
        assertEquals(expected.getScript(), actual);
    }
View Full Code Here

     * Test the equals method.
     *
     * @throws ProtocolException
     */
    public void testEquals() throws ProtocolException {
        TestMarinerPageContext context = new TestMarinerPageContext();
        ScriptAssetReference scriptObject = getDefaultScriptValue();
        Script script = createScript(context, scriptObject);
        assertTrue(! script.equals(null));
        assertTrue(! script.equals("dummy object"));
       
View Full Code Here

     * @throws ProtocolException
     */
    public void testAppendTo() throws ProtocolException {
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        TestMarinerPageContext context = new TestMarinerPageContext();
        ScriptAssetReference scriptObject = getDefaultScriptValue();
        Script script = createScript(context, scriptObject);
        script.appendTo(buffer);
        Node node = buffer.getRoot().getHead();
        checkAppendToResult(node);
View Full Code Here

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

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

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

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

        TestDeviceLayoutContext deviceLayoutContext =
                new TestDeviceLayoutContext();

        PaneInstance paneInstance = new TestPaneInstance();
        paneInstance.setFormat(testPane);
        paneInstance.setDeviceLayoutContext(deviceLayoutContext);

        deviceLayoutContext.setFormatInstance(testPane,
                NDimensionalIndex.ZERO_DIMENSIONS, paneInstance);
        pageContext.pushDeviceLayoutContext(deviceLayoutContext);
        pageContext.setFormatInstance(paneInstance);

        final PolicyReferenceResolverMock referenceResolverMock =
                new PolicyReferenceResolverMock("referenceResolverMock",
                        expectations);

        referenceResolverMock.expects.resolveQuotedTextExpression(null)
                .returns(null).any();

        pageContext.setPolicyReferenceResolver(referenceResolverMock);

        // set up menu atttributes
        MenuAttributes menuAttrs = new MenuAttributes();
        final String styleClass = "styleClass";
        menuAttrs.setStyleClass(styleClass);
        final String id = "id";
        menuAttrs.setId(id);
        menuAttrs.setPane(pane);

        int result = element.elementStart(requestContext, menuAttrs);

        assertTrue("Unexpected value returned from MenuElement.  Should have" +
                "been PROCESS_ELEMENT_BODY.",
                result == PAPIElement.PROCESS_ELEMENT_BODY);

        // retrieve the menu that was just added to the menuBuilder
        final Menu menu = (Menu)PrivateAccessor.getField(
                pageContext.getMenuBuilder(), "currentEntity");

        assertNotNull("Menu should not be null", menu);
        assertEquals("PAPI and Protocol pane names should match",
                testPane.getName(), menu.getPane().getStem());
View Full Code Here

        RuntimeDeviceLayout runtimeDeviceLayout =
                RuntimeDeviceLayoutTestHelper.activate(layout);

        durationBuffer = new StringBuffer();

        pageContext = new TestMarinerPageContext();
        pageContext.setDeviceLayout(runtimeDeviceLayout);

        dlContext = new MyDeviceLayoutContext(pageContext);

        DOMOutputBuffer buffer = new DOMOutputBuffer();
View Full Code Here

        final MarinerRequestContext requestContext =
                new TestMarinerRequestContext();
        ProtocolBuilder builder = new ProtocolBuilder();
        DOMProtocol protocol = (DOMProtocol) builder.build(
                new TestProtocolRegistry.TestDOMProtocolFactory(), null);
        final TestMarinerPageContext pageContext = new TestMarinerPageContext();

        pageContext.pushRequestContext(requestContext);
        pageContext.setProtocol(protocol);
        pageContext.setPageGenerationCache(new PageGenerationCache());
        pageContext.setRequestURL(
                new MarinerURL("http://server:8080/volantis/test.xdime"));

        final PolicyReferenceResolverMock referenceResolverMock =
                new PolicyReferenceResolverMock("referenceResolverMock",
                        expectations);
        pageContext.setPolicyReferenceResolver(referenceResolverMock);
        referenceResolverMock.expects
                .resolveQuotedLinkExpression(null, PageURLType.FORM)
                .returns(null).any();
        referenceResolverMock.expects.resolveQuotedTextExpression(null)
                .returns(null).any();
        referenceResolverMock.expects
                .resolveQuotedTextExpression("testCaption")
                .returns(new LiteralTextAssetReference("testCaption"))
                .any();

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

        loadStyleSheet(pageContext);

        // a form with a pane in it
        final CanvasLayout canvasLayout =
                new CanvasLayout();
        // Activate the device layout.
        RuntimeDeviceLayout runtimeDeviceLayout =
                RuntimeDeviceLayoutTestHelper.activate(canvasLayout);
        pageContext.setDeviceLayout(runtimeDeviceLayout);

        final Form form = new Form(canvasLayout);
        form.setName("form");
        pageContext.setForm(form);
        FormInstance formInstance = new FormInstance(
                NDimensionalIndex.ZERO_DIMENSIONS);
        formInstance.setFormat(form);
        pageContext.setFormatInstance(formInstance);

        final Pane testPane = new Pane(canvasLayout);
        final String paneName = "testPane";
        testPane.setName(paneName);
        testPane.setParent(form);
        final PaneInstance paneInstance = new TestPaneInstance();
        paneInstance.setFormat(testPane);

        final TestDeviceLayoutContext deviceLayoutContext =
                new TestDeviceLayoutContext();
        paneInstance.setDeviceLayoutContext(deviceLayoutContext);
        pageContext.setFormatInstance(paneInstance);
        pageContext.addPaneMapping(testPane);

        // set up xfform element
        final XFFormAttributes xfFormAttributes = new XFFormAttributes();
        final XFFormElementImpl xfFormElement = new XFFormElementImpl();
        xfFormElement.elementStart(requestContext, xfFormAttributes);
        pageContext.setCurrentElement(xfFormElement);

        // set up xfsiselect element
        final XFSingleSelectElementImpl xfSingleSelectElement =
                new XFSingleSelectElementImpl();
        final XFSingleSelectAttributes xfSingleSelectAttributes =
                new XFSingleSelectAttributes();
        xfSingleSelectAttributes.setCaptionPane(paneName);
        xfSingleSelectElement.elementStart(requestContext,
                xfSingleSelectAttributes);
        pageContext.setCurrentElement(xfSingleSelectElement);

        // set up xfoption element
        XFOptionAttributes xfOptionsAttrs = new XFOptionAttributes();
        final String styleClass = "styleClass";
        xfOptionsAttrs.setStyleClass(styleClass);
View Full Code Here

     */
    private static void setupProtocol(
            ExpectationBuilder expectations, VolantisProtocol protocol)
            throws Exception {
        Volantis volantis = new Volantis();
        TestMarinerPageContext pageContext = new TestMarinerPageContext();
        pageContext.setVolantis(volantis);
        // Initialise the device.
        pageContext.setDeviceName("Unknown Device");
        InternalDevice device = InternalDeviceTestHelper.createTestDevice();
        pageContext.setDevice(device);

        pageContext.setProtocol(protocol);
        // Set the protocols configuration
        ProtocolsConfiguration config = new ProtocolsConfiguration();
        config.setWmlPreferredOutputFormat("wml");
        volantis.setProtocolsConfiguration(config);


        MarinerRequestContext requestContext =
                ProtocolTestAbstract.initialiseMarinerRequestContext(
                        expectations);
        pageContext.pushRequestContext(requestContext);

        protocol.setMarinerPageContext(pageContext);
        protocol.initialise();
        protocol.initialiseCanvas();
        protocol.initialisePageHead();
        protocol.setWriteHead(false);

        StylingFactory stylingFactory = StylingFactory.getDefaultInstance();
        CompilerConfiguration configuration =
                stylingFactory.createCompilerConfiguration();
        configuration.setSource(StyleSheetSource.THEME);
        configuration.addFunctionResolver(StylingFunctions.getResolver());
        StyleSheetCompiler compiler = stylingFactory.createStyleSheetCompiler(
                configuration);
        CompiledStyleSheet compiledStyleSheet = compiler.compileStyleSheet(null);

        DeviceLayoutContext deviceLayoutContext =
                new TestDeviceLayoutContext(pageContext);
        deviceLayoutContext.setMarinerPageContext(pageContext);
        RuntimeDeviceLayout runtimeDeviceLayout = new RuntimeLayoutAdapter(
                "layoutName", new CanvasLayout(), compiledStyleSheet, null);
        deviceLayoutContext.setDeviceLayout(runtimeDeviceLayout);
        deviceLayoutContext.initialise ();

        pageContext.pushDeviceLayoutContext(deviceLayoutContext);
        MarinerURL requestURL = new MarinerURL();
        pageContext.setRequestURL(requestURL);

        // Need to setup a region instance for testing inclusions
        RegionInstance regionInstance =
                new RegionInstance(new NDimensionalIndex(new int[1]));
        regionInstance.setDeviceLayoutContext(deviceLayoutContext);

        pageContext.pushContainerInstance(regionInstance);
    }
View Full Code Here

        // Open the page before the method is invoked ensures that an
        // output buffer is placed on the stack of buffers.
        CanvasAttributes canvasAttributes = new CanvasAttributes();
        protocol.openCanvasPage(canvasAttributes);

        final TestMarinerPageContext pageContext =
            (TestMarinerPageContext)protocol.getMarinerPageContext();
        FormInstance formInstance = new FormInstance(NDimensionalIndex.ZERO_DIMENSIONS) {
            public OutputBuffer getContentBuffer(boolean create) {
                return pageContext.getCurrentOutputBuffer();
            }
        };
        formInstance.setDeviceLayoutContext(pageContext.getDeviceLayoutContext());
        pageContext.setFormatInstance(formInstance);

        invoker.invoke();

        final ByteArrayOutputStream stream = new ByteArrayOutputStream();
        final OutputStreamWriter writer = new OutputStreamWriter( stream );
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.