Search in sources :

Example 11 with Resource

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

the class ClasspathAssetAliasManagerImplTest method can_not_map_resource_path_that_matches_virtual_folder.

@Test
public void can_not_map_resource_path_that_matches_virtual_folder() throws IOException {
    Resource r = mockResource();
    expect(r.getPath()).andReturn("com/example/mylib");
    replay();
    ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(configuration());
    try {
        manager.extractAssetAlias(r);
        unreachable();
    } catch (IllegalArgumentException ex) {
    }
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) ClasspathAssetAliasManager(org.apache.tapestry5.services.ClasspathAssetAliasManager) Test(org.testng.annotations.Test)

Example 12 with Resource

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

the class ClasspathAssetAliasManagerImplTest method to_client_url.

@Test(dataProvider = "to_client_url_data")
public void to_client_url(String resourcePath, String expectedFolder, String expectedPath) throws IOException {
    Resource r = mockResource();
    expect(r.getPath()).andReturn(resourcePath);
    replay();
    ClasspathAssetAliasManager manager = new ClasspathAssetAliasManagerImpl(configuration());
    AssetAlias alias = manager.extractAssetAlias(r);
    assertEquals(alias.virtualFolder, expectedFolder);
    assertEquals(alias.path, expectedPath);
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) AssetAlias(org.apache.tapestry5.services.AssetAlias) ClasspathAssetAliasManager(org.apache.tapestry5.services.ClasspathAssetAliasManager) Test(org.testng.annotations.Test)

Example 13 with Resource

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

the class MutableComponentModelImplTest method handles_render_phase.

/**
 * @since 5.0.19
 */
@Test
public void handles_render_phase() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    model.addRenderPhase(BeginRender.class);
    assertTrue(model.getHandledRenderPhases().contains(BeginRender.class));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) BeginRender(org.apache.tapestry5.annotations.BeginRender) Test(org.testng.annotations.Test)

Example 14 with Resource

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

the class MutableComponentModelImplTest method get_persistent_field_names_are_sorted.

@Test
public void get_persistent_field_names_are_sorted() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertEquals(model.setFieldPersistenceStrategy("fred", "session"), "fred");
    assertEquals(model.setFieldPersistenceStrategy("barney", "client"), "barney");
    assertEquals(model.getPersistentFieldNames(), Arrays.asList("barney", "fred"));
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 15 with Resource

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

the class MutableComponentModelImplTest method child_meta_overrides_parent_meta.

@Test
public void child_meta_overrides_parent_meta() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel parent = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableComponentModel child = new MutableComponentModelImpl(CLASS_NAME, logger, r, parent, false, null);
    parent.setMeta("fred", "flintstone");
    child.setMeta("fred", "mcmurray");
    assertEquals(parent.getMeta("fred"), "flintstone");
    assertEquals(child.getMeta("fred"), "mcmurray");
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Aggregations

Resource (org.apache.tapestry5.commons.Resource)78 Test (org.testng.annotations.Test)62 MutableComponentModel (org.apache.tapestry5.model.MutableComponentModel)38 Logger (org.slf4j.Logger)38 ClasspathResource (org.apache.tapestry5.ioc.internal.util.ClasspathResource)16 Asset (org.apache.tapestry5.Asset)14 ComponentModel (org.apache.tapestry5.model.ComponentModel)10 MutableEmbeddedComponentModel (org.apache.tapestry5.model.MutableEmbeddedComponentModel)10 ComponentTemplate (org.apache.tapestry5.internal.parser.ComponentTemplate)6 AssetFactory (org.apache.tapestry5.services.AssetFactory)6 IOException (java.io.IOException)5 AssetSource (org.apache.tapestry5.services.AssetSource)5 ComponentResourceLocator (org.apache.tapestry5.services.pageload.ComponentResourceLocator)5 Context (org.apache.tapestry5.http.services.Context)4 BeginRender (org.apache.tapestry5.annotations.BeginRender)3 Location (org.apache.tapestry5.commons.Location)3 AbstractResource (org.apache.tapestry5.ioc.internal.util.AbstractResource)3 ThreadLocale (org.apache.tapestry5.ioc.services.ThreadLocale)3 ClasspathAssetAliasManager (org.apache.tapestry5.services.ClasspathAssetAliasManager)3 StreamableResource (org.apache.tapestry5.services.assets.StreamableResource)3