use of org.apache.tapestry5.services.AssetSource 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.AssetSource 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.AssetSource 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.AssetSource 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.AssetSource in project tapestry-5 by apache.
the class AssetsModule method setupGlobalMessageCatalog.
/**
* Contributes:
* <dl>
* <dt>ClientLocalization</dt>
* <dd>A virtual resource of formatting symbols for decimal numbers</dd>
* <dt>Core</dt>
* <dd>Built in messages used by Tapestry's default validators and components</dd>
* <dt>AppCatalog</dt>
* <dd>The Resource defined by {@link SymbolConstants#APPLICATION_CATALOG}</dd>
* <dt>
* </dl>
*
* @since 5.2.0
*/
@Contribute(ComponentMessagesSource.class)
public static void setupGlobalMessageCatalog(AssetSource assetSource, @Symbol(SymbolConstants.APPLICATION_CATALOG) Resource applicationCatalog, OrderedConfiguration<Resource> configuration) {
configuration.add("ClientLocalization", new ClientLocalizationMessageResource());
configuration.add("Core", assetSource.resourceForPath("org/apache/tapestry5/core.properties"));
configuration.add("AppCatalog", applicationCatalog);
}
Aggregations