Package com.volantis.testtools.mock.method

Examples of com.volantis.testtools.mock.method.MethodAction


        sessionContextMock.expects.getDevice().returns(device);
       
        protocolMock.expects.setMarinerPageContext(context);           
        protocolMock.expects.initialise()
            .does(new MethodAction() {
                public Object perform(MethodActionEvent event) throws Throwable {
                   
                    // Make sure asset resolver has been initialized (VBM 2006032022)
                    assertNotNull(context.getAssetResolver());
                    // Make sure policy ref resolver has been initialized (VBM 2006021602)
View Full Code Here


                .getCommonExpectations(expectations, mockFactory))
                .any();

        deviceLayoutContextMock.expects.allocateOutputBuffer().
            does(
                new MethodAction() {
                    public Object perform(MethodActionEvent event)
                        throws Throwable {
                        return new DOMOutputBuffer();
                    }
                }).any();
View Full Code Here

    public void testMaxAge() {
        final SystemClockMock clockMock =
            new SystemClockMock("clockMock", expectations);
        final Time[] time =
            new Time[]{Time.inMilliSeconds(System.currentTimeMillis())};
        clockMock.expects.getCurrentTime().does(new MethodAction(){
                public Object perform(final MethodActionEvent event) {
                    return time[0];
                }
            }).any();
        final ResponseCachingDirectives rcd =
View Full Code Here

    public void testExpires() {
        final SystemClockMock clockMock =
            new SystemClockMock("clockMock", expectations);
        final Time[] time =
            new Time[]{Time.inMilliSeconds(System.currentTimeMillis())};
        clockMock.expects.getCurrentTime().does(new MethodAction(){
                public Object perform(final MethodActionEvent event) {
                    return time[0];
                }
            }).any();
        final ResponseCachingDirectives rcd =
View Full Code Here

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        valueCompilerMock.fuzzy.compile(mockFactory.expectsAny())
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        return event.getArgument(StyleValue.class);
                    }
                }).any();
View Full Code Here

        // =====================================================================
        //   Set Expectations
        // =====================================================================

        valueCompilerMock.fuzzy.compile(mockFactory.expectsAny())
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        return event.getArgument(StyleValue.class);
                    }
                }).any();
View Full Code Here

        final AssetResolverMock assetResolverMock =
            new AssetResolverMock("assetResolverMock", expectations);

        policyReferenceFactoryMock.fuzzy.createLazyNormalizedReference(
            runtimeProjectMock, null, mockFactory.expectsInstanceOf(String.class),
            PolicyType.SCRIPT).does(new MethodAction(){
            public Object perform(MethodActionEvent event) throws Throwable {
                final String url = (String) event.getArguments()[2];
                if (url.startsWith("URL")) {
                    return urlRuntimePolicyReferenceMock;
                } else {
                    return noUrlRuntimePolicyReferenceMock;
                }
            }
        }).any();

        final SelectedVariantMock selectedVariantMock =
            new SelectedVariantMock("selectedVariantMock", expectations);
        selectedVariantMock.expects.getOldObject().does(new MethodAction(){
            public Object perform(MethodActionEvent event) throws Throwable {
                return new ScriptAsset("name", "deviceName",
                    "programmingLanguage", "mimeType", "characterSet",
                    ScriptAsset.URL, "assetGroupName", "value");
            }}).any();

        assetResolverMock.expects.selectBestVariant(
            urlRuntimePolicyReferenceMock, null).returns(selectedVariantMock).any();

        assetResolverMock.expects.selectBestVariant(
            noUrlRuntimePolicyReferenceMock, null).returns(null).any();
        assetResolverMock.expects.computeURLAsString(selectedVariantMock).
            returns("url-for-the-script-variant").any();
        assetResolverMock.expects
            .rewriteURLWithPageURLRewriter("url-for-the-script-variant", PageURLType.SCRIPT)
            .returns("url-for-the-script-variant").any();

        final DOMProtocol protocol = createProtocol();

        requestContextMock.expects.
            getMarinerPageContext().returns(pageContextMock).any();

        final StylingEngine stylingEngine = getStylingEngine();

        final PaneInstanceMock paneInstance = getPaneInstance();

        pageContextMock.expects.enteringXDIMECPElement().any();
        pageContextMock.expects.insideXDIMECPElement().returns(false).any();
        pageContextMock.expects.exitingXDIMECPElement().any();
        pageContextMock.expects.getStylingEngine().returns(stylingEngine).any();
        pageContextMock.expects.getCurrentContainerInstance().
            returns(paneInstance).any();
        pageContextMock.expects.initialisedCanvas().returns(true).any();
        pageContextMock.expects.getProtocol().returns(protocol).any();
        pageContextMock.fuzzy.pushOutputBuffer(
            mockFactory.expectsInstanceOf(DOMOutputBuffer.class)).does(
                new MethodAction() {
                    public Object perform(MethodActionEvent event)
                        throws Throwable {
                        Object buffer = event.getArgument(OutputBuffer.class);

                        outputBufferStack.push(buffer);

                        return null;
                    }
                }).any();
        pageContextMock.fuzzy.popOutputBuffer(
            mockFactory.expectsInstanceOf(DOMOutputBuffer.class)).does(
                new MethodAction() {
                    public Object perform(MethodActionEvent event)
                        throws Throwable {

                        return outputBufferStack.pop();
                    }
                }).any();
        pageContextMock.expects.getCurrentOutputBuffer().does(
            new MethodAction() {
                public Object perform(MethodActionEvent event) throws Throwable {
                    return outputBufferStack.peek();
                }
            }).any();
        pageContextMock.expects.getVolantisBean().returns(volantisBeanMock).any();
