Search in sources :

Example 56 with TypeCoercer

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

the class InternalComponentResourcesImplTest method render_informal_parameters_no_bindings.

@Test
public void render_informal_parameters_no_bindings() {
    ComponentPageElement element = mockComponentPageElement();
    Component component = mockComponent();
    Instantiator ins = mockInstantiator(component);
    MarkupWriter writer = mockMarkupWriter();
    TypeCoercer coercer = mockTypeCoercer();
    ComponentModel model = mockComponentModel();
    train_getModel(ins, model);
    replay();
    InternalComponentResources resources = new InternalComponentResourcesImpl(null, element, null, elementResources, null, null, ins, false);
    resources.renderInformalParameters(writer);
    verify();
}
Also used : InternalComponentResources(org.apache.tapestry5.internal.InternalComponentResources) TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) ComponentModel(org.apache.tapestry5.model.ComponentModel) Instantiator(org.apache.tapestry5.internal.services.Instantiator) Component(org.apache.tapestry5.runtime.Component) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 57 with TypeCoercer

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

the class InternalComponentResourcesImplTest method setup.

@BeforeClass
public void setup() {
    perThreadManager = getService(PerthreadManager.class);
    TypeCoercer typeCoercer = getService(TypeCoercer.class);
    elementResources = new ComponentPageElementResourcesImpl(null, null, typeCoercer, null, null, null, null, null, null, null, perThreadManager, false, false, null);
}
Also used : TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) PerthreadManager(org.apache.tapestry5.ioc.services.PerthreadManager) BeforeClass(org.testng.annotations.BeforeClass)

Example 58 with TypeCoercer

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

the class EnumValueEncoderTest method valid_values_can_be_retrieved_from_exception.

@Test
public // TAP5-1331
void valid_values_can_be_retrieved_from_exception() {
    TypeCoercer typeCoercer = getService(TypeCoercer.class);
    EnumValueEncoder<Stooge> encoder = new EnumValueEncoder<Stooge>(typeCoercer, Stooge.class);
    try {
        encoder.toValue("Foo");
        fail();
    } catch (RuntimeException e) {
        assertTrue(e.getCause() instanceof UnknownValueException);
        UnknownValueException cause = (UnknownValueException) e.getCause();
        List<String> availableValues = cause.getAvailableValues().getValues();
        assertTrue(availableValues.contains("MOE"));
        assertTrue(availableValues.contains("LARRY"));
        assertTrue(availableValues.contains("CURLY_JOE"));
    }
}
Also used : TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) UnknownValueException(org.apache.tapestry5.commons.util.UnknownValueException) List(java.util.List) Test(org.testng.annotations.Test)

Example 59 with TypeCoercer

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

the class PageCallbackTest method callback_with_context.

@Test
public void callback_with_context() {
    EventContext context = new ArrayEventContext(typeCoercer, 1, 2);
    PageRenderLinkSource source = mockPageRenderLinkSource();
    Link link = mockLink();
    expect(source.createPageRenderLinkWithContext("bar", "1", "2")).andReturn(link);
    PageCallback pc = new PageCallback("bar", context);
    assertEquals(pc.toString(), "PageCallback[bar 1/2]");
    replay();
    assertSame(pc.toLink(source), link);
    verify();
}
Also used : ArrayEventContext(org.apache.tapestry5.internal.services.ArrayEventContext) EventContext(org.apache.tapestry5.EventContext) ArrayEventContext(org.apache.tapestry5.internal.services.ArrayEventContext) PageRenderLinkSource(org.apache.tapestry5.services.PageRenderLinkSource) PageCallback(org.apache.tapestry5.PageCallback) Link(org.apache.tapestry5.http.Link) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)43 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)27 ComponentResources (org.apache.tapestry5.ComponentResources)19 Messages (org.apache.tapestry5.commons.Messages)13 FieldValidator (org.apache.tapestry5.FieldValidator)11 Validator (org.apache.tapestry5.Validator)11 SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)11 FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)11 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)11 Link (org.apache.tapestry5.http.Link)10 ComponentModel (org.apache.tapestry5.model.ComponentModel)10 FormSupport (org.apache.tapestry5.services.FormSupport)10 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)9 MetaDataLocator (org.apache.tapestry5.services.MetaDataLocator)9 EventContext (org.apache.tapestry5.EventContext)7 ComponentEventLinkEncoder (org.apache.tapestry5.services.ComponentEventLinkEncoder)7 PageRenderRequestParameters (org.apache.tapestry5.services.PageRenderRequestParameters)7 LinkCreationListener2 (org.apache.tapestry5.services.LinkCreationListener2)6 MarkupWriter (org.apache.tapestry5.MarkupWriter)5 HibernateEntityValueEncoder (org.apache.tapestry5.hibernate.web.internal.HibernateEntityValueEncoder)4