Examples of MappedContext


Examples of ar.com.dgarcia.javaspec.impl.context.MappedContext

        assertThat(context.<Integer>get("foo")).isEqualTo(3);
    }

    @Test
    public void itShouldAllowVariableDefinitionInDifferentContexts() {
        MappedContext otherContext = MappedContext.create();

        context.letFoo(()-> 1);
        sharedVariable.set(otherContext);
        context.letFoo(()-> 2);
View Full Code Here

Examples of ar.com.dgarcia.javaspec.impl.context.MappedContext

    /**
     * Creates a new context to run given code, restoring shared context to previous value after execution
     * @param codeToRun Code to run in own context
     */
    private void runWithOwnSubContext(Runnable codeToRun) {
        MappedContext testRunContext = MappedContext.create();
        testRunContext.setParentDefinition(parentContext);

        TestContext previousContext = sharedContext.get();
        sharedContext.set(testRunContext);
        try{
            codeToRun.run();
View Full Code Here

Examples of com.alibaba.citrus.turbine.support.MappedContext

    @Test
    public void controlContext() throws Exception {
        request("action", "context.myAction", "doGetString");

        Context context = new MappedContext();
        context.put("aaa", "sss");
        rundata.pushContext(context);

        module.execute();
        assertLog("actionLog", String.class, "sss");
View Full Code Here

Examples of com.alibaba.citrus.turbine.support.MappedContext

    @Test
    public void context_control() throws Exception {
        getInvocationContext("/app1");
        initRequestContext();

        Context controlContext = new MappedContext();
        getRunData().pushContext(controlContext);

        moduleLoaderService.getModule("control", "rundata.myControl").execute();

        Context context = assertLog("controlLog", Context.class);
View Full Code Here

Examples of com.alibaba.citrus.turbine.support.MappedContext

        Context screenContext = rundata.getContext(componentName);
        final Context callerContext = rundata.getCurrentContext();
        final Set<String> exportVars = params.exportVars == null ? Collections.<String>emptySet() : params.exportVars;

        // create control context
        MappedContext context = new MappedContext(screenContext) {
            @Override
            protected void internalPut(String key, Object value) {
                if (isExport(key)) {
                    callerContext.put(key, value);
                }

                super.internalPut(key, value);
            }

            @Override
            protected void internalRemove(String key) {
                if (isExport(key)) {
                    callerContext.remove(key);
                }

                super.internalRemove(key);
            }

            private boolean isExport(String key) {
                return callerContext != null && (exportAll || exportVars.contains(key));
            }
        };

        // add all params
        context.getMap().putAll(params);

        return context;
    }
View Full Code Here

Examples of com.alibaba.citrus.turbine.support.MappedContext

        Context screenContext = rundata.getContext(componentName);
        final Context callerContext = rundata.getCurrentContext();
        final Set<String> exportVars = params.exportVars == null ? Collections.<String> emptySet() : params.exportVars;

        // create control context
        MappedContext context = new MappedContext(screenContext) {
            @Override
            protected void internalPut(String key, Object value) {
                if (isExport(key)) {
                    callerContext.put(key, value);
                }

                super.internalPut(key, value);
            }

            @Override
            protected void internalRemove(String key) {
                if (isExport(key)) {
                    callerContext.remove(key);
                }

                super.internalRemove(key);
            }

            private boolean isExport(String key) {
                return callerContext != null && (exportAll || exportVars.contains(key));
            }
        };

        // add all params
        context.getMap().putAll(params);

        return context;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.