Package com.alibaba.citrus.turbine

Examples of com.alibaba.citrus.turbine.Context


        rundata.getResponse().getWriter();
    }

    @Test
    public void render_exportVars() throws Exception {
        Context context1 = rundata.getContext();
        Context context2 = rundata.getContext("app2");
        assertTrue(tool.exportAll);

        context1.put("var1", "init");
        context1.put("var2", "init");

        // no current context
        tool.setTemplate("control_set").render();
        assertEquals("init", context1.get("var1"));
        assertEquals("init", context1.get("var2"));

        // app1:context -> app1:control, without exports
        rundata.pushContext(context1);

        tool.setTemplate("control_set").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        // app1:context -> app1:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var1").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var2").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var1", "var2").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        // app1:context -> app1:control -> app2:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");
        context2.put("var1", "init");
        context2.put("var2", "init");

        String content = tool.setTemplate("control_nest").render();

        assertEquals("app2", context1.get("var1"));
        assertEquals(null, context1.get("var2"));
        assertEquals("init", context2.get("var1"));
        assertEquals("init", context2.get("var2"));

        assertThat(content, containsAll("1. app2", "2. $var2"));

        // app1:context -> app1:control.export(var1, var2) -> app2:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");
        context2.put("var1", "init");
        context2.put("var2", "init");

        content = tool.setTemplate("control_nest").export("var1", "var2").render();

        assertEquals("app2", context1.get("var1"));
        assertEquals(null, context1.get("var2"));
        assertEquals("init", context2.get("var1"));
        assertEquals("init", context2.get("var2"));

        assertThat(content, containsAll("1. app2", "2. $var2"));
    }
View Full Code Here


        assertEquals(redirectTarget, rundata.getRedirectTarget());
    }

    @Test
    public void getContext() {
        Context context1 = rundata.getContext();
        Context context2 = rundata.getContext("app2");

        // getContext()取得当前component的context。
        assertSame(rundata.getContext("app1"), rundata.getContext());
        assertSame(rundata.getContext("app1"), context1);
View Full Code Here

            fail();
        } catch (IllegalStateException e) {
            assertThat(e, exception("can't popContext without pushContext"));
        }

        Context context1 = rundata.getContext("app1");
        Context context2 = rundata.getContext("app2");

        try {
            rundata.pushContext(null);
            fail();
        } catch (IllegalArgumentException e) {
View Full Code Here

        assertEquals(result, str);
    }

    @Test
    public void hierarchical_toString() {
        Context context = new MappedContext(this.context);

        context.put("ddd", "444");

        String str = context.toString();
        String result = "";

        result = "MappedContext {\n";
        result += "  parentContext = MappedContext {\n";
        result += "                    aaa = 111\n";
View Full Code Here

    @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

    }

    @Test
    public void context() throws Exception {
        execute("action", "rundata.myAction", "doGetContext");
        Context context = assertLog("actionLog", Context.class);

        assertSame(context, getRunData().getContext());
    }
View Full Code Here

    @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);

        assertSame(context, controlContext);
    }
View Full Code Here

        assertEquals("hi, baobao app2 without template", content);
    }

    @Test
    public void controlContexts() throws Exception {
        Context context1 = rundata.getContext();
        Context context2 = rundata.getContext("app2");
        assertFalse(tool.exportAll);

        context1.put("var1", "init");
        context1.put("var2", "init");
View Full Code Here

        return (Context) method.invoke(tool, controlParameters, component);
    }

    @Test
    public void render_exportVars() throws Exception {
        Context context1 = rundata.getContext();
        Context context2 = rundata.getContext("app2");
        assertFalse(tool.exportAll);

        context1.put("var1", "init");
        context1.put("var2", "init");

        // no current context
        tool.setTemplate("control_set").render();
        assertEquals("init", context1.get("var1"));
        assertEquals("init", context1.get("var2"));

        // app1:context -> app1:control, without exports
        rundata.pushContext(context1);

        tool.setTemplate("control_set").render();
        assertEquals("init", context1.get("var1"));
        assertEquals("init", context1.get("var2"));

        // app1:context -> app1:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var1").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals("init", context1.get("var2"));

        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var2").render();
        assertEquals("init", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        context1.put("var1", "init");
        context1.put("var2", "init");

        tool.setTemplate("control_set").export("var1", "var2").render();
        assertEquals("app1", context1.get("var1"));
        assertEquals(null, context1.get("var2"));

        // app1:context -> app1:control -> app2:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");
        context2.put("var1", "init");
        context2.put("var2", "init");

        String content = tool.setTemplate("control_nest").render();

        assertEquals("init", context1.get("var1"));
        assertEquals("init", context1.get("var2"));
        assertEquals("init", context2.get("var1"));
        assertEquals("init", context2.get("var2"));

        assertThat(content, containsAll("1. app2", "2. $var2"));

        // app1:context -> app1:control.export(var1, var2) -> app2:control.export(var1, var2)
        context1.put("var1", "init");
        context1.put("var2", "init");
        context2.put("var1", "init");
        context2.put("var2", "init");

        content = tool.setTemplate("control_nest").export("var1", "var2").render();

        assertEquals("app2", context1.get("var1"));
        assertEquals(null, context1.get("var2"));
        assertEquals("init", context2.get("var1"));
        assertEquals("init", context2.get("var2"));

        assertThat(content, containsAll("1. app2", "2. $var2"));
    }
View Full Code Here

            assertThat(e, exception(IllegalArgumentException.class));
        }

        assertNull(request.getAttribute("_webx3_turbine_rundata"));

        Context savedContext = (Context) request.getAttribute("_webx3_turbine_rundata_context");
        assertNotNull(savedContext); // 保留context

        // 切换到root component,以模拟error处理的情形
        WebxUtil.setCurrentComponent(request, component.getWebxComponents().getComponent(null));
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.turbine.Context

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.