Package org.apache.tapestry.spec

Examples of org.apache.tapestry.spec.ComponentSpecification


{

    public void test_Event_Connection()
    {
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        Resource resource = newResource(AnnotatedPage.class);
               
        EventListenerAnnotationWorker worker = new EventListenerAnnotationWorker();

        replay();
       
        Method m = findMethod(AnnotatedPage.class, "eventListener");
       
        assertTrue(worker.canEnhance(m));
        assertFalse(worker.canEnhance(findMethod(AnnotatedPage.class, "getPersistentProperty")));
        worker.peformEnhancement(op, spec, m, resource);
       
        verify();
               
        ComponentEventProperty property = spec.getComponentEvents("email");
        assertNotNull(property);
       
        List listeners = property.getEventListeners("onClick");
        assertNotNull(listeners);
        assertEquals(1, listeners.size());
       
        property = spec.getElementEvents("foo");
        assertNotNull(property);
       
        listeners = property.getEventListeners("onClick");
        assertNotNull(listeners);
        assertEquals(1, listeners.size());
View Full Code Here


    }
   
    public void test_Form_Event_Connection()
    {
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        Resource resource = newResource(AnnotatedPage.class);

        EventListenerAnnotationWorker worker = new EventListenerAnnotationWorker();

        replay();
       
        Method m = findMethod(AnnotatedPage.class, "formListener");
       
        assertTrue(worker.canEnhance(m));
        worker.peformEnhancement(op, spec, m, resource);
       
        verify();
               
        ComponentEventProperty property = spec.getComponentEvents("email");
        assertNotNull(property);
       
        List listeners = property.getFormEventListeners("onClick");
        assertNotNull(listeners);
        assertEquals(1, listeners.size());
View Full Code Here

        AbstractPropertyWorker w = new AbstractPropertyWorker();

        w.setErrorLog(new ErrorLogImpl(new DefaultErrorHandler(), LOG));

        EnhancementOperationImpl op = new EnhancementOperationImpl(_classResolver,
                new ComponentSpecification(), inputClass, _classFactory);

        w.performEnhancement(op, null);

        return op.getConstructor();
    }
View Full Code Here

            _log.debug("Found HTML template at " + resource);

        // TODO The SpecFactory in Specification parser should be used in some way to
        // create an IComponentSpecification!

        IComponentSpecification specification = new ComponentSpecification();
        specification.setPageSpecification(true);
        specification.setSpecificationLocation(resource);

        setSpecification(specification);

        install();
    }
View Full Code Here

        Class componentClass = _classFinder.findClass(packages, className);
        if (componentClass == null)
            return null;

        IComponentSpecification spec = new ComponentSpecification();

        Resource namespaceResource = namespace.getSpecificationLocation();
        Resource componentResource = namespaceResource.getRelativeResource(type + ".jwc");

        // try classpath relative if namespace relative doesn't resolve

        if (componentResource.getResourceURL() == null) {
           
            componentResource = new ClasspathResource(_classResolver, componentClass.getName().replace('.', '/'));
        }

        Location location = new LocationImpl(componentResource);

        spec.setLocation(location);
        spec.setSpecificationLocation(componentResource);
        spec.setComponentClassName(componentClass.getName());

        return spec;
    }
View Full Code Here

    public void testDefaultStrategy()
    {
        Location l = newLocation();

        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();

        replay();

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

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

        verify();

        IPropertySpecification ps = spec.getPropertySpecification("persistentProperty");

        assertEquals("session", ps.getPersistence());
        assertEquals("persistentProperty", ps.getName());
        assertSame(l, ps.getLocation());
        assertNull(ps.getInitialValue());
View Full Code Here

    public void testStrategySpecified()
    {
        Location l = newLocation();

        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();

        replay();

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

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

        verify();

        IPropertySpecification ps = spec.getPropertySpecification("clientPersistentProperty");

        assertEquals("client", ps.getPersistence());
        assertEquals("clientPersistentProperty", ps.getName());
        assertSame(l, ps.getLocation());
        assertNull(ps.getInitialValue());
View Full Code Here

    public void testWithInitialValue()
    {
        Location l = newLocation();

        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();

        replay();

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

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

        verify();

        IPropertySpecification ps = spec
                .getPropertySpecification("persistentPropertyWithInitialValue");

        assertEquals("session", ps.getPersistence());
        assertEquals("persistentPropertyWithInitialValue", ps.getName());
        assertSame(l, ps.getLocation());
View Full Code Here

    public void test_Success()
    {
        Location l = newLocation();
        Resource r = newMock(Resource.class);
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        spec.setSpecificationLocation(r);

        replay();

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

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

        verify();

        IAssetSpecification as = spec.getAsset("globalStylesheet");

        assertEquals("/style/global.css", as.getPath());
        assertEquals(as.getLocation(), l);
        assertEquals("globalStylesheet", as.getPropertyName());
    }
View Full Code Here

    public void test_Class_Relative_Asset()
    {
        Location l = newLocation();
        Resource r = newMock(Resource.class);
        EnhancementOperation op = newOp();
        IComponentSpecification spec = new ComponentSpecification();
        spec.setSpecificationLocation(r);

        replay();

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

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

        verify();

        IAssetSpecification as = spec.getAsset("textAsset");

        assertEquals("images/test-asset.txt", as.getPath());
        assertEquals(as.getLocation(), l);
        assertEquals("textAsset", as.getPropertyName());
    }
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.