use of org.apache.tapestry5.ioc.services.ThreadLocale 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.ioc.services.ThreadLocale 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.ioc.services.ThreadLocale 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.ioc.services.ThreadLocale in project tapestry-5 by apache.
the class ComponentTemplateSourceImplTest method child_component_inherits_parent_template.
@Test
public void child_component_inherits_parent_template() {
TemplateParser parser = mockTemplateParser();
ComponentTemplate template = mockComponentTemplate();
ComponentModel model = mockComponentModel();
ComponentModel parentModel = mockComponentModel();
Resource resource = mockResource();
ComponentResourceLocator locator = mockLocator(model, english, null);
train_getComponentClassName(model, "foo.Bar");
train_getParentModel(model, parentModel);
expect(locator.locateTemplate(parentModel, english)).andReturn(resource).once();
expect(resource.exists()).andReturn(true);
expect(resource.toURL()).andReturn(null);
train_parseTemplate(parser, resource, template);
replay();
ComponentTemplateSource source = new ComponentTemplateSourceImpl(true, parser, locator, converter, componentRequestSelectorAnalyzer, threadLocale);
assertSame(source.getTemplate(model, english), template);
verify();
}
use of org.apache.tapestry5.ioc.services.ThreadLocale in project tapestry-5 by apache.
the class LocalizationSetterImplTest method set_nonpersistent_locale.
@Test
public void set_nonpersistent_locale() {
PersistentLocale pl = mockPersistentLocale();
ThreadLocale tl = mockThreadLocale();
Request request = mockRequest();
tl.setLocale(Locale.FRENCH);
replay();
LocalizationSetterImpl setter = new LocalizationSetterImpl(request, pl, tl, "en,fr");
setter.setNonPersistentLocaleFromLocaleName("fr_BE");
verify();
}
Aggregations