Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.Environment


    @Test
    public void beaneditcontext_popped_from_environment()
    {
        ComponentResources resources = mockComponentResources();
        BeanModelSource source = mockBeanModelSource();
        Environment env = mockEnvironment();
        PropertyOverrides overrides = mockPropertyOverrides();

        expect(env.pop(BeanEditContext.class)).andReturn(null);
        expect(env.pop(BeanValidationContext.class)).andReturn(null);

        replay();

        BeanEditor component = new BeanEditor();
View Full Code Here


public class EnvironmentImplTest extends TapestryTestCase
{
    @Test
    public void peek_when_empty_returns_null()
    {
        Environment e = new EnvironmentImpl();

        assertNull(e.peek(Runnable.class));
        assertNull(e.peek(Map.class));
    }
View Full Code Here

    }

    @Test
    public void push_and_pop()
    {
        Environment e = new EnvironmentImpl();
        Runnable r1 = mockRunnable();
        Runnable r2 = mockRunnable();

        replay();

        assertNull(e.push(Runnable.class, r1));

        assertSame(r1, e.peek(Runnable.class));

        assertSame(r1, e.push(Runnable.class, r2));

        assertSame(r2, e.peek(Runnable.class));

        assertSame(r2, e.pop(Runnable.class));
        assertSame(r1, e.pop(Runnable.class));

        verify();
    }
View Full Code Here


    @Test
    public void pop_when_empty_is_error()
    {
        Environment e = new EnvironmentImpl();

        try
        {
            e.pop(Runnable.class);
            unreachable();
        } catch (NoSuchElementException ex)
        {
        }
    }
View Full Code Here

    }

    @Test
    public void peek_required_when_available()
    {
        Environment e = new EnvironmentImpl();
        Location l = mockLocation();

        replay();

        e.push(Location.class, l);

        assertSame(l, e.peekRequired(Location.class));

        verify();
    }
View Full Code Here

    }

    @Test
    public void peek_required_without_value_is_error()
    {
        Environment e = new EnvironmentImpl();
        Location l = mockLocation();
        Component c = mockComponent();

        replay();

        e.push(Location.class, l);
        e.push(Component.class, c);

        try
        {
            e.peekRequired(List.class);
            unreachable();
        } catch (UnknownValueException ex)
        {
            assertEquals(
                    ex.getMessage(),
View Full Code Here

    }
   
    @Test
    public void peek_required_does_not_list_previouly_available()
    {
        Environment e = new EnvironmentImpl();
        Location l = mockLocation();

        replay();

        e.push(Location.class, l);
        e.pop(Location.class);

        try
        {
            e.peekRequired(Location.class);
            unreachable();
        } catch (UnknownValueException ex)
        {
            assertEquals(
                    ex.getMessage(),
View Full Code Here

        BeanModelSource source = mockBeanModelSource();
        BeanModel model = mockBeanModel();
        RegistrationData data = new RegistrationData();
        Messages messages = mockMessages();
        PropertyOverrides overrides = mockPropertyOverrides();
        Environment env = EasyMock.createNiceMock(Environment.class);

        train_getBoundType(resources, "object", RegistrationData.class);

        train_createEditModel(source, RegistrationData.class, messages, model);
View Full Code Here

        BeanModel model = mockBeanModel();
        Location l = mockLocation();
        Throwable exception = new RuntimeException("Fall down go boom.");
        PropertyOverrides overrides = mockPropertyOverrides();
        Messages messages = mockMessages();
        Environment env = EasyMock.createNiceMock(Environment.class);

        train_getOverrideMessages(overrides, messages);

        train_getBoundType(resources, "object", Runnable.class);
View Full Code Here

    public void beaneditcontext_pushed_to_environment()
    {
        ComponentResources resources = mockComponentResources();
        BeanModelSource source = mockBeanModelSource();
        BeanModel model = mockBeanModel();
        Environment env = mockEnvironment();
        RegistrationData data = new RegistrationData();
        Messages messages = mockMessages();
        PropertyOverrides overrides = mockPropertyOverrides();

        train_getBoundType(resources, "object", RegistrationData.class);

        train_createEditModel(source, RegistrationData.class, messages, model);

        train_getOverrideMessages(overrides, messages);

        expect(model.newInstance()).andReturn(data);

        expect(model.getBeanType()).andReturn(RegistrationData.class);

        BeanEditContext ctxt = new BeanEditContext()
        {
            public Class<?> getBeanClass()
            {
                return RegistrationData.class;
            }

            public <T extends Annotation> T getAnnotation(Class<T> type)
            {
                return null;
            }
        };

        expect(env.push(eq(BeanEditContext.class), contextEq())).andReturn(ctxt);

        expect(env.push(eq(BeanValidationContext.class), isA(BeanValidationContext.class)))
                .andReturn(null);

        replay();

        BeanEditor component = new BeanEditor();
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.Environment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.