public void testImmutableList() throws IOException { Object object = new Object() { List<String> people = singletonList("Test"); }; StringWriter sw = execute("isempty.html", singletonList(object)); assertEquals(getContents(root, "isempty.txt"), sw.toString()); }
public void testIsNotEmpty() throws IOException { Object object = new Object() { List<String> people = singletonList("Test"); }; StringWriter sw = execute("isempty.html", object); assertEquals(getContents(root, "isempty.txt"), sw.toString()); }
public void testRecursionWithInheritance() throws IOException { StringWriter sw = execute("recursion_with_inheritance.html", new Object() { Object value = new Object() { boolean value = false; }; }); assertEquals(getContents(root, "recursion.txt"), sw.toString()); }
public void testRecurision() throws IOException { StringWriter sw = execute("recursion.html", new Object() { Object value = new Object() { boolean value = false; }; }); assertEquals(getContents(root, "recursion.txt"), sw.toString()); }
public void testPartialRecursionWithInheritance() throws IOException { StringWriter sw = execute("recursive_partial_inheritance.html", new Object() { Object test = new Object() { boolean test = false; }; }); assertEquals(getContents(root, "recursive_partial_inheritance.txt"), sw.toString()); }
public void testChainedInheritance() throws IOException { StringWriter sw = execute("page.html", new Object() { Object test = new Object() { boolean test = false; }; }); assertEquals(getContents(root, "page.txt"), sw.toString()); }
public void testRelativePathsDotDotDirOverride() throws IOException { MustacheFactory mf = new DefaultMustacheFactory(root) { @Override public String resolvePartialPath(String dir, String name, String extension) { return name + extension; } }; Mustache compile = mf.compile("relative/nonrelative.html"); StringWriter sw = new StringWriter(); compile.execute(sw, "").close(); assertEquals(getContents(root, "nonrelative.html"), sw.toString()); }
public void testIdentitySimple() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = createMustacheFactory(); Mustache m = c.compile("simple.html"); StringWriter sw = new StringWriter(); m.identity(sw); assertEquals(getContents(root, "simple.html").replaceAll("\\s+", ""), sw.toString().replaceAll( "\\s+", "")); }
@Test public void testClientMethod() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new DefaultMustacheFactory(root); Mustache m = c.compile("client.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("reply", "TestReply"); scope.put("commands", Arrays.asList("a", "b")); m.execute(sw, scope); assertEquals(getContents(root, "client.txt"), sw.toString()); }
@Test public void testSubSub() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new DefaultMustacheFactory(root); Mustache m = c.compile("subsub.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("name", "Sam"); scope.put("randomid", "asdlkfj"); m.execute(sw, scope); assertEquals(getContents(root, "subsub.txt"), sw.toString()); }
@Test public void testSubInPartial() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new DefaultMustacheFactory(root); Mustache m = c.compile("partialsub.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("name", "Sam"); scope.put("randomid", "asdlkfj"); m.execute(sw, scope); assertEquals(getContents(root, "sub.txt"), sw.toString()); }
public void testRelativePathsSameDir() throws IOException { MustacheFactory mf = createMustacheFactory(); Mustache compile = mf.compile("relative/paths.html"); StringWriter sw = new StringWriter(); compile.execute(sw, "").close(); assertEquals(getContents(root, "relative/paths.txt"), sw.toString()); }
public void testRelativePathsDotDotDir() throws IOException { MustacheFactory mf = createMustacheFactory(); Mustache compile = mf.compile("relative/dotdot.html"); StringWriter sw = new StringWriter(); compile.execute(sw, "").close(); assertEquals(getContents(root, "uninterestingpartial.html"), sw.toString()); }
public void testIssue191() throws IOException { MustacheFactory mustacheFactory = createMustacheFactory(); Mustache mustache = mustacheFactory.compile("templates/someTemplate.mustache"); StringWriter stringWriter = new StringWriter(); mustache.execute(stringWriter, ImmutableMap.of("title", "Some title!")); assertEquals(getContents(root, "templates/someTemplate.txt"), stringWriter.toString()); }
@Test public void testSub() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new DefaultMustacheFactory(root); Mustache m = c.compile("sub.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("name", "Sam"); scope.put("randomid", "asdlkfj"); m.execute(sw, scope); assertEquals(getContents(root, "sub.txt"), sw.toString()); }
public void testRelativePathsRootDir() throws IOException { MustacheFactory mf = createMustacheFactory(); Mustache compile = mf.compile("relative/rootpath.html"); StringWriter sw = new StringWriter(); compile.execute(sw, "").close(); assertEquals(getContents(root, "relative/paths.txt"), sw.toString()); }
public void testPathsWithExtension() throws IOException { MustacheFactory mf = createMustacheFactory(); Mustache compile = mf.compile("relative/extension.html"); StringWriter sw = new StringWriter(); compile.execute(sw, "").close(); assertEquals(getContents(root, "relative/paths.txt"), sw.toString()); }
@Test public void testOverridePage1() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new FallbackMustacheFactory(rootOverride, rootDefault); Mustache m = c.compile("page1.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("title", "My title"); m.execute(sw, scope); assertEquals(getContents(rootOverride, "page1.txt"), sw.toString()); }
@Test public void testOverridePage2() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new FallbackMustacheFactory(rootOverride, rootDefault); Mustache m = c.compile("page2.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("title", "My title"); m.execute(sw, scope); assertEquals(getContents(rootOverride, "page2.txt"), sw.toString()); }
@Test public void testDefaultPage1() throws MustacheException, IOException, ExecutionException, InterruptedException { MustacheFactory c = new FallbackMustacheFactory(rootDefault, rootDefault); // no override Mustache m = c.compile("page1.html"); StringWriter sw = new StringWriter(); Map scope = new HashMap(); scope.put("title", "My title"); m.execute(sw, scope); assertEquals(getContents(rootDefault, "page1.txt"), sw.toString()); }