Search in sources :

Example 96 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class MetaDataLocatorImplTest method subfolder_default_overrides_high_level_default.

@Test
public void subfolder_default_overrides_high_level_default() {
    ComponentResources resources = mockComponentResources();
    ComponentModel model = mockComponentModel();
    SymbolSource symbolSource = mockSymbolSource();
    ComponentModelSource modelSource = mockComponentModelSource();
    String key = "foo.bar";
    String value = "zaphod";
    String completeId = "foo.Bar";
    train_getCompleteId(resources, completeId);
    train_getComponentModel(resources, model);
    train_getMeta(model, key, null);
    train_getContainerResources(resources, null);
    train_getPageName(resources, "foo/Bar");
    train_expandSymbols(symbolSource, value, value);
    replay();
    Map<String, String> configuration = newMap();
    configuration.put(key, "xxx");
    configuration.put("foo:" + key, value);
    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 97 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class MetaDataLocatorImplTest method found_via_high_level_default.

@Test
public void found_via_high_level_default() {
    ComponentResources resources = mockComponentResources();
    ComponentModel model = mockComponentModel();
    SymbolSource symbolSource = mockSymbolSource();
    ComponentModelSource modelSource = mockComponentModelSource();
    String key = "foo.bar";
    String value = "zaphod";
    String completeId = "Bar";
    String logicalPageName = completeId;
    train_getCompleteId(resources, completeId);
    train_getComponentModel(resources, model);
    train_getMeta(model, key, null);
    train_getContainerResources(resources, null);
    train_getPageName(resources, logicalPageName);
    train_expandSymbols(symbolSource, value, value);
    replay();
    Map<String, String> configuration = newMap();
    configuration.put(key, value);
    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 98 with ComponentResources

use of org.apache.tapestry5.ComponentResources in project tapestry-5 by apache.

the class MetaDataLocatorImplTest method default_matching_is_case_insensitive.

@Test
public void default_matching_is_case_insensitive() {
    ComponentResources resources = mockComponentResources();
    ComponentModel model = mockComponentModel();
    SymbolSource symbolSource = mockSymbolSource();
    ComponentModelSource modelSource = mockComponentModelSource();
    String key = "foo.bar";
    String value = "zaphod";
    String completeId = "foo.Bar";
    train_getCompleteId(resources, completeId);
    train_getComponentModel(resources, model);
    train_getMeta(model, key, null);
    train_getContainerResources(resources, null);
    train_getPageName(resources, "foo/Bar");
    train_expandSymbols(symbolSource, value, value);
    replay();
    Map<String, String> configuration = newMap();
    configuration.put(key.toUpperCase(), value);
    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 99 with ComponentResources

use of org.apache.tapestry5.ComponentResources 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 100 with ComponentResources

use of org.apache.tapestry5.ComponentResources 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)

Aggregations

ComponentResources (org.apache.tapestry5.ComponentResources)110 Test (org.testng.annotations.Test)99 Location (org.apache.tapestry5.commons.Location)34 Binding (org.apache.tapestry5.Binding)24 Messages (org.apache.tapestry5.commons.Messages)24 ComponentModel (org.apache.tapestry5.model.ComponentModel)17 FormSupport (org.apache.tapestry5.services.FormSupport)17 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)16 Component (org.apache.tapestry5.runtime.Component)15 MarkupWriter (org.apache.tapestry5.MarkupWriter)14 FieldValidator (org.apache.tapestry5.FieldValidator)13 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)13 FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)13 Validator (org.apache.tapestry5.Validator)11 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)11 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)10 BindingFactory (org.apache.tapestry5.services.BindingFactory)10 PropertyOverrides (org.apache.tapestry5.PropertyOverrides)9 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)9 Request (org.apache.tapestry5.http.services.Request)7