use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method found_in_component.
@Test
public void found_in_component() {
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
String completeId = "foo.Bar:baz";
train_getCompleteId(resources, completeId);
train_getComponentModel(resources, model);
train_getMeta(model, key, value);
train_expandSymbols(symbolSource, value, value);
replay();
Map<String, String> configuration = Collections.emptyMap();
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
verify();
// And check that it's cached:
train_getCompleteId(resources, completeId);
replay();
assertSame(locator.findMeta(key, resources, String.class), value);
verify();
}
use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method train_symbols_expanded_and_types_coerced.
/**
* Makes sense to test together to ensure that the expanded value is what's fed to the type
* coercer.
*/
@Test
public void train_symbols_expanded_and_types_coerced() {
ComponentResources resources = mockComponentResources();
ComponentModel model = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "${zaphod}";
String expandedValue = "99";
String completeId = "foo.Bar:baz";
train_getCompleteId(resources, completeId);
train_getComponentModel(resources, model);
train_getMeta(model, key, value);
train_expandSymbols(symbolSource, value, expandedValue);
replay();
Map<String, String> configuration = Collections.emptyMap();
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertEquals(locator.findMeta(key, resources, Integer.class), new Integer(99));
verify();
}
use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.
the class MetaDataLocatorImplTest method found_in_container.
@Test
public void found_in_container() {
ComponentResources resources = mockComponentResources();
ComponentResources containerResources = mockComponentResources();
ComponentModel model = mockComponentModel();
ComponentModel containerModel = mockComponentModel();
SymbolSource symbolSource = mockSymbolSource();
ComponentModelSource modelSource = mockComponentModelSource();
String key = "foo.bar";
String value = "zaphod";
String completeId = "foo.Bar:baz";
train_getCompleteId(resources, completeId);
train_getComponentModel(resources, model);
train_getMeta(model, key, null);
train_getContainerResources(resources, containerResources);
train_getComponentModel(containerResources, containerModel);
train_getMeta(containerModel, key, value);
train_expandSymbols(symbolSource, value, value);
replay();
Map<String, String> configuration = Collections.emptyMap();
MetaDataLocator locator = new MetaDataLocatorImpl(symbolSource, typeCoercer, modelSource, configuration);
assertSame(locator.findMeta(key, resources, String.class), value);
verify();
}
use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.
the class AssetObjectProviderTest method no_path_annotation.
@Test
public void no_path_annotation() {
AssetSource source = mockAssetSource();
ObjectLocator locator = mockObjectLocator();
AnnotationProvider annotationProvider = mockAnnotationProvider();
TypeCoercer typeCoercer = mockTypeCoercer();
SymbolSource symbolSource = mockSymbolSource();
train_getAnnotation(annotationProvider, Path.class, null);
replay();
ObjectProvider provider = new AssetObjectProvider(source, typeCoercer, symbolSource);
assertNull(provider.provide(Asset.class, annotationProvider, locator));
verify();
}
use of org.apache.tapestry5.ioc.services.SymbolSource in project tapestry-5 by apache.
the class AssetObjectProviderTest method normal_conversion.
@Test
public void normal_conversion() {
AssetSource source = mockAssetSource();
ObjectLocator locator = mockObjectLocator();
Asset asset = mockAsset();
String path = "${foo}";
String expanded = "foo/bar/baz.gif";
AnnotationProvider annotationProvider = mockAnnotationProvider();
TypeCoercer typeCoercer = mockTypeCoercer();
Path pathAnnotation = mockPath();
SymbolSource symbolSource = mockSymbolSource();
train_getAnnotation(annotationProvider, Path.class, pathAnnotation);
train_value(pathAnnotation, path);
train_expandSymbols(symbolSource, path, expanded);
train_getAsset(source, null, expanded, null, asset);
train_coerce(typeCoercer, asset, Asset.class, asset);
replay();
ObjectProvider provider = new AssetObjectProvider(source, typeCoercer, symbolSource);
Asset result = provider.provide(Asset.class, annotationProvider, locator);
assertSame(result, asset);
verify();
}
Aggregations