diff options
-rw-r--r-- | java/pablotron/luigi/Test.java | 16 |
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)); } }; |