Package org.apache.tapestry.events

Examples of org.apache.tapestry.events.InvalidationListener


    @Test
    public void caching_and_invalidation() throws Exception
    {
        ResourceDigestGenerator generator = mockResourceDigestGenerator();
        InvalidationListener listener = mockInvalidationListener();
        File f = createTestFile();
        URL url = f.toURL();
        Resource r = mockResource();

        long lastUpdated = f.lastModified();

        train_getPath(r, PATH);
        train_toURL(r, url);

        train_requiresDigest(generator, PATH, true);
        train_generateChecksum(generator, url, DIGEST);

        replay();

        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
        cache.addInvalidationListener(listener);

        assertEquals(cache.requiresDigest(r), true);
        assertEquals(cache.getTimeModified(r), lastUpdated);
        assertEquals(cache.getDigest(r), DIGEST);

        // No updates yet.

        cache.checkForUpdates();

        verify();

        touch(f);

        lastUpdated = f.lastModified();

        String expectedDigest = "FREDBARNEY";

        train_getPath(r, PATH);
        train_toURL(r, url);
        train_requiresDigest(generator, PATH, true);
        train_generateChecksum(generator, url, expectedDigest);

        listener.objectWasInvalidated();

        replay();

        cache.checkForUpdates();
View Full Code Here


        Resource baseResource = new ClasspathResource(loader, "baz/Biff.class");
        Resource localized = baseResource.withExtension(InternalConstants.TEMPLATE_EXTENSION);

        TemplateParser parser = mockTemplateParser();
        ComponentTemplate template = mockComponentTemplate();
        InvalidationListener listener = mockInvalidationListener();

        train_getComponentClassName(model, "baz.Biff");

        train_getBaseResource(model, baseResource);

        train_parseTemplate(parser, localized, template);

        replay();

        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser, null);
        source.addInvalidationListener(listener);

        assertSame(source.getTemplate(model, Locale.ENGLISH), template);

        // Check for updates (which won't be found).
        source.checkForUpdates();

        // A second pass will test the caching (the
        // parser is not invoked).

        assertSame(source.getTemplate(model, Locale.ENGLISH), template);

        verify();

        // Now, change the file and process an UpdateEvent.

        touch(f);

        listener.objectWasInvalidated();

        replay();

        // Check for updates (which will be found).
        source.checkForUpdates();
View Full Code Here

            }
        };

        configuration.add("SetApplicationPackage", setApplicationPackage, "before:*.*");

        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

            }
        };

        configuration.add("SetApplicationPackage", setApplicationPackage, "before:*.*");

        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

            }
        };

        configuration.add("SetApplicationPackage", setApplicationPackage, "before:*.*");

        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

    @Test
    public void caching_and_invalidation() throws Exception
    {
        ResourceDigestGenerator generator = newResourceDigestGenerator();
        InvalidationListener listener = newInvalidationListener();
        File f = createTestFile();
        URL url = f.toURL();
        Resource r = newResource();

        long lastUpdated = f.lastModified();

        train_getPath(r, PATH);
        train_toURL(r, url);

        train_requiresDigest(generator, PATH, true);
        train_generateChecksum(generator, url, DIGEST);

        replay();

        ResourceCacheImpl cache = new ResourceCacheImpl(generator);
        cache.addInvalidationListener(listener);

        assertEquals(cache.requiresDigest(r), true);
        assertEquals(cache.getTimeModified(r), lastUpdated);
        assertEquals(cache.getDigest(r), DIGEST);

        // No updates yet.

        cache.checkForUpdates();

        verify();

        touch(f);

        lastUpdated = f.lastModified();

        String expectedDigest = "FREDBARNEY";

        train_getPath(r, PATH);
        train_toURL(r, url);
        train_requiresDigest(generator, PATH, true);
        train_generateChecksum(generator, url, expectedDigest);

        listener.objectWasInvalidated();

        replay();

        cache.checkForUpdates();
View Full Code Here

        Resource baseResource = new ClasspathResource(loader, "baz/Biff.class");
        Resource localized = baseResource.withExtension(InternalConstants.TEMPLATE_EXTENSION);

        TemplateParser parser = newTemplateParser();
        ComponentTemplate template = newComponentTemplate();
        InvalidationListener listener = newInvalidationListener();

        train_getComponentClassName(model, "baz.Biff");

        train_getBaseResource(model, baseResource);

        train_parseTemplate(parser, localized, template);

        replay();

        ComponentTemplateSourceImpl source = new ComponentTemplateSourceImpl(parser, null);
        source.addInvalidationListener(listener);

        assertSame(source.getTemplate(model, Locale.ENGLISH), template);

        // Check for updates (which won't be found).
        source.checkForUpdates();

        // A second pass will test the caching (the
        // parser is not invoked).

        assertSame(source.getTemplate(model, Locale.ENGLISH), template);

        verify();

        // Now, change the file and process an UpdateEvent.

        touch(f);

        listener.objectWasInvalidated();

        replay();

        // Check for updates (which will be found).
        source.checkForUpdates();
View Full Code Here

            }
        };

        configuration.add("SetApplicationPackage", setApplicationPackage, "before:*.*");

        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.events.InvalidationListener

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.