Examples of InvalidationListener


Examples of org.apache.tapestry.internal.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();
        lastUpdated -= lastUpdated % 1000;

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

        Thread.sleep(1500);
        touch(f);

        lastUpdated = f.lastModified();
        lastUpdated -= lastUpdated % 1000;

        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

Examples of org.apache.tapestry.internal.events.InvalidationListener

        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

Examples of org.apache.tapestry.internal.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();
        lastUpdated -= lastUpdated % 1000;

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

        Thread.sleep(1500);
        touch(f);

        lastUpdated = f.lastModified();
        lastUpdated -= lastUpdated % 1000;

        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

Examples of org.apache.tapestry.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final PropertyAccess propertyAccess, final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

Examples of org.apache.tapestry.internal.events.InvalidationListener

    public void contributeApplicationInitializer(
            OrderedConfiguration<ApplicationInitializerFilter> configuration,
            final ApplicationGlobals applicationGlobals, final PropertyAccess propertyAccess,
            final TypeCoercer typeCoercer)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

Examples of org.apache.tapestry.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final PropertyAccess propertyAccess, final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

Examples of org.apache.tapestry.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final PropertyAccess propertyAccess, final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();
                typeCoercer.clearCache();
View Full Code Here

Examples of org.apache.tapestry5.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();

View Full Code Here

Examples of org.apache.tapestry5.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();

View Full Code Here

Examples of org.apache.tapestry5.internal.events.InvalidationListener

     */
    public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
                                                 final TypeCoercer typeCoercer,
                                                 final ComponentClassResolver componentClassResolver)
    {
        final InvalidationListener listener = new InvalidationListener()
        {
            public void objectWasInvalidated()
            {
                propertyAccess.clearCache();

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.