From 5e3358175b5026de5a7473988cbe9c2db9306e00 Mon Sep 17 00:00:00 2001 From: "pabs@pablotron.org" Date: Thu, 18 Dec 2014 16:41:11 -0500 Subject: add cache test --- java/pablotron/luigi/Test.java | 16 ++++++++++++++-- 1 file 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() {{ + put("test-template", TEMPLATE); + }}); + + // test arguments private static final Map args = new HashMap() {{ put("name", "paul"); }}; + // custom filters private static final Map filters = new HashMap() {{ put("custom", new Filter.Handler() { public String filter(String val, String args[], Map 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)); } }; -- cgit v1.2.3