1 19 package org.netbeans.modules.javacore.parsing; 20 21 import java.util.List ; 22 23 import junit.textui.TestRunner; 24 import org.netbeans.jmi.javamodel.*; 25 import org.netbeans.jmi.javamodel.codegen.Utility; 26 import org.netbeans.junit.NbTestCase; 27 import org.netbeans.junit.NbTestSuite; 28 29 32 public class ParserErrorsTest extends NbTestCase { 33 34 35 public ParserErrorsTest(String name) { 36 super(name); 37 38 } 39 40 public static NbTestSuite suite() { 41 NbTestSuite suite = new NbTestSuite(); 42 suite.addTest(new ParserErrorsTest("testSyntaxErrors")); 43 suite.addTest(new ParserErrorsTest("testSemanticErrors")); 44 return suite; 46 } 47 48 49 public static void main(java.lang.String [] args) { 50 TestRunner.run(suite()); 51 } 52 53 protected void setUp() { 54 } 55 56 public void testSyntaxErrors() { 57 JavaClass clazz = Utility.findClass("org.netbeans.test.parser.SyntaxError"); 58 Resource res = clazz.getResource(); 59 List errors = res.getErrors(); 60 assertEquals(1, errors.size()); 61 ErrorInfo error = (ErrorInfo) errors.iterator().next(); 62 assertEquals(9, error.getLineNumber()); 63 assertEquals("';' expected", error.getDescription()); 64 assertEquals(ErrorTypeEnum.ERROR, error.getSeverity()); 65 assertEquals(12, error.getColumn()); 66 } 67 68 public void testSemanticErrors() { 69 JavaClass clazz = Utility.findClass("org.netbeans.test.parser.SemanticError"); 70 Resource res = clazz.getResource(); 71 List errors = res.getErrors(); 72 assertEquals(1, errors.size()); 73 ErrorInfo error = (ErrorInfo) errors.iterator().next(); 74 assertEquals(7, error.getLineNumber()); 75 assertEquals(ErrorTypeEnum.ERROR, error.getSeverity()); 77 assertEquals(13, error.getColumn()); 78 } 79 80 92 } 93 | Popular Tags |