|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.javacore.parsing; import java.util.List; import junit.textui.TestRunner; import org.netbeans.jmi.javamodel.*; import org.netbeans.jmi.javamodel.codegen.Utility; import org.netbeans.junit.NbTestCase; import org.netbeans.junit.NbTestSuite; /** * @author Jan Becicka */ public class ParserErrorsTest extends NbTestCase { /** Need to be defined because of JUnit */ public ParserErrorsTest(String name) { super(name); } public static NbTestSuite suite() { NbTestSuite suite = new NbTestSuite(); suite.addTest(new ParserErrorsTest("testSyntaxErrors")); suite.addTest(new ParserErrorsTest("testSemanticErrors")); // suite.addTest(new ParserErrorsTest("testWarnings")); return suite; } /** Use for execution inside IDE */ public static void main(java.lang.String[] args) { TestRunner.run(suite()); } protected void setUp() { } public void testSyntaxErrors() { JavaClass clazz = Utility.findClass("org.netbeans.test.parser.SyntaxError"); Resource res = clazz.getResource(); List errors = res.getErrors(); assertEquals(1, errors.size()); ErrorInfo error = (ErrorInfo) errors.iterator().next(); assertEquals(9, error.getLineNumber()); assertEquals("';' expected", error.getDescription()); assertEquals(ErrorTypeEnum.ERROR, error.getSeverity()); assertEquals(12, error.getColumn()); } public void testSemanticErrors() { JavaClass clazz = Utility.findClass("org.netbeans.test.parser.SemanticError"); Resource res = clazz.getResource(); List errors = res.getErrors(); assertEquals(1, errors.size()); ErrorInfo error = (ErrorInfo) errors.iterator().next(); assertEquals(7, error.getLineNumber()); // assertEquals("cannot find symbol symbol : class JFrame location: class org.netbeans.test.parser.SemanticError", error.getDescription()); assertEquals(ErrorTypeEnum.ERROR, error.getSeverity()); assertEquals(13, error.getColumn()); } // public void testWarnings() { // JavaClass clazz = Utility.findClass("org.netbeans.test.parser.Warning"); // Resource res = clazz.getResource(); // List errors = res.getErrors(); // assertEquals(1, errors.size()); // ErrorInfo error = (ErrorInfo) errors.iterator().next(); // assertEquals(0, error.getLineNumber()); // assertEquals(null, error.getDescription()); // assertEquals(ErrorTypeEnum.ERROR, error.getSeverity()); // assertEquals(0, error.getColumn()); // } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.