1 19 20 package org.netbeans.lib.html.lexer; 21 22 import junit.framework.TestCase; 23 import org.netbeans.api.html.lexer.HTMLTokenId; 24 import org.netbeans.lib.lexer.test.FixedTextDescriptor; 25 import org.netbeans.lib.lexer.test.LexerTestUtilities; 26 import org.netbeans.lib.lexer.test.RandomCharDescriptor; 27 import org.netbeans.lib.lexer.test.RandomModifyDescriptor; 28 import org.netbeans.lib.lexer.test.RandomTextProvider; 29 import org.netbeans.lib.lexer.test.TestRandomModify; 30 31 37 public class JspLexerRandomTest extends TestCase { 38 39 public JspLexerRandomTest(String testName) { 40 super(testName); 41 } 42 43 protected void setUp() throws java.lang.Exception { 44 LexerTestUtilities.setTesting(true); 46 } 47 48 protected void tearDown() throws java.lang.Exception { 49 } 50 51 public void testRandom() throws Exception { 52 test(0); 53 } 54 55 private void test(long seed) throws Exception { 56 TestRandomModify randomModify = new TestRandomModify(seed); 57 randomModify.setLanguage(HTMLTokenId.language()); 58 59 63 randomModify.insertText(0, "<a>"); 65 randomModify.insertText(2, " "); randomModify.removeText(2, 1); 67 68 randomModify.clearDocument(); 69 70 randomModify.insertText(0, "<body>"); 72 randomModify.insertText(5, " "); randomModify.insertText(6, "bgcolor='red'"); randomModify.clearDocument(); 75 76 FixedTextDescriptor[] fixedTexts = new FixedTextDescriptor[] { 78 FixedTextDescriptor.create("/>", 0.2), 79 }; 80 81 RandomCharDescriptor[] regularChars = new RandomCharDescriptor[] { 82 RandomCharDescriptor.letter(0.2), 83 RandomCharDescriptor.space(0.2), 84 RandomCharDescriptor.lf(0.05), 85 RandomCharDescriptor.chars(new char[] { '<', '>', '=' }, 0.3), 86 }; 87 88 RandomTextProvider regularTextProvider = new RandomTextProvider(regularChars, fixedTexts); 89 90 randomModify.test( 91 new RandomModifyDescriptor[] { 92 new RandomModifyDescriptor(200, regularTextProvider, 93 0.4, 0.2, 0.2, 94 0.1, 0.1, 95 0.0, 0.0), new RandomModifyDescriptor(200, regularTextProvider, 97 0.2, 0.2, 0.1, 98 0.4, 0.3, 99 0.0, 0.0), } 101 ); 102 } 103 104 } 105 | Popular Tags |