use of org.apache.tapestry5.commons.Resource in project tapestry-5 by apache.
the class MutableComponentModelImplTest method get_persistent_field_names_reflects_parent_model.
@Test
public void get_persistent_field_names_reflects_parent_model() {
Resource r = mockResource();
Logger logger = mockLogger();
replay();
MutableComponentModel parent = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
assertEquals(parent.setFieldPersistenceStrategy("wilma", "session"), "wilma");
MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, parent, false, null);
assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred", "wilma"));
verify();
}
use of org.apache.tapestry5.commons.Resource in project tapestry-5 by apache.
the class MutableComponentModelImplTest method set_and_get_meta.
@Test
public void set_and_get_meta() {
Resource r = mockResource();
Logger logger = mockLogger();
replay();
MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
model.setMeta("fred", "flintstone");
model.setMeta("barney", "rubble");
assertEquals(model.getMeta("fred"), "flintstone");
assertEquals(model.getMeta("barney"), "rubble");
// Ensure case insensitive:
assertEquals(model.getMeta("FRED"), "flintstone");
assertEquals(model.getMeta("BARNEY"), "rubble");
verify();
}
use of org.apache.tapestry5.commons.Resource 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.commons.Resource 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.commons.Resource in project tapestry-5 by apache.
the class ClasspathAssetAliasManagerImplTest method failure_if_path_not_in_mapped_alias_folder.
@Test
public void failure_if_path_not_in_mapped_alias_folder() {
ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(configuration());
Resource resource = mockResource();
expect(resource.getPath()).andReturn("org/example/icons/flag.gif").atLeastOnce();
replay();
try {
manager.extractAssetAlias(resource);
unreachable();
} catch (UnknownValueException ex) {
assertMessageContains(ex, "Unable to create a client URL for classpath resource org/example/icons/flag.gif");
assertListsEquals(ex.getAvailableValues().getValues(), "com/example/mylib", "org/apache/tapestry5", "org/apache/tapestry5/internal");
}
verify();
}
Aggregations