Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.Environment


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 clear()
    {
        Environment e = new EnvironmentImpl();
        Runnable r1 = mockRunnable();
        Runnable r2 = mockRunnable();

        replay();

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

        e.clear();

        assertNull(e.peek(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 (RuntimeException ex)
        {
            assertEquals(
View Full Code Here

public class DefaultValidationDecoratorTest extends TapestryTestCase
{
    @Test
    public void label_has_no_field()
    {
        Environment env = newEnvironment();

        replay();

        ValidationDecorator decorator = new DefaultValidationDecorator(env);
View Full Code Here

    @Test
    public void label_error_no_existing_class_attribute()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);
View Full Code Here

    @Test
    public void label_error_with_existing_class_attribute()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);
View Full Code Here

    @Test
    public void field_error()
    {
        MarkupWriter writer = new MarkupWriterImpl(new XMLMarkupModel(), null);
        Environment env = newEnvironment();
        Field field = newField();
        ValidationTracker tracker = newValidationTracker();

        train_peekRequired(env, ValidationTracker.class, tracker);
        train_inError(tracker, field, true);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.