--- /dev/null
+apackage/InitCatcher.java\r
+apackage/SomeClass.java\r
--- /dev/null
+package apackage;
+
+public aspect InitCatcher {
+
+ declare warning: call(* *.init(..)) :
+ "Please don't call init methods"; //$NON-NLS-1$
+
+}
\ No newline at end of file
--- /dev/null
+package apackage;
+
+public class SomeClass {
+
+ public SomeClass() {
+ init(); // line 6
+ }
+
+ public void init() {
+ }
+
+}
\ No newline at end of file
private static final String TEST_DATA_PATH = "testdata";
//private static final String TEST_DATA_PATH = "C:/Dev/aspectj/modules/ajde/testdata";
- protected NullIdeManager ideManager = new NullIdeManager();
+ protected NullIdeManager ideManager = NullIdeManager.getIdeManager();
protected TestBuildListener testerBuildListener = new TestBuildListener();
protected String currTestDataPath;
suite.addTestSuite(StructureModelRegressionTest.class);
suite.addTestSuite(StructureModelTest.class);
suite.addTestSuite(VersionTest.class);
+ suite.addTestSuite(CompilerMessagesTest.class);
//$JUnit-END$
return suite;
}
--- /dev/null
+/*
+ * Created on 27-Mar-2003
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package org.aspectj.ajde;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author colyer
+ *
+ * To change this generated comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class CompilerMessagesTest extends AjdeTestCase {
+
+ private final String CONFIG_FILE_PATH = "../examples/declare-warning/all.lst";
+
+ /**
+ * Constructor for CompilerMessagesTest.
+ * @param name
+ */
+ public CompilerMessagesTest(String name) {
+ super(name);
+ }
+
+ public void testMessages() {
+ // bug 33474
+ // The build has happened, what messages did the compiler give, and do they
+ // contain the information we expect?
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ assertEquals("One warning message should be produced",1,msgs.size());
+ NullIdeTaskListManager.SourceLineTask task =
+ (NullIdeTaskListManager.SourceLineTask) msgs.get(0);
+ assertEquals( 6, task.location.getLine());
+ assertEquals( "Please don't call init methods", task.message);
+ try {
+ String fullyQualifiedFile = task.location.getSourceFile().getCanonicalPath();
+ // this name has a tester specific prefix, followed by the location of the file.
+ // we can validate the ending.
+ fullyQualifiedFile = fullyQualifiedFile.replace('\\','/'); // ignore platform differences in slashes
+ assertTrue( "Fully-qualified source file location returned",
+ fullyQualifiedFile.endsWith("testdata/examples/declare-warning/apackage/SomeClass.java"));
+ } catch (IOException ex) {
+ assertTrue( "Unable to convert source file location: " + task.location.getSourceFile(), false);
+ }
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp("examples");
+ doSynchronousBuild(CONFIG_FILE_PATH);
+ }
+
+ /*
+ * @see AjdeTestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+}
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
- * Xerox/PARC initial implementation
+ * Xerox/PARC initial implementation
+ * AMC 03.27.2003 changed to allow access to NullIdeManager
+ * as a singleton - needed for verifying
+ * compiler warning and error messages.
* ******************************************************************/
package org.aspectj.ajde;
+import java.util.List;
+
import javax.swing.JFrame;
import org.aspectj.ajde.ui.IdeUIAdapter;
*/
public class NullIdeManager {
+ private static NullIdeManager ideManager = null;
+ private NullIdeTaskListManager taskListManager = null;
+
+ public static NullIdeManager getIdeManager() {
+ if ( null == ideManager ) {
+ ideManager = new NullIdeManager();
+ }
+ return ideManager;
+ }
+
public void init(String testProjectPath) {
try {
UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore();
ProjectPropertiesAdapter browserProjectProperties = new NullIdeProperties(testProjectPath);
- TaskListManager taskListManager = new NullIdeTaskListManager();
+ taskListManager = new NullIdeTaskListManager();
BasicEditor ajdeEditor = new BasicEditor();
IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
JFrame nullFrame = new JFrame();
t);
}
}
+
+ public List getCompilationSourceLineTasks() {
+ return taskListManager.getSourceLineTasks();
+ }
}
package org.aspectj.ajde;
+import java.util.ArrayList;
+import java.util.List;
+
import org.aspectj.bridge.*;
/**
* @author Mik Kersten
*/
public class NullIdeTaskListManager implements TaskListManager {
+
+ List sourceLineTasks = new ArrayList();
public void addSourcelineTask(String message, ISourceLocation sourceLocation, IMessage.Kind kind) {
+ sourceLineTasks.add(new SourceLineTask(message,sourceLocation,kind));
// System.out.println("> added sourceline task: " + message + ", file: " + sourceLocation.getSourceFile().getAbsolutePath()
// + ": " + sourceLocation.getLine());
}
}
public void clearTasks() {
+ sourceLineTasks = new ArrayList();
// System.out.println("> cleared tasks");
}
+
+ /**
+ * Return the list of source line compiler messages resulting from a compile, so
+ * that we can test them.
+ * @return List
+ */
+ public List getSourceLineTasks() {
+ return sourceLineTasks;
+ }
+
+
+ public static class SourceLineTask {
+ public String message;
+ public ISourceLocation location;
+ public IMessage.Kind kind;
+
+ public SourceLineTask(String m,ISourceLocation l,IMessage.Kind k) {
+ message = m;
+ location = l;
+ kind = k;
+ }
+ }
}