Search in sources :

Example 11 with SymbolSource

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();
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) ComponentModel(org.apache.tapestry5.model.ComponentModel) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 12 with SymbolSource

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();
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) ComponentModel(org.apache.tapestry5.model.ComponentModel) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 13 with SymbolSource

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();
}
Also used : SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) ComponentModel(org.apache.tapestry5.model.ComponentModel) MetaDataLocator(org.apache.tapestry5.services.MetaDataLocator) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 14 with SymbolSource

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();
}
Also used : AssetSource(org.apache.tapestry5.services.AssetSource) SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) AnnotationProvider(org.apache.tapestry5.commons.AnnotationProvider) ObjectLocator(org.apache.tapestry5.commons.ObjectLocator) Asset(org.apache.tapestry5.Asset) ObjectProvider(org.apache.tapestry5.commons.ObjectProvider) Test(org.testng.annotations.Test)

Example 15 with SymbolSource

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();
}
Also used : AssetSource(org.apache.tapestry5.services.AssetSource) Path(org.apache.tapestry5.annotations.Path) SymbolSource(org.apache.tapestry5.ioc.services.SymbolSource) TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) AnnotationProvider(org.apache.tapestry5.commons.AnnotationProvider) ObjectLocator(org.apache.tapestry5.commons.ObjectLocator) Asset(org.apache.tapestry5.Asset) ObjectProvider(org.apache.tapestry5.commons.ObjectProvider) Test(org.testng.annotations.Test)

Aggregations

SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)15 Test (org.testng.annotations.Test)13 ComponentModel (org.apache.tapestry5.model.ComponentModel)9 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)9 ComponentResources (org.apache.tapestry5.ComponentResources)7 Asset (org.apache.tapestry5.Asset)3 AssetSource (org.apache.tapestry5.services.AssetSource)3 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)2 ObjectLocator (org.apache.tapestry5.commons.ObjectLocator)2 ObjectProvider (org.apache.tapestry5.commons.ObjectProvider)2 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)2 AssetPathProcessor (com.flowlogix.web.services.internal.AssetPathProcessor)1 Formatter (java.util.Formatter)1 ServletContext (javax.servlet.ServletContext)1 Path (org.apache.tapestry5.annotations.Path)1 Resource (org.apache.tapestry5.commons.Resource)1 SymbolBeanFactoryPostProcessor (org.apache.tapestry5.internal.spring.SymbolBeanFactoryPostProcessor)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)1 ServiceActivity (org.apache.tapestry5.ioc.services.ServiceActivity)1