Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.ComponentSpecification


    private Object construct(Class baseClass, String methodName, Messages messages)
    {
        Location l = newLocation();

        ComponentSpecification spec = new ComponentSpecification();
        EnhancementOperationImpl op = new EnhancementOperationImpl(getClassResolver(), spec,
                baseClass, new ClassFactoryImpl(), null);

        op.addInjectedField("_messages", Messages.class, messages);
View Full Code Here


       
        EnhancementOperation op = newMock(EnhancementOperation.class);
       
        expect(op.getPropertyType(propertyName)).andReturn(m.getReturnType());
       
        IComponentSpecification spec = new ComponentSpecification();

        replay();

        new ParameterAnnotationWorker().performEnhancement(op, spec, m, location);

        verify();

        return spec.getParameter(parameterName);
    }
View Full Code Here

    {
        Method m = findMethod(AnnotatedPage.class, "getSimpleParameter");
       
        EnhancementOperation op = newMock(EnhancementOperation.class);
               
        IComponentSpecification spec = new ComponentSpecification();

        replay();

        try
        {
View Full Code Here

{
    public void testBeanClassSpecified()
    {
        Location l = newLocation();
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();

        Method m = findMethod(AnnotatedPage.class, "getMapBean");

        replay();

        new BeanAnnotationWorker().performEnhancement(op, spec, m, l);

        verify();

        IBeanSpecification bs = spec.getBeanSpecification("mapBean");

        assertEquals("mapBean", bs.getPropertyName());
        assertEquals(HashMap.class.getName(), bs.getClassName());
        assertEquals(BeanLifecycle.REQUEST, bs.getLifecycle());
        assertSame(l, bs.getLocation());
View Full Code Here

    public void testBeanClassNotSpecified()
    {
        Location l = newLocation();
        EnhancementOperation op = newOp("hashMapBean", HashMap.class);
        IComponentSpecification spec = new ComponentSpecification();

        Method m = findMethod(AnnotatedPage.class, "getHashMapBean");

        replay();

        new BeanAnnotationWorker().performEnhancement(op, spec, m, l);

        verify();

        IBeanSpecification bs = spec.getBeanSpecification("hashMapBean");

        assertEquals("hashMapBean", bs.getPropertyName());
        assertEquals(HashMap.class.getName(), bs.getClassName());
        assertEquals(BeanLifecycle.REQUEST, bs.getLifecycle());
        assertSame(l, bs.getLocation());
View Full Code Here

    }

    public void testInitializer()
    {
        EnhancementOperation op = newOp("beanWithInitializer", TargetValues.class);
        IComponentSpecification spec = new ComponentSpecification();

        Method m = findMethod(AnnotatedPage.class, "getBeanWithInitializer");

        replay();

        new BeanAnnotationWorker().performEnhancement(op, spec, m, null);

        verify();

        IBeanSpecification bs = spec.getBeanSpecification("beanWithInitializer");

        List l = bs.getInitializers();
        LightweightBeanInitializer lbi = (LightweightBeanInitializer) l.get(0);

        assertEquals("intValue=10", lbi.getPropertyName());
View Full Code Here

    }

    public void testLifecycle()
    {
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();

        Method m = findMethod(AnnotatedPage.class, "getRenderLifecycleBean");

        replay();

        new BeanAnnotationWorker().performEnhancement(op, spec, m, null);

        verify();

        IBeanSpecification bs = spec.getBeanSpecification("renderLifecycleBean");

        assertEquals(BeanLifecycle.RENDER, bs.getLifecycle());
    }
View Full Code Here

    /** @since 4.0 */

    public void testGetReservedParameterNames()
    {
        IComponentSpecification s = new ComponentSpecification();

        assertEquals(Collections.EMPTY_SET, s.getReservedParameterNames());

        s.addReservedParameterName("Fred");

        Set expected = new HashSet();

        expected.add("fred");

        assertEquals(expected, s.getReservedParameterNames());

        IParameterSpecification ps = new ParameterSpecification();

        ps.setAliases("wilma,barney");
        ps.setParameterName("bambam");

        s.addParameter(ps);

        expected.add("wilma");
        expected.add("barney");
        expected.add("bambam");

        assertEquals(expected, s.getReservedParameterNames());

        try
        {
            s.getReservedParameterNames().clear();
            unreachable();
        }
        catch (UnsupportedOperationException ex)
        {
            // expected
View Full Code Here

        IComponentEventInvoker invoker = new ComponentEventInvoker();
        IEngineService engine = newMock(IEngineService.class);
        IRequestCycle cycle = newCycle();
        checkOrder(cycle, false);
       
        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, 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.getExtendedId()).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, 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.getExtendedId()).andReturn("wid1").anyTimes();
        expect(widget.getClientId()).andReturn("wid1").anyTimes();
       
        assert widgetSpec.getComponentEvents("wid1") != null;
       
        trainGetLinkCheckIgnoreParameter(engine, cycle, false, new Object(), link);
        trainGetURL(link, "/some/url2");
       
        expect(scriptSource.getScript(widScriptResource)).andReturn(script);
View Full Code Here

        ComponentEventConnectionWorker worker = new ComponentEventConnectionWorker();
        worker.setEventInvoker(invoker);
        worker.setEventEngine(engine);
       
        IDirectEvent component = newMock(IDirectEvent.class);
        IComponentSpecification spec = new ComponentSpecification();
       
        IDirectEvent comp1 = newMock(IDirectEvent.class);
        IComponentSpecification comp1Spec = new ComponentSpecification();
       
        IDirectEvent comp2 = newMock(IDirectEvent.class);
        IComponentSpecification comp2Spec = new ComponentSpecification();
       
        // now test render
        spec.addEventListener("comp1", new String[] {"onclick", "onchange"}, "testMethod", "form1", true, true, false, false);
        invoker.addEventListener("comp1", spec);
        invoker.addFormEventListener("form1", spec);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.spec.ComponentSpecification

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.