Search in sources :

Example 21 with Resource

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

the class MutableComponentModelImplTest method get_mixin_class_names_with_no_mixins.

@Test
public void get_mixin_class_names_with_no_mixins() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    ComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    assertTrue(model.getMixinClassNames().isEmpty());
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) ComponentModel(org.apache.tapestry5.model.ComponentModel) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) Test(org.testng.annotations.Test)

Example 22 with Resource

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

the class MutableComponentModelImplTest method add_parameters_to_embedded.

@Test
public void add_parameters_to_embedded() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    assertTrue(fred.getParameterNames().isEmpty());
    fred.addParameter("city", "bedrock");
    fred.addParameter("job", "crane operator");
    assertEquals(fred.getParameterNames(), Arrays.asList("city", "job"));
    assertEquals(fred.getParameterValue("city"), "bedrock");
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) Test(org.testng.annotations.Test)

Example 23 with Resource

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

the class MutableComponentModelImplTest method get_parent_from_subclass.

@Test
public void get_parent_from_subclass() {
    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);
    assertSame(child.getParentModel(), parent);
    assertNull(parent.getParentModel());
    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 24 with Resource

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

the class MutableComponentModelImplTest method add_embedded_component_with_duplicate_id.

@Test
public void add_embedded_component_with_duplicate_id() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    model.addEmbeddedComponent("fred", "Fred1", COMPONENT_CLASS_NAME, false, null);
    try {
        model.addEmbeddedComponent("fred", "Fred2", COMPONENT_CLASS_NAME, false, null);
        unreachable();
    } catch (IllegalArgumentException ex) {
        assertEquals(ex.getMessage(), "Embedded component 'fred' has already been defined for component class org.example.components.Foo.");
    }
    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 25 with Resource

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

the class MutableComponentModelImplTest method mixin_names_is_initially_empty_list.

@Test
public void mixin_names_is_initially_empty_list() {
    Resource r = mockResource();
    Logger logger = mockLogger();
    replay();
    MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null);
    MutableEmbeddedComponentModel fred = model.addEmbeddedComponent("fred", "Fred", COMPONENT_CLASS_NAME, false, null);
    assertTrue(fred.getMixinClassNames().isEmpty());
    verify();
}
Also used : Resource(org.apache.tapestry5.commons.Resource) MutableComponentModel(org.apache.tapestry5.model.MutableComponentModel) Logger(org.slf4j.Logger) MutableEmbeddedComponentModel(org.apache.tapestry5.model.MutableEmbeddedComponentModel) 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