View Full Code Here

        pageContext.expects.getVolantisBean().returns(setupVolantis()).any();

        pageContext.fuzzy.pushDeviceLayoutContext(
                mockFactory.expectsInstanceOf(DeviceLayoutContext.class))
                .does(new MethodAction() {

                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        deviceLayoutContext = (DeviceLayoutContext)
                                event.getArgument(DeviceLayoutContext.class);
View Full Code Here

         * Set expectations on MarinerPageContext Mock
         */
        marinerPageContextMock.expects.getRequestURL(false).returns(
            requestURL).any();

        marinerPageContextMock.expects.getDeviceLayoutContext().does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                Object result = null;
                if (!deviceLayoutContextStack.empty()) {
                    result = deviceLayoutContextStack.peek();
                }
                return result;
            }
        }).any();
        marinerPageContextMock.fuzzy.pushDeviceLayoutContext(
            mockFactory.expectsInstanceOf(DeviceLayoutContext.class))
            .does(new MethodAction() {
                public Object perform(MethodActionEvent event)
                    throws Throwable {
                    Object context = event.getArgument(
                        DeviceLayoutContext.class);

                    deviceLayoutContextStack.push(context);
                    return null;
                }
            }).any();
        // optional for XDIME2
        marinerPageContextMock.expects.setCanvasHasChildren(false).any();
        marinerPageContextMock.fuzzy.getFormatInstance(
            mockFactory.expectsInstanceOf(Pane.class),
            NDimensionalIndex.ZERO_DIMENSIONS)
            .returns(paneInstance)
            .any();

        InternalProjectFactory factory =
                InternalProjectFactory.getInternalInstance();

