use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testGetDirective.
@Test
public void testGetDirective() throws IOException, ParseException {
String srcFile = "tests/getTag.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("tests/getTag.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
// assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "title", Modifier.PROTECTED, "void", ""));
assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "footer", Modifier.PROTECTED, "void", ""));
assertTrue("method is not declared", JavaSyntaxTool.hasMethod(cu, "doLayout", Modifier.PROTECTED | Modifier.ABSTRACT, "void", ""));
assertTrue("method is never called", JavaSyntaxTool.hasMethodInvocatioin(cu, "title"));
assertTrue("method is never called", JavaSyntaxTool.hasMethodInvocatioin(cu, "footer"));
// assertTrue(bt.javaSource.contains("@Override protected void message() {"));
// assertTrue(bt.javaSource.contains("@Override protected void title() {"));
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testOpenFor.
@Test
public void testOpenFor() throws IOException {
String src = readFile("tests/openFor.html");
JapidTemplate bt = new JapidTemplate("tests/openFor.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testLayoutWithArgs.
@Test
public void testLayoutWithArgs() throws IOException {
String src = readFile("JapidSample/app/japidviews/more/Perf/perfmain.html");
JapidTemplate bt = new JapidTemplate("more/Perf/perfmain.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testAnotherLayout.
@Test
public void testAnotherLayout() throws IOException, ParseException {
String src = readFile("JapidSample/app/japidviews/_layouts/TagLayout.html");
JapidTemplate bt = new JapidTemplate("japidviews/_layouts/TagLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
CompilationUnit cu = JavaSyntaxTool.parse(srccode);
assertTrue(srccode.contains("package japidviews._layouts;"));
assertTrue(srccode.contains("public abstract class TagLayout extends cn.bran.play.JapidTemplateBase"));
assertTrue(srccode.contains("protected abstract void doLayout();"));
assertTrue(srccode.contains("@Override public void layout()"));
}
use of cn.bran.japid.compiler.JapidLayoutCompiler in project Japid by branaway.
the class CompilerTests method testIfCommand.
@Test
public void testIfCommand() throws IOException {
String src = readFile("JapidSample/app/japidviews/Application/ifs.html");
JapidTemplate bt = new JapidTemplate("Application/ifs.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String javaSource = bt.javaSource;
System.out.println(javaSource);
assertTrue(javaSource.contains("if(!asBoolean(ss))"));
assertTrue(javaSource.contains("else if(!asBoolean(ss))"));
assertTrue("invalid java code", JavaSyntaxTool.isValid(javaSource));
}
Aggregations