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;
}
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");
}
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");
}
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");
}
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();
}
Aggregations