use of org.apache.tapestry5.services.AssetFactory in project tapestry-5 by apache.
the class AssetSourceImplTest method missing_resource.
@Test
public void missing_resource() {
ThreadLocale threadLocale = mockThreadLocale();
Map<String, AssetFactory> configuration = Collections.emptyMap();
replay();
AssetSource source = new AssetSourceImpl(threadLocale, configuration, null, null, tracker);
try {
source.getAsset(baseResource, "DoesNotExist.properties", Locale.UK);
unreachable();
} catch (RuntimeException ex) {
assertEquals(ex.getMessage(), "Unable to locate asset 'classpath:org/apache/tapestry5/internal/services/DoesNotExist.properties' (the file does not exist).");
}
verify();
}
use of org.apache.tapestry5.services.AssetFactory in project tapestry-5 by apache.
the class AssetSourceImplTest method get_classpath_asset.
@Test
public void get_classpath_asset() {
AssetFactory factory = mockAssetFactory();
ThreadLocale threadLocale = mockThreadLocale();
Asset asset = mockAsset();
Resource expectedResource = baseResource.forFile("SimpleComponent_en_GB.properties");
train_getRootResource(factory, rootResource);
train_createAsset(factory, expectedResource, asset);
Map<String, AssetFactory> configuration = Collections.singletonMap("classpath", factory);
replay();
AssetSource source = new AssetSourceImpl(threadLocale, configuration, null, null, tracker);
// First try creates it:
assertSame(source.getClasspathAsset("org/apache/tapestry5/internal/services/SimpleComponent.properties", Locale.UK), asset);
verify();
}
use of org.apache.tapestry5.services.AssetFactory in project tapestry-5 by apache.
the class AssetSourceImplTest method get_expanded_asset.
@Test
public void get_expanded_asset() {
AssetFactory factory = mockAssetFactory();
Asset asset = mockAsset();
SymbolSource symbolSource = mockSymbolSource();
Resource expectedResource = baseResource.forFile("SimpleComponent.properties");
train_getRootResource(factory, rootResource);
train_createAsset(factory, expectedResource, asset);
train_expandSymbols(symbolSource, "${path}/SimpleComponent.properties", "org/apache/tapestry5/internal/services/SimpleComponent.properties");
Map<String, AssetFactory> configuration = Collections.singletonMap("classpath", factory);
replay();
AssetSource source = new AssetSourceImpl(null, configuration, symbolSource, null, tracker);
// First try creates it:
assertSame(source.getExpandedAsset("${path}/SimpleComponent.properties"), asset);
verify();
}
use of org.apache.tapestry5.services.AssetFactory in project tapestry-5 by apache.
the class AssetSourceImplTest method unknown_asset_prefix.
@Test
public void unknown_asset_prefix() {
ThreadLocale threadLocale = mockThreadLocale();
Map<String, AssetFactory> configuration = Collections.emptyMap();
replay();
AssetSource source = new AssetSourceImpl(threadLocale, configuration, null, null, tracker);
try {
source.getAsset(baseResource, "classpath:org/apache/tapestry5/internal/services/SimpleComponent.properties", Locale.UK);
unreachable();
} catch (IllegalArgumentException ex) {
assertEquals(ex.getMessage(), "Unknown prefix for asset path 'classpath:org/apache/tapestry5/internal/services/SimpleComponent.properties'.");
}
verify();
}
use of org.apache.tapestry5.services.AssetFactory in project tapestry-5 by apache.
the class TapestryModule method contributeComponentTemplateLocator.
/**
* Contributes two template locators:
* <dl>
* <dt>Default</dt>
* <dd>Searches for the template on the classpath ({@link DefaultTemplateLocator}</dd>
* <dt>Page</dt>
* <dd>Searches for <em>page</em> templates in the context ({@link PageTemplateLocator})</dd>
* </dl>
*
* @since 5.2.0
*/
public static void contributeComponentTemplateLocator(OrderedConfiguration<ComponentTemplateLocator> configuration, @ContextProvider AssetFactory contextAssetFactory, @Symbol(SymbolConstants.APPLICATION_FOLDER) String applicationFolder, ComponentClassResolver componentClassResolver) {
configuration.add("Default", new DefaultTemplateLocator());
configuration.add("Page", new PageTemplateLocator(contextAssetFactory.getRootResource(), componentClassResolver, applicationFolder));
}
Aggregations