aboutsummaryrefslogtreecommitdiff
path: root/java/pablotron/luigi
diff options
context:
space:
mode:
authorpabs@pablotron.org <pabs@pablotron.org>2014-12-18 16:41:11 -0500
committerpabs@pablotron.org <pabs@pablotron.org>2014-12-18 16:41:11 -0500
commit5e3358175b5026de5a7473988cbe9c2db9306e00 (patch)
tree93616bb6ffb6d3adadbcf92a6a1d151c2ff1679c /java/pablotron/luigi
parent61777591e0c6010067dd2355c92cde75b088bfd8 (diff)
downloadluigi-template-5e3358175b5026de5a7473988cbe9c2db9306e00.tar.bz2
luigi-template-5e3358175b5026de5a7473988cbe9c2db9306e00.zip
add cache test
Diffstat (limited to 'java/pablotron/luigi')
-rw-r--r--java/pablotron/luigi/Test.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/java/pablotron/luigi/Test.java b/java/pablotron/luigi/Test.java
index e687308..1814a95 100644
--- a/java/pablotron/luigi/Test.java
+++ b/java/pablotron/luigi/Test.java
@@ -3,20 +3,29 @@ package pablotron.luigi;
import java.util.Map;
import java.util.HashMap;
import pablotron.luigi.LuigiError;
-import pablotron.luigi.Template;
import pablotron.luigi.Filter;
+import pablotron.luigi.Template;
+import pablotron.luigi.Cache;
public final class Test {
+ // test template
private static final String TEMPLATE =
"test basic: hello %{name}\n" +
"test filter: hello %{name | uc}\n" +
"test custom: %{name | custom | uc | lc}\n" +
"test custom_with_arg: %{name | custom_with_arg hello}\n";
+ // test template cache
+ private static final Cache cache = new Cache(new HashMap<String, String>() {{
+ put("test-template", TEMPLATE);
+ }});
+
+ // test arguments
private static final Map<String, String> args = new HashMap<String, String>() {{
put("name", "paul");
}};
+ // custom filters
private static final Map<String, Filter.Handler> filters = new HashMap<String, Filter.Handler>() {{
put("custom", new Filter.Handler() {
public String filter(String val, String args[], Map<String, String> row) {
@@ -32,11 +41,14 @@ public final class Test {
}};
public static void main(String cli_args[]) throws Exception {
- // add custom filters to default filter cache
+ // add custom filters
Filter.FILTERS.putAll(filters);
// create and run template
final Template t = new Template(TEMPLATE);
System.out.print(t.run(args));
+
+ // run cache
+ System.out.print(cache.run("test-template", args));
}
};