Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.AssetFactory


    }

    @Test
    public void get_classpath_asset_for_unspecified_locale()
    {
        AssetFactory factory = mockAssetFactory();
        ThreadLocale threadLocale = mockThreadLocale();
        Asset asset = mockAsset();
        Locale locale = Locale.UK;

        Resource expectedResource = baseResource.forFile("SimpleComponent_en_GB.properties");
View Full Code Here


    }

    @Test
    public void absolute_asset_with_known_prefix()
    {
        AssetFactory factory = mockAssetFactory();
        ThreadLocale threadLocale = mockThreadLocale();
        Asset asset = mockAsset();

        Resource expectedResource = rootResource
                .forFile("org/apache/tapestry5/internal/services/SimpleComponent_en_GB.properties");
View Full Code Here

        Map<Class, AssetFactory> byResourceClass = CollectionFactory.newMap();

        for (Map.Entry<String, AssetFactory> e : configuration.entrySet())
        {
            String prefix = e.getKey();
            AssetFactory factory = e.getValue();

            Resource rootResource = factory.getRootResource();

            byResourceClass.put(rootResource.getClass(), factory);

            prefixToRootResource.put(prefix, rootResource);
        }
View Full Code Here

        // So we can then use the class of the resource as a key to locate the correct asset
        // factory.

        Class resourceClass = resource.getClass();

        AssetFactory factory = registry.get(resourceClass);

        return factory.createAsset(resource);
    }
View Full Code Here

        Context context = mockContext();
        Request request = mockRequest();

        replay();

        AssetFactory factory = new ContextAssetFactory(request, context, "1.2.3", converter);

        assertEquals(factory.getRootResource().toString(), "context:/");

        verify();
    }
View Full Code Here

        train_getContextPath(request, "/context");

        replay();

        AssetFactory factory = new ContextAssetFactory(request, context, "4.5.6", new IdentityAssetPathConverter());

        Asset asset = factory.createAsset(r);

        assertSame(asset.getResource(), r);
        assertEquals(asset.toClientURL(), "/context/assets/ctx/4.5.6/foo/Bar.txt");

        // In real life, toString() is the same as toClientURL(), but we're testing
View Full Code Here

        train_toClientURL(aliasManager, "foo/Bar.txt", expectedClientURL);

        replay();

        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager, new IdentityAssetPathConverter());

        Asset asset = factory.createAsset(r);

        assertSame(asset.getResource(), r);
        assertEquals(asset.toClientURL(), expectedClientURL);
        assertEquals(asset.toString(), expectedClientURL);
View Full Code Here

        train_toClientURL(aliasManager, "foo/Bar.ABC123.txt", expectedClientURL);

        replay();

        AssetFactory factory = new ClasspathAssetFactory(cache, aliasManager, new IdentityAssetPathConverter());

        Asset asset = factory.createAsset(r);

        assertSame(asset.getResource(), r);
        assertEquals(asset.toClientURL(), expectedClientURL);
        assertEquals(asset.toString(), expectedClientURL);
View Full Code Here

        Map<Class, AssetFactory> byResourceClass = CollectionFactory.newMap();

        for (Map.Entry<String, AssetFactory> e : configuration.entrySet())
        {
            String prefix = e.getKey();
            AssetFactory factory = e.getValue();

            Resource rootResource = factory.getRootResource();

            byResourceClass.put(rootResource.getClass(), factory);

            prefixToRootResource.put(prefix, rootResource);
        }
View Full Code Here

        // So we can then use the class of the resource as a key to locate the correct asset
        // factory.

        Class resourceClass = resource.getClass();

        AssetFactory factory = registry.get(resourceClass);

        return factory.createAsset(resource);
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.AssetFactory

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.