super(name);
}
- protected File createFile(String path) {
+ protected File openFile(String path) {
return new File(currTestDataPath + File.separatorChar + path);
}
*/
protected void doSynchronousBuild(String configFilePath) {
testerBuildListener.reset();
- File configFile = createFile(configFilePath);
+ File configFile = openFile(configFilePath);
Ajde.getDefault().getBuildManager().build(configFile.getAbsolutePath());
while(!testerBuildListener.getBuildFinished()) {
try {
package org.aspectj.ajde;
import java.io.IOException;
+import java.util.Iterator;
import java.util.List;
/**
// The build has happened, what messages did the compiler give, and do they
// contain the information we expect?
List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- if (1 != msgs.size()) {
- assertTrue("not one message: " + msgs, false);
+ if (2 != msgs.size()) {
+ assertTrue("not two messages: " + msgs, false);
}
- assertEquals("One warning message should be produced",1,msgs.size());
+ assertEquals("Two warning messages should be produced",2,msgs.size());
NullIdeTaskListManager.SourceLineTask task =
(NullIdeTaskListManager.SourceLineTask) msgs.get(0);
- assertEquals( 6, task.location.getLine());
+ assertEquals( 8, task.location.getLine());
assertEquals( "Please don't call init methods", task.message);
try {
String fullyQualifiedFile = task.location.getSourceFile().getCanonicalPath();
}
}
+
+ public void testDeclareMessageContents() {
+ List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ assertEquals( "Please don't call setters" , ((NullIdeTaskListManager.SourceLineTask) msgs.get(1)).message);
+
+ }
+
+
/*
* @see TestCase#setUp()
*/
public void testRootForSourceFile() throws IOException {
- File testFile = createFile("figures-coverage/figures/Figure.java");
+ File testFile = openFile("figures-coverage/figures/Figure.java");
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
testFile.getCanonicalPath());
assertTrue("find result", node != null) ;
}
public void testPointcutName() throws IOException {
- File testFile = createFile("figures-coverage/figures/Main.java");
+ File testFile = openFile("figures-coverage/figures/Main.java");
//System.err.println("PointcutName, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists());
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findRootNodeForSourceFile(
testFile.getCanonicalPath());
}
public void testFileNodeFind() throws IOException {
- File testFile = createFile("figures-coverage/figures/Main.java");
+ File testFile = openFile("figures-coverage/figures/Main.java");
//System.err.println("NodeFind, testFile: " + testFile.getCanonicalPath() + " exists: " + testFile.exists());
StructureNode node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
testFile.getCanonicalPath(), 1);
StructureModel model = Ajde.getDefault().getStructureModelManager().getStructureModel();
assertTrue("model exists", model != null);
assertTrue("root exists", model.getRoot() != null);
- File testFile = createFile("figures-coverage/figures/Main.java");
+ File testFile = openFile("figures-coverage/figures/Main.java");
StructureNode node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11);
assertTrue("find result", node != null);
}
public void testSymbolFileGenerated() {
- File file = createFile("../examples/figures-coverage/all.ajsym");
+ File file = openFile("../examples/figures-coverage/all.ajsym");
if (file.exists()) {
file.delete();
} else {
import java.io.File;
import java.io.IOException;
-import java.util.*;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
import junit.framework.TestSuite;
import org.aspectj.ajde.AjdeTestCase;
import org.aspectj.ajde.BuildConfigManager;
+import org.aspectj.ajde.NullIdeManager;
+import org.aspectj.ajde.NullIdeTaskListManager.SourceLineTask;
import org.aspectj.ajde.ui.BuildConfigModel;
import org.aspectj.ajde.ui.internal.AjcBuildOptions;
return result;
}
+ public void testErrorMessages() throws IOException {
+ doSynchronousBuild("invalid-entry.lst");
+ assertTrue("compile failed", !testerBuildListener.getBuildSucceeded());
+
+ List messages = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
+ SourceLineTask message = (SourceLineTask)messages.get(0);
+
+ System.err.println(">>>> " + message.message);
+ assertEquals("invalid option: aaa.bbb", message.message);
+ }
+
public void testNonExistentConfigFile() throws IOException {
- File file = createFile("mumbleDoesNotExist.lst");
+ File file = openFile("mumbleDoesNotExist.lst");
assertTrue("valid non-existing file", !file.exists());
BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath());
System.err.println(model.getRoot().getChildren());
}
public void testFileRelativePathSameDir() throws IOException {
- File file = createFile("file-relPath-sameDir.lst");
+ File file = openFile("file-relPath-sameDir.lst");
System.err.println("> " + file.getCanonicalPath());
BuildConfigModel model = buildConfigManager.buildModel(file.getCanonicalPath());
System.err.println("> " + model.getRoot());
public void testFreshStructureModelCreation() {
renderer.setHasBeenNotified(false);
String modelPath = genStructureModelExternFilePath(CONFIG_FILE_PATH);
- createFile(modelPath).delete();
+ openFile(modelPath).delete();
//System.err.println("> path: " + modelPath);
Ajde.getDefault().getStructureModelManager().readStructureModel(CONFIG_FILE_PATH);
doSynchronousBuild(CONFIG_FILE_PATH);
properties = Ajde.getDefault().getStructureViewManager().getDefaultViewProperties();
- testFile = createFile("../examples/figures-coverage/figures/Figure.java");
+ testFile = openFile("../examples/figures-coverage/figures/Figure.java");
currentView = Ajde.getDefault().getStructureViewManager().createViewForSourceFile(testFile.getAbsolutePath(), properties);
currentView.setRenderer(renderer);
}