use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testSubLayout.
@Test
public void testSubLayout() throws IOException {
String src = readFile("JapidSample/app/japidviews/_layouts/SubLayout.html");
JapidTemplate bt = new JapidTemplate("japidviews/_layouts/SubLayout.html", src);
JapidAbstractCompiler cp = new JapidLayoutCompiler();
cp.compile(bt);
String srccode = bt.javaSource;
System.out.println(srccode);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
assertTrue(srccode.contains("package japidviews._layouts;"));
assertTrue(srccode.contains("public abstract class SubLayout extends Layout"));
assertTrue(srccode.contains("protected abstract void doLayout();"));
assertTrue(srccode.contains("@Override public void layout()"));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testCompileLayout.
@Test
public void testCompileLayout() throws IOException {
String src = readFile("JapidSample/app/japidviews/_layouts/Layout.html");
JapidTemplate bt = new JapidTemplate("tag/Layout.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.JapidAbstractCompiler 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.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testOpenForInDef.
@Test
public void testOpenForInDef() throws IOException, ParseException {
String src = readFile("tests/openForInDef.html");
JapidTemplate bt = new JapidTemplate("tests/openForInDef.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
CompilationUnit cu = JavaSyntaxTool.parse(bt.javaSource);
System.out.println(cu);
// assertTrue("invalid java code", JavaSyntaxValidator.isValid(bt.javaSource));
}
use of cn.bran.japid.compiler.JapidAbstractCompiler in project Japid by branaway.
the class CompilerTests method testTagBlock.
@Test
public void testTagBlock() throws IOException {
String srcFile = "JapidSample/app/japidviews/templates/tagBody.html";
String src = readFile(srcFile);
JapidTemplate bt = new JapidTemplate("japidviews/templates/tagBody.html", src);
JapidAbstractCompiler cp = new JapidTemplateCompiler();
cp.compile(bt);
System.out.println(bt.javaSource);
assertTrue("invalid java code", JavaSyntaxTool.isValid(bt.javaSource));
// assertTrue(bt.javaSource.contains("((anotherTag)(new anotherTag(getOut())).setActionRunners(getActionRunners())).render(echo, new anotherTag.DoBody<String>(){"));
assertTrue(bt.javaSource.contains("new moreTag(tagBody.this)"));
}
Aggregations