aboutsummaryrefslogtreecommitdiff
path: root/java/pablotron/luigi/Test.java
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2018-09-06 08:40:23 -0400
committerPaul Duncan <pabs@pablotron.org>2018-09-06 08:40:23 -0400
commitf422534cd4cf1ba32523c9fc798c207065038ca5 (patch)
treed3dce87dffeca2acfceab6aa9abf7046843f9145 /java/pablotron/luigi/Test.java
parentc02640d395fe95a41183a63bea29113676e92fae (diff)
downloadluigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.tar.bz2
luigi-template-f422534cd4cf1ba32523c9fc798c207065038ca5.zip
java: add pom.xml, mv sources to src/main/java/org/pablotron, add src/test, add initial junit tests, update makefile and .gitignore
Diffstat (limited to 'java/pablotron/luigi/Test.java')
-rw-r--r--java/pablotron/luigi/Test.java57
1 files changed, 0 insertions, 57 deletions
diff --git a/java/pablotron/luigi/Test.java b/java/pablotron/luigi/Test.java
deleted file mode 100644
index 7163c52..0000000
--- a/java/pablotron/luigi/Test.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package pablotron.luigi;
-
-import java.util.Map;
-import java.util.HashMap;
-
-import pablotron.luigi.LuigiError;
-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>() {{
- // add custom filter
- put("custom", new Filter.Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return "custom";
- }
- });
-
- // add custom filter with argument
- put("custom_with_arg", new Filter.Handler() {
- public String filter(String val, String args[], Map<String, String> row) {
- return (args.length > 0) ? args[0] : "custom";
- }
- });
- }};
-
- public static void main(String params[]) throws Exception {
- // 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));
- }
-};