1 27 package org.htmlparser.tests.scannersTests; 28 29 import org.htmlparser.PrototypicalNodeFactory; 30 import org.htmlparser.tags.JspTag; 31 import org.htmlparser.tests.ParserTestCase; 32 import org.htmlparser.util.ParserException; 33 34 public class JspScannerTest extends ParserTestCase { 35 36 static 37 { 38 System.setProperty ("org.htmlparser.tests.scannersTests.JspScannerTest", "JspScannerTest"); 39 } 40 41 private static final boolean JSP_TESTS_ENABLED = false; 42 43 public JspScannerTest(String name) { 44 super(name); 45 } 46 47 51 public void testScan() throws ParserException { 52 createParser( 53 "<h1>\n"+ 54 "This is a <%=object%>\n"+ 55 "</h1>"); 56 57 parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ())); 58 parseAndAssertNodeCount(5); 59 assertTrue("Third should be an JspTag",node[2] instanceof JspTag); 61 JspTag tag = (JspTag)node[2]; 62 assertEquals("tag contents","%=object%",tag.getText()); 63 } 64 65 71 public void testUnclosedTagInsideJsp() throws ParserException { 72 if (JSP_TESTS_ENABLED) 73 { 74 createParser( 75 "<%\n" + 76 "public String getHref(String value) \n" + 77 "{ \n" + 78 "int indexs = value.indexOf(\"<A HREF=\");\n" + 79 "int indexe = value.indexOf(\">\");\n" + 80 "if (indexs != -1) {\n" + 81 "return value.substring(indexs+9,indexe-2);\n" + 82 "}\n" + 83 "return value;\n" + 84 "}\n" + 85 "%>"); 86 parser.setNodeFactory (new PrototypicalNodeFactory (new JspTag ())); 87 parseAndAssertNodeCount(1); 88 } 89 } 90 } 91 | Popular Tags |