Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.Environment


    }

    @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 clear()
    {
        Environment e = new EnvironmentImpl();

        try
        {
            e.clear();
            unreachable();
        } catch (IllegalStateException ex)
        {
            assertMessageContains(ex, "no longer supported");
        }
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 proxy_class()
    {
        JavaScriptSupport delegate = newMock(JavaScriptSupport.class);
        Environment env = mockEnvironment();

        train_peekRequired(env, JavaScriptSupport.class, delegate);

        expect(delegate.allocateClientId("fred")).andReturn("barney");
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_create(source, RegistrationData.class, true, 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_create(source, RegistrationData.class, true, 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(EasyMock.eq(BeanEditContext.class), contextEq())).andReturn(ctxt);
        replay();

        BeanEditor component = new BeanEditor();

        component.inject(resources, overrides, source,env);
View Full Code Here

    @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);
       
        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.