Search in sources :

Example 6 with BufferingAppendable

use of com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable in project closure-templates by google.

the class BytecodeCompilerTest method render.

private String render(CompiledTemplates templates, SoyRecord params, String name) throws IOException {
    CompiledTemplate caller = templates.getTemplateFactory(name).create(params, EMPTY_DICT);
    BufferingAppendable builder = LoggingAdvisingAppendable.buffering();
    assertThat(caller.render(builder, getDefaultContext(templates))).isEqualTo(RenderResult.done());
    String output = builder.toString();
    return output;
}
Also used : BufferingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable) CompiledTemplate(com.google.template.soy.jbcsrc.shared.CompiledTemplate)

Example 7 with BufferingAppendable

use of com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable in project closure-templates by google.

the class AbstractLoggingAdvisingAppendableTest method testLogonly_logonly_above_regular.

@Test
public void testLogonly_logonly_above_regular() throws IOException {
    BufferingAppendable buffering = LoggingAdvisingAppendable.buffering();
    buffering.append("a");
    buffering.enterLoggableElement(LOGONLY);
    buffering.append("b");
    buffering.enterLoggableElement(NOT_LOGONLY);
    buffering.append("c");
    buffering.exitLoggableElement();
    buffering.append("d");
    buffering.exitLoggableElement();
    buffering.append("e");
    assertThat(buffering.toString()).isEqualTo("ae");
}
Also used : BufferingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable) Test(org.junit.Test)

Example 8 with BufferingAppendable

use of com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable in project closure-templates by google.

the class AbstractLoggingAdvisingAppendableTest method testLogonly_regular_above_logong.

@Test
public void testLogonly_regular_above_logong() throws IOException {
    BufferingAppendable buffering = LoggingAdvisingAppendable.buffering();
    buffering.append("a");
    buffering.enterLoggableElement(NOT_LOGONLY);
    buffering.append("b");
    buffering.enterLoggableElement(LOGONLY);
    buffering.append("c");
    buffering.exitLoggableElement();
    buffering.append("d");
    buffering.exitLoggableElement();
    buffering.append("e");
    assertThat(buffering.toString()).isEqualTo("abde");
}
Also used : BufferingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable) Test(org.junit.Test)

Example 9 with BufferingAppendable

use of com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable in project closure-templates by google.

the class AbstractLoggingAdvisingAppendableTest method testLogonly_deeplyNested.

@Test
public void testLogonly_deeplyNested() throws IOException {
    // test against the buffering version since it is a simple concrete implementation.
    BufferingAppendable buffering = LoggingAdvisingAppendable.buffering();
    buffering.append("a");
    for (int i = 0; i < 1024; i++) {
        buffering.enterLoggableElement(LOGONLY);
        buffering.append("b");
        buffering.exitLoggableElement();
    }
    buffering.append("c");
    assertThat(buffering.toString()).isEqualTo("ac");
}
Also used : BufferingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable) Test(org.junit.Test)

Example 10 with BufferingAppendable

use of com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable in project closure-templates by google.

the class SanitizersTest method testFilterNoAutoescapeStreamingText.

@Test
public void testFilterNoAutoescapeStreamingText() throws IOException {
    BufferingAppendable buffer = LoggingAdvisingAppendable.buffering();
    LoggingAdvisingAppendable escapingBuffer = Sanitizers.filterNoAutoescapeStreaming(buffer);
    escapingBuffer.setSanitizedContentKind(ContentKind.TEXT);
    assertThat(buffer.getAndClearBuffer()).isEqualTo("zSoyz");
    escapingBuffer.append("foo");
    assertThat(buffer.getAndClearBuffer()).isEmpty();
}
Also used : BufferingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable) LoggingAdvisingAppendable(com.google.template.soy.data.LoggingAdvisingAppendable) Test(org.junit.Test)

Aggregations

BufferingAppendable (com.google.template.soy.data.LoggingAdvisingAppendable.BufferingAppendable)27 Test (org.junit.Test)23 CompiledTemplate (com.google.template.soy.jbcsrc.shared.CompiledTemplate)14 CompiledTemplates (com.google.template.soy.jbcsrc.shared.CompiledTemplates)14 RenderContext (com.google.template.soy.jbcsrc.shared.RenderContext)13 RenderResult (com.google.template.soy.jbcsrc.api.RenderResult)6 LoggingAdvisingAppendable (com.google.template.soy.data.LoggingAdvisingAppendable)3 SoyRecord (com.google.template.soy.data.SoyRecord)3 SoyDict (com.google.template.soy.data.SoyDict)2 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 TemplateMetadata (com.google.template.soy.jbcsrc.shared.TemplateMetadata)1 IOException (java.io.IOException)1