aboutsummaryrefslogtreecommitdiff
path: root/java/src/test
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-06 08:57:51 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-06 08:57:51 -0400
commit2be7535e09e359d70b924013c9f4d25149fdf0ae (patch)
tree912223b1090cecc627c3ef7e845f4296acb88c51 /java/src/test
parentf422534cd4cf1ba32523c9fc798c207065038ca5 (diff)
downloadluigi-template-2be7535e09e359d70b924013c9f4d25149fdf0ae.tar.bz2
luigi-template-2be7535e09e359d70b924013c9f4d25149fdf0ae.zip
java: add src/main/java/org/pablotron/luigi/ResultHandler.java, update tests
Diffstat (limited to 'java/src/test')
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java24
1 files changed, 24 insertions, 0 deletions
diff --git a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java
index 5ff9ede..94e259e 100644
--- a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java
+++ b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java
@@ -3,6 +3,7 @@ import java.util.HashMap;
import org.pablotron.luigi.LuigiError;
import org.pablotron.luigi.Template;
+import org.pablotron.luigi.ResultHandler;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -35,6 +36,29 @@ public final class TemplateTest {
assertEquals("foofoo", r);
}
+ private static final class TestResultHandler implements ResultHandler {
+ private final StringBuilder sb;
+ public TestResultHandler(final StringBuilder sb) {
+ this.sb = sb;
+ }
+
+ public void append(final String s) {
+ sb.append(s);
+ }
+ };
+
+ @Test
+ public void testResultHandler() throws LuigiError {
+ final Template t = new Template("foo%{bar}");
+ final StringBuilder sb = new StringBuilder();
+ final TestResultHandler rh = new TestResultHandler(sb);
+
+ t.run(TEST_ARGS, rh);
+ final String r = sb.toString();
+
+ assertEquals("foofoo", sb.toString());
+ }
+
@Test
public void testMultipleKeys() throws LuigiError {
final Template t = new Template("foo%{bar}%{baz}");