Search in sources :

Example 1 with RenderQueue

use of org.apache.tapestry5.runtime.RenderQueue in project tapestry-5 by apache.

the class CompositeRenderCommandTest method render_queue_commands_nyi.

@Test(dataProvider = "nyi_data")
public void render_queue_commands_nyi(RenderCommand rc) {
    MarkupWriter writer = mockMarkupWriter();
    RenderQueue queue = mockRenderQueue();
    try {
        new CompositeRenderCommand(new RenderCommand[] { rc }).render(writer, queue);
        unreachable();
    } catch (IllegalStateException ex) {
    // Don't care about the message.
    }
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 2 with RenderQueue

use of org.apache.tapestry5.runtime.RenderQueue in project tapestry-5 by apache.

the class RenderQueueImplTest method run_commands.

@Test
public void run_commands() {
    final RenderCommand command2 = newMock(RenderCommand.class);
    RenderCommand command1 = new RenderCommand() {

        public void render(MarkupWriter writer, RenderQueue queue) {
            queue.push(command2);
        }
    };
    Logger logger = mockLogger();
    MarkupWriter writer = mockMarkupWriter();
    RenderQueueImpl queue = new RenderQueueImpl(logger);
    // There's only one check for trace enabled now.
    expect(logger.isTraceEnabled(TapestryMarkers.RENDER_COMMANDS)).andReturn(false);
    expect(logger.isDebugEnabled()).andReturn(true);
    logger.debug(eq(TapestryMarkers.RENDER_COMMANDS), isA(String.class));
    command2.render(writer, queue);
    replay();
    queue.push(command1);
    queue.run(writer);
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) Logger(org.slf4j.Logger) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 3 with RenderQueue

use of org.apache.tapestry5.runtime.RenderQueue in project tapestry-5 by apache.

the class RenderQueueImplTest method command_failed.

@Test
public void command_failed() {
    ComponentResources foo = mockInternalComponentResources();
    ComponentResources bar = mockInternalComponentResources();
    ComponentResources baz = mockInternalComponentResources();
    final RuntimeException t = new RuntimeException("Oops.");
    RenderCommand rc = new RenderCommand() {

        public void render(MarkupWriter writer, RenderQueue queue) {
            throw t;
        }

        @Override
        public String toString() {
            return "FailedCommand";
        }
    };
    Logger logger = mockLogger();
    MarkupWriter writer = mockMarkupWriter();
    expect(logger.isTraceEnabled(TapestryMarkers.RENDER_COMMANDS)).andReturn(false);
    expect(logger.isDebugEnabled()).andReturn(true);
    logger.error("Render queue error in FailedCommand: Oops.", t);
    replay();
    RenderQueueImpl queue = new RenderQueueImpl(logger);
    queue.startComponent(foo);
    queue.startComponent(bar);
    queue.endComponent();
    queue.startComponent(baz);
    queue.push(rc);
    try {
        queue.run(writer);
        unreachable();
    } catch (RenderQueueException ex) {
        assertSame(ex.getCause(), t);
        assertArraysEqual(ex.getActiveComponents(), new Object[] { foo, baz });
    }
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) Logger(org.slf4j.Logger) MarkupWriter(org.apache.tapestry5.MarkupWriter) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 4 with RenderQueue

use of org.apache.tapestry5.runtime.RenderQueue in project tapestry-5 by apache.

the class BlockImplTest method body_pushed_to_queue_backwards.

@Test
public void body_pushed_to_queue_backwards() {
    BlockImpl block = new BlockImpl(null, null);
    RenderQueue queue = mockRenderQueue();
    MarkupWriter writer = mockMarkupWriter();
    RenderCommand element1 = mockRenderCommand();
    RenderCommand element2 = mockRenderCommand();
    getMocksControl().checkOrder(true);
    queue.push(element2);
    queue.push(element1);
    replay();
    block.addToBody(element1);
    block.addToBody(element2);
    block.render(writer, queue);
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Example 5 with RenderQueue

use of org.apache.tapestry5.runtime.RenderQueue in project tapestry-5 by apache.

the class ExpansionPageElementImplTest method invariant_binding_is_cached.

@Test
public void invariant_binding_is_cached() {
    Binding binding = mockBinding();
    TypeCoercer coercer = mockTypeCoercer();
    MarkupWriter writer = mockMarkupWriter();
    RenderQueue queue = mockRenderQueue();
    Object value = new Object();
    train_isInvariant(binding, true);
    replay();
    RenderCommand element = new ExpansionPageElement(binding, coercer);
    verify();
    train_get(binding, value);
    train_coerce(coercer, value, String.class, "STRING-VALUE");
    writer.write("STRING-VALUE");
    replay();
    element.render(writer, queue);
    verify();
    // It is now cached ...
    writer.write("STRING-VALUE");
    replay();
    element.render(writer, queue);
    verify();
}
Also used : Binding(org.apache.tapestry5.Binding) RenderCommand(org.apache.tapestry5.runtime.RenderCommand) TypeCoercer(org.apache.tapestry5.commons.services.TypeCoercer) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Aggregations

MarkupWriter (org.apache.tapestry5.MarkupWriter)14 RenderQueue (org.apache.tapestry5.runtime.RenderQueue)14 RenderCommand (org.apache.tapestry5.runtime.RenderCommand)13 Test (org.testng.annotations.Test)9 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)3 Binding (org.apache.tapestry5.Binding)2 Block (org.apache.tapestry5.Block)2 ComponentResources (org.apache.tapestry5.ComponentResources)2 Renderable (org.apache.tapestry5.Renderable)2 TapestryException (org.apache.tapestry5.commons.internal.util.TapestryException)2 Element (org.apache.tapestry5.dom.Element)2 Logger (org.slf4j.Logger)2 AccessControlException (java.security.AccessControlException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Calendar (java.util.Calendar)1 Collection (java.util.Collection)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1