Methods Summary |
---|
protected void | assertJavaFileCreated(java.lang.String filename)verify that a named file was created
File file = getOutputFile(filename);
assertTrue("file " + filename + " not found", file.exists());
assertTrue("file " + filename + " is empty", file.length() > 0);
|
protected void | assertMapped(org.apache.tools.ant.taskdefs.optional.jsp.JspMangler mangler, java.lang.String filename, java.lang.String classname)assert our mapping rules
String mappedname = mangler.mapJspToJavaName(new File(filename));
assertTrue(filename+" should have mapped to "+classname
+" but instead mapped to "+mappedname,
classname.equals(mappedname));
|
protected void | executeJspCompile(java.lang.String target, java.lang.String javafile)run a target then verify the named file gets created
executeTarget(target);
assertJavaFileCreated(javafile);
|
protected java.io.File | getOutputFile(java.lang.String subpath)Gets the OutputFile attribute of the JspcTest object
return new File(outDir, subpath);
|
public void | setUp()The JUnit setup method
configureProject(TASKDEFS_DIR + "jspc.xml");
baseDir = new File(System.getProperty("root"), TASKDEFS_DIR);
outDir = new File(baseDir, "jsp/java");
|
public void | tearDown()The teardown method for JUnit
executeTarget("cleanup");
|
public void | testInvalidClassname()what happens to 1nvalid-classname
executeJspCompile("testInvalidClassname",
"_1nvalid_0002dclassname_jsp.java");
|
public void | testJasper41()
JspMangler mangler = new Jasper41Mangler();
//java keywords are not special
assertMapped(mangler, "for.jsp", "for_jsp");
//underscores go in front of invalid start chars
assertMapped(mangler, "0.jsp", "_0_jsp");
//underscores at the front get an underscore too
assertMapped(mangler, "_.jsp", "___jsp");
//non java char at start => underscore then the the _hex value
assertMapped(mangler, "-.jsp", "__0002d_jsp");
//and paths are stripped
char s = File.separatorChar;
assertMapped(mangler, "" + s + s + "somewhere" + s + "file" + s + "index.jsp", "index_jsp");
|
public void | testJasperNameManglerSelection()verify that we select the appropriate mangler
JspCompilerAdapter adapter=
JspCompilerAdapterFactory.getCompiler("jasper", null,null);
JspMangler mangler=adapter.createMangler();
assertTrue(mangler instanceof JspNameMangler);
adapter= JspCompilerAdapterFactory.getCompiler("jasper41", null, null);
mangler = adapter.createMangler();
assertTrue(mangler instanceof Jasper41Mangler);
|
public void | testKeyword()try a keyword in a file
executeJspCompile("testKeyword", "default_jsp.java");
|
public void | testNoTld()A unit test for JUnit
// expectBuildExceptionContaining("testNoTld",
// "Jasper found an error in a file",
// "Java returned: 9");
expectBuildExceptionContaining("testNoTld",
"not found",
"Java returned: 9");
|
public void | testNotAJspFile()A unit test for JUnit
executeTarget("testNotAJspFile");
|
public void | testSimple()A unit test for JUnit
executeJspCompile("testSimple", "simple_jsp.java");
|
public void | testUriroot()A unit test for JUnit
executeJspCompile("testUriroot", "uriroot_jsp.java");
|
public void | testXml()A unit test for JUnit
executeJspCompile("testXml", "xml_jsp.java");
|