Examples of IScript


Examples of org.apache.tapestry.IScript

        assertSymbol(symbols, "gamma", "Alpha_1");
    }

    public void testIncludeScript() throws Exception
    {
        IScript script = execute("include-script.script", null);

        Resource scriptLocation = script.getScriptResource();

        Resource[] expected = new Resource[]
        { scriptLocation.getRelativeResource("first"),
                scriptLocation.getRelativeResource("second"),
                scriptLocation.getRelativeResource("third") };
View Full Code Here

Examples of org.apache.tapestry.IScript

    /**
     * A bunch of quickies to push up the code coverage numbers.
     */
    public void testCheats() throws Exception
    {
        IScript script = execute("simple.script", null);

        ScriptSession session = new ScriptSessionImpl(script.getScriptResource(), null, null,
                createExpressionEvaluator(), null, null);
        assertEquals("ScriptSession[" + script.getScriptResource() + "]", session.toString());
    }
View Full Code Here

Examples of org.apache.tapestry.IScript

        MockDelegate delegate = new MockDelegate();
       
        IEngineService engine = newEngineService();
        ILink link = newLink();
       
        IScript script = newMock(IScript.class);
       
        SimpleBean match = new SimpleBean(new Integer(2), "Simple 2", 200);
       
        Autocompleter component = newInstance(Autocompleter.class,
                new Object[] {
            "name", "fred", "model", model,
            "directService", engine,
            "script", script,
            "validatableFieldSupport", vfs,
            "value", match,
            "dataSqueezer", ds
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        DirectServiceParameter dsp =
            new DirectServiceParameter(component);
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, true, dsp, link);
       
        trainGetURL(link, "urlstring");
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        expect(ds.squeeze(2)).andReturn("2p");
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        expect(cycle.renderStackPop()).andReturn(component);
       
        replay();
       
View Full Code Here

Examples of org.apache.tapestry.IScript

       
        IComponentSpecification spec = new ComponentSpecification();
        IComponentSpecification widgetSpec = new ComponentSpecification();
       
        IScriptSource scriptSource = newMock(IScriptSource.class);
        IScript script = newMock(IScript.class);
       
        PageRenderSupport prs = newPageRenderSupport();
       
        ILink link = newMock(ILink.class);
       
        String elemScript = "/org/apache/tapestry/html/ElementEvent.script";
        String compScript = "/org/apache/tapestry/ComponentEvent.script";
        String widScript = "/org/apache/tapestry/dojo/html/WidgetEvent.script";
       
        Resource compScriptResource = new ClasspathResource(resolver, compScript);
        Resource widScriptResource = new ClasspathResource(resolver, widScript);
        Resource elemScriptResource = new ClasspathResource(resolver, elemScript);
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setClassResolver(resolver);
        worker.setEventInvoker(invoker);
        worker.setComponentScript(compScript);
        worker.setWidgetScript(widScript);
        worker.setElementScript(elemScript);
        worker.setEventEngine(engine);
        worker.setScriptSource(scriptSource);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IWidget widget = newMock(IWidget.class);
       
        assertNotNull(worker.getScript(component));
        assertEquals(compScript, worker.getScript(component).getPath());
       
        assertNotNull(worker.getScript(widget));
        assertEquals(widScript, worker.getScript(widget).getPath());
       
        assertNotNull(worker.getElementScript());
        assertEquals(elemScript, worker.getElementScript().getPath());
       
        // now test render
        invoker.addEventListener("comp1", spec);
        spec.addEventListener("comp1", new String[] {"onclick"}, "testMethod", null, false, true, false);
        spec.addElementEventListener("elementId", new String[] {"onclick"}, "testMethod", null, false, true, false);
       
        /////////////////////////////////
       
        Map elmEvents = spec.getElementEvents();
        Iterator keyIt = elmEvents.keySet().iterator();
       
        while (keyIt.hasNext()) {
            String elem = (String)keyIt.next();
            assertEquals(elem, "elementId");
           
            ComponentEventProperty prop = (ComponentEventProperty)elmEvents.get(elem);
            assertNotNull(prop);
           
            Object[][] events = worker.getEvents(prop, elem);
           
            assertNotNull(events);
            assertEquals(events.length, 1);
            assertEquals(events[0].length, 2);
        }
       
        ////////////////////////////////////////////
       
        expect(cycle.isRewinding()).andReturn(false);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(component.getId()).andReturn("comp1").anyTimes();
        expect(component.getClientId()).andReturn("comp1").anyTimes();
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE))
        .andReturn(prs).anyTimes();
       
        expect(component.getSpecification()).andReturn(spec);
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url");
       
        expect(scriptSource.getScript(compScriptResource)).andReturn(script);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        expect(component.getSpecification()).andReturn(spec);
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
       
        trainGetURL(link, "/some/url");
       
        expect(scriptSource.getScript(elemScriptResource)).andReturn(script);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        worker.renderComponent(cycle, component);
       
        verify();
       
        assertEquals(0, worker.getDefferedFormConnections().size());
       
        // test widget render
       
        invoker.addEventListener("wid1", widgetSpec);
        widgetSpec.addEventListener("wid1", new String[] {"onclick"}, "testMethod", null, false, true, false);
       
        checkOrder(cycle, false);
        expect(cycle.isRewinding()).andReturn(false);
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE))
        .andReturn(prs).anyTimes();
       
        expect(widget.getSpecification()).andReturn(widgetSpec);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(widget.getId()).andReturn("wid1").anyTimes();
        expect(widget.getClientId()).andReturn("wid1").anyTimes();
       
        assertTrue(widgetSpec.hasEvents("wid1"));
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url2");
       
        expect(scriptSource.getScript(widScriptResource)).andReturn(script);
       
        script.execute(eq(widget), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        worker.renderComponent(cycle, widget);
       
View Full Code Here

Examples of org.apache.tapestry.IScript

       
        IComponentEventInvoker invoker = new org.apache.tapestry.internal.event.impl.ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        IRequestCycle cycle = newCycle();
        IScriptSource scriptSource = newMock(IScriptSource.class);
        IScript script = newMock(IScript.class);
       
        PageRenderSupport prs = newPageRenderSupport();
       
        String compScript = "/org/apache/tapestry/ComponentEvent.script";
        Resource compScriptResource = new ClasspathResource(resolver, compScript);
       
        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setClassResolver(resolver);
        worker.setEventInvoker(invoker);
        worker.setComponentScript(compScript);
        worker.setEventEngine(engine);
        worker.setScriptSource(scriptSource);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IComponentSpecification spec = new ComponentSpecification();
       
        IForm form = newMock(IForm.class);
        IComponentSpecification formSpec = new ComponentSpecification();
       
        // now test render
        invoker.addEventListener("comp1", spec);
        spec.addEventListener("comp1", new String[] {"onclick"}, "testMethod", "form1", false, false, false);
       
        expect(cycle.isRewinding()).andReturn(false);
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(component.getId()).andReturn("comp1").anyTimes();
        expect(component.getClientId()).andReturn("comp1").anyTimes();
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
       
        expect(component.getSpecification()).andReturn(spec);
       
        replay();
       
        worker.renderComponent(cycle, component);
       
        verify();
       
        assertEquals(1, worker.getDefferedFormConnections().size());
       
        checkOrder(form, false);
        checkOrder(component, false);
       
        expect(cycle.isRewinding()).andReturn(false);
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE)).andReturn(prs);
       
        expect(form.getSpecification()).andReturn(formSpec);
       
        expect(cycle.getAttribute(TapestryUtils.FIELD_PRERENDER)).andReturn(null);
       
        expect(form.getId()).andReturn("form1").anyTimes();
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1")).andReturn(null);
       
        cycle.setAttribute(eq(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1"),
                isA(List.class));
       
        expect(form.getName()).andReturn("form1_0").anyTimes();
       
        expect(component.getSpecification()).andReturn(spec);
       
        expect(component.getId()).andReturn("comp1").anyTimes();
       
        List formNames = new ArrayList();
        formNames.add("form1_0");
       
        expect(cycle.getAttribute(ComponentEventConnectionWorker.FORM_NAME_LIST + "form1"))
        .andReturn(formNames);
       
        expect(cycle.getAttribute(TapestryUtils.PAGE_RENDER_SUPPORT_ATTRIBUTE))
        .andReturn(prs);
       
        expect(scriptSource.getScript(compScriptResource)).andReturn(script);
       
        script.execute(eq(form), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        worker.renderComponent(cycle, form);
       
View Full Code Here

Examples of org.apache.tapestry.IScript

        verify();
    }

    public void test_SubmitType_OnClick()
    {
        IScript script = newMock(IScript.class);
        Submit submit = newInstance(Submit.class,
                new Object[] {"submitType", "cancel", "submitScript", script});
       
        IValidationDelegate delegate = newDelegate();
        IForm form = newForm();
View Full Code Here

Examples of org.apache.tapestry.IScript

        verify();
    }
   
    public void test_SubmitType_Script_OnClick()
    {
        IScript script = newMock(IScript.class);
        IForm form = newForm();
        IBinding binding = newMock(IBinding.class);
       
        Submit submit = newInstance(Submit.class,
                new Object[] {"submitType", "cancel",
            "submitScript", script, "form", form});
       
        submit.setBinding("onClick", binding);
       
        IRequestCycle cycle = newCycle();
        IMarkupWriter writer = newWriter();
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        script.execute(eq(submit), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        submit.renderSubmitBindings(writer, cycle);
View Full Code Here

Examples of org.apache.tapestry.IScript

    public void test_Submit_Async()
    {
        List updates = new ArrayList();
        updates.add("bsComponent");
       
        IScript script = newMock(IScript.class);
        IForm form = newForm();
        IBinding binding = newMock(IBinding.class);
       
        IEngineService engine = newEngineService();
        ILink link = newMock(ILink.class);
       
        Submit submit = newInstance(Submit.class,
                new Object[] {"submitType", "cancel",
            "submitScript", script, "form", form,
            "async", true, "updateComponents", updates,
            "directService", engine});
       
        submit.setBinding("onClick", binding);
       
        IRequestCycle cycle = newCycle();
        IMarkupWriter writer = newWriter();
       
        expect(engine.getLink(eq(true), isA(DirectServiceParameter.class))).andReturn(link);
       
        expect(link.getURL()).andReturn("/test/url");
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        script.execute(eq(submit), eq(cycle), eq(prs), isA(Map.class));
       
        replay();
       
        submit.renderSubmitBindings(writer, cycle);
View Full Code Here

Examples of org.apache.tapestry.IScript

        checkOrder(form, false);
        IPage page = newPage();
       
        MockDelegate delegate = new MockDelegate();
       
        IScript script = newMock(IScript.class);
       
        Date dtValue = new Date();
       
        DropdownTimePicker component = newInstance(DropdownTimePicker.class,
                new Object[] {
            "name", "fred",
            "script", script,
            "validatableFieldSupport", vfs,
            "translator", translator,
            "value", dtValue,
            "page", page
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
       
        expect(cycle.renderStackPop()).andReturn(component);
       
        replay();
       
View Full Code Here

Examples of org.apache.tapestry.IScript

     * No input symbols, no informal parameters.
     */
    public void test_Minimal_Render()
    {
        IScriptSource source = newScriptSource();
        IScript script = newScript();

        IMarkupWriter writer = newWriter();
       
        PageRenderSupport support = newPageRenderSupport();
       
        IRequestCycle cycle = newCycle(false, null);
       
        trainGetPageRenderSupport(cycle, support);
       
        Resource scriptLocation = newResource();
        IRender body = newRender();
       
        IComponent container = newComponent();

        String scriptPath = "MyScript.script";

        Script component = newInstance(Script.class, new Object[]
        { "specification", new ComponentSpecification(), "container", container, "scriptSource",
                source, "scriptPath", scriptPath });
       
        trainGetScriptLocation(container, scriptPath, scriptLocation);
       
        trainGetScript(source, scriptLocation, script);

        script.execute(component, cycle, support, new HashMap());

        trainResponseBuilder(cycle, writer);
       
        body.render(writer, cycle);
       
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.