//        ProjectMock project = new ProjectMock("project mock", expectations);
        final RuntimeProjectMock project =
                new RuntimeProjectMock("projectMock", expectations);
        project.expects.getPolicySource()
                .returns(factory.createXMLPolicySource(null, ".")).any();

        MethodAction initialiseCanvasAction = new MethodAction() {

            public Object perform(MethodActionEvent event) throws Throwable {
                // Optional for XDIME2.
                marinerPageContextMock.expects.initialisedCanvas().returns(true).any();
                return null;
            }
        };
        marinerPageContextMock.fuzzy.initialise(Boolean.FALSE,
                Boolean.FALSE,
                null,
                null,
                mockFactory.expectsInstanceOf(CompiledStyleSheetCollection.class),
                LAYOUT_NAME).does(initialiseCanvasAction);

        marinerPageContextMock.expects.peekCanvasType().does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                Object result = null;
                if (!canvasTypeStack.empty()) {
                    result = canvasTypeStack.peek();
                }
                return result;
            }
        }).any();
        marinerPageContextMock.expects.popCanvasType().does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                Object result = null;
                if (!canvasTypeStack.empty()) {
                    result = canvasTypeStack.pop();
                }
                return result;
            }
        }).any();
        marinerPageContextMock.fuzzy.pushCanvasType(
            mockFactory.expectsInstanceOf(String.class))
            .does(new MethodAction() {
                public Object perform(MethodActionEvent event)
                    throws Throwable {
                    Object context = event.getArgument(String.class);

                    canvasTypeStack.push(context);
                    return null;
                }
            }).any();


        // Since we have pane set for XDIMECP via cdm:pane and for XDIME2 via
        // mcs-container these two will be called twice as we cannot vary the
        // stylesheet per test.
        marinerPageContextMock.expects.pushContainerInstance(paneInstance).any();
        marinerPageContextMock.expects.popContainerInstance(paneInstance).any();

        marinerPageContextMock.expects.getCurrentContainerInstance().returns(paneInstance).any();
        marinerPageContextMock.expects.getCurrentPane().returns(pane).any();

        marinerPageContextMock.expects.updateFragmentationState();
        marinerPageContextMock.expects.getProtocol().returns(protocol).any();
        marinerPageContextMock.expects.getDeviceName().returns("Master");
        marinerPageContextMock.expects.getDevice().returns(device).any();

        // optional for XDIME1?
        marinerPageContextMock.fuzzy.getFormat("pane",
                mockFactory.expectsInstanceOf(FormatNamespace.class))
                .returns(pane).any();
        // optional for XDIME2.
        marinerPageContextMock.expects.getPane("pane").returns(pane).any();
        marinerPageContextMock.fuzzy.pushOutputBuffer(
            mockFactory.expectsInstanceOf(DOMOutputBuffer.class))
            .does(new MethodAction() {
                public Object perform(MethodActionEvent event)
                    throws Throwable {
                    Object buffer = event.getArgument(OutputBuffer.class);

                    outputBufferStack.push(buffer);

                    return null;
                }
            }).any();
        marinerPageContextMock.fuzzy.popOutputBuffer(
            mockFactory.expectsInstanceOf(DOMOutputBuffer.class))
            .does(new MethodAction() {
                public Object perform(MethodActionEvent event)
                    throws Throwable {

                    return outputBufferStack.pop();
                }
            }).any();
        marinerPageContextMock.expects.getCurrentOutputBuffer().does(new MethodAction() {

            public Object perform(MethodActionEvent event) throws Throwable {
                return outputBufferStack.peek();
            }
        }).any();

        RuntimeDeviceTheme runtimeDeviceTheme = createRuntimeDeviceTheme();

        marinerPageContextMock.expects.retrieveThemeStyleSheet(THEME_NAME).
            returns(runtimeDeviceTheme.getCompiledStyleSheet());
       
        marinerPageContextMock.expects.enteringXDIMECPElement().any();
        marinerPageContextMock.expects.insideXDIMECPElement()
                .returns(false).any();
        marinerPageContextMock.expects.exitingXDIMECPElement().any();
        marinerPageContextMock.expects.getEnclosingRegionInstance()
                .returns(null).any();
        marinerPageContextMock.expects.popDeviceLayoutContext()
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent methodActionEvent)
                            throws Throwable {

                        // Don't actually pop this as it prevents the markup
                        // from being generated at the end. NASTY.
View Full Code Here

        mediaAgentMock.fuzzy
            .requestURL(
                mockFactory.expectsInstanceOf(Request.class),
                mockFactory.expectsInstanceOf(ResponseCallback.class))
            .does(
                new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        ResponseCallback callback = (ResponseCallback) event
                                .getArgument(ResponseCallback.class);
View Full Code Here

TOP

Related Classes of com.volantis.testtools.mock.method.MethodAction

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.