aboutsummaryrefslogtreecommitdiff
path: root/java/src/test
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-06 22:15:19 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-06 22:15:19 -0400
commit00da8bf65784b830925718569bde36d1ad43ab4a (patch)
tree9acc251c1c2eb17e99b9831f11f8aa2753b324ce /java/src/test
parent12403e241e5ce99836d7687e3dadcccb2afadb89 (diff)
downloadluigi-template-00da8bf65784b830925718569bde36d1ad43ab4a.tar.bz2
luigi-template-00da8bf65784b830925718569bde36d1ad43ab4a.zip
java: add javadoc for Cache, refactor TestResultHandler, add Cache#run with ResultHandler
Diffstat (limited to 'java/src/test')
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/CacheTest.java13
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java13
-rw-r--r--java/src/test/java/org/pablotron/luigi/tests/TestResultHandler.java15
3 files changed, 30 insertions, 11 deletions
diff --git a/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java b/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java
index 9aff8fc..f0e2ab5 100644
--- a/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java
+++ b/java/src/test/java/org/pablotron/luigi/tests/CacheTest.java
@@ -1,3 +1,5 @@
+package org.pablotron.luigi.tests;
+
import java.util.Map;
import java.util.HashMap;
@@ -40,4 +42,15 @@ public final class CacheTest {
final Cache cache = new Cache(TEST_TEMPLATES, TEST_FILTERS);
assertEquals("foo-custom-foo-filter-foo", cache.run("foo-custom", TEST_ARGS));
}
+
+ @Test
+ public void testCacheGetWithResultHandler() throws LuigiError {
+ final Cache cache = new Cache(TEST_TEMPLATES);
+ final StringBuilder sb = new StringBuilder();
+ final TestResultHandler rh = new TestResultHandler(sb);
+ cache.run("foo", TEST_ARGS, rh);
+
+ assertEquals("foofoofoo", sb.toString());
+ }
+
};
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 f4960cc..83a137d 100644
--- a/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java
+++ b/java/src/test/java/org/pablotron/luigi/tests/TemplateTest.java
@@ -1,3 +1,5 @@
+package org.pablotron.luigi.tests;
+
import java.util.Map;
import java.util.HashMap;
@@ -41,17 +43,6 @@ 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}");
diff --git a/java/src/test/java/org/pablotron/luigi/tests/TestResultHandler.java b/java/src/test/java/org/pablotron/luigi/tests/TestResultHandler.java
new file mode 100644
index 0000000..a847e79
--- /dev/null
+++ b/java/src/test/java/org/pablotron/luigi/tests/TestResultHandler.java
@@ -0,0 +1,15 @@
+package org.pablotron.luigi.tests;
+
+import org.pablotron.luigi.ResultHandler;
+
+public 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);
+ }
+};