Package com.volantis.testtools.mock.method

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


        final MockFactory mf = MockFactory.getDefaultInstance();

        // use a vector as we need to return an enumeration for calls to
        // getHeaderNames()
        final Map params = new HashMap();
        request.fuzzy.getParameter(mf.expectsAny()).does(new MethodAction(){
            public Object perform(MethodActionEvent event) throws Throwable {
                return params.get(event.getArguments()[0]);
            }
        }).any();

        StringBuffer url = new StringBuffer(pathInfo);
        char c = '?';
        if (parameters != null) {
            url.append('/');
            for (int i = 0; i < parameters.length; i++) {
                if (parameters[i].length != 2) {
                    throw new IllegalArgumentException(
                        "Supplied parameter " +
                        i +
                        " has incorrect " +
                        "length: expected 2 got " +
                        parameters[i].length);
                }
                url.append(c).append(parameters[i][0]).append("=").append(parameters[i][1]);
                c = '&';
                params.put(parameters[i][0], parameters[i][1]);
            }
        }

        // Hack to enable gif support without having a config file.
        if (enableGif) {
            params.put("v.gifEnabled", "true");
            url.append(c).append("v.gifEnabled=true");
        }

        request.expects.getParameterNames().does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                return Collections.enumeration(params.keySet());
            }
        }).any();
View Full Code Here


        }

        // Perform the action here, rather than while processing events so
        // that the expectation will be satisfied before any additional
        // events are generated by this action.
        MethodAction action = ((MethodInvocationEvent) methodCall).getAction();
        if (action != null) {
            return action.perform(methodCall);
        }

        return null;
    }
View Full Code Here

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

        final String ref = "ref";
        contextMock.fuzzy.setProperty(Script.class,
                mockFactory.expectsAny(), Boolean.FALSE).does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        Script script = (Script) event.getArgument("value",
                                Object.class);
View Full Code Here

    protected void expectAddSimpleElementProcess(
            final DerivableHTTPMessageEntity entity) {

        dynamicProcessMock.fuzzy.addProcess(mockFactory.expectsAny())
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        SimpleElementProcess process =
                                (SimpleElementProcess)
                                event.getArgument(XMLProcess.class);
View Full Code Here

     * Add an expectation that the dynamic process will receive an error and
     * throw it.
     */
    protected void addExpectErrorAndThrow() {
        dynamicProcessMock.fuzzy.error(mockFactory.expectsAny())
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        Throwable t = (Throwable) event.getArgument(
                                SAXParseException.class);
                        throw t;
View Full Code Here

        // ==================================================================
        // Create expectations.
        // ==================================================================

        // Create an action which fakes the iteration.
        MethodAction action = new OutputStylesIterateMethodAction() {
            public void iterate(PseudoStylePathIteratee iteratee) {
                iteratee.next(pseudoStylePathMock);
            }
        };
        outputStylesMock.fuzzy.iterate(mockFactory.expectsInstanceOf(
View Full Code Here

        //
        // For piece of mind we will get our WritableCSSEntityMock to actually
        // write something to its supplied writer. That way we know for sure
        // that the servlet works end to end.
        //
        writableCSSEntityMock.expects.write(printWriter).does(new MethodAction() {
            public Object perform(MethodActionEvent event) throws Throwable {
                Writer pw = (Writer) event.getArgument(Writer.class);
                pw.write("foo");
                return null;
            }
View Full Code Here

        dependencies = new Dependency[1];
        pipelineContextMock.expects.getDependencyContext().returns(
            dependencyContextMock).any();
        final MockFactory mockFactory = MockFactory.getDefaultInstance();
        dependencyContextMock.fuzzy.addDependency(
            mockFactory.expectsAny()).does(new MethodAction() {
                public Object perform(MethodActionEvent event) throws Throwable {
                    assertNull(dependencies[0]);
                    dependencies[0] = (Dependency) event.getArguments()[0];
                    return null;
                }
View Full Code Here

        deltaMock.expects.iterator().returns(deltaStylerList.iterator());
        listMock.expects.listIterator().returns(listStylerList.listIterator());
        // dodgy merge adds them back in again.
        listMock.fuzzy.append(mockFactory.expectsInstanceOf(Styler.class))
                .does(new MethodAction() {
                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        listStylerList.add(event.getArgument(Styler.class));
                        return null;
                    }
View Full Code Here

        deviceMock.expects.getName().returns("mock").any();

        deviceMock.expects.getProtocolConfiguration().returns(null);
        deviceMock.fuzzy.setProtocolConfiguration(
                mockFactory.expectsInstanceOf(ProtocolConfiguration.class))
                .does(new MethodAction() {

                    public Object perform(MethodActionEvent event)
                            throws Throwable {
                        configuration = (ProtocolConfiguration)
                                event.getArgument(Object.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.