<classpathentry kind="src" path="/org.aspectj.ajdt.core"/>
<classpathentry kind="src" path="/util"/>
<classpathentry kind="src" path="/bridge"/>
- <classpathentry kind="src" path="/ajde"/>
+ <classpathentry kind="src" path="/ajde.core"/>
<classpathentry kind="src" path="/asm"/>
<classpathentry sourcepath="/lib/bcel/bcel-src.zip" kind="lib" path="/lib/bcel/bcel.jar"/>
<classpathentry kind="lib" path="/lib/ant/lib/ant-launcher.jar"/>
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Adrian Colyer initial implementation
+ * Helen Hawkins Converted to new interface (bug 148190)
+ *******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.io.BufferedReader;
import java.util.List;
import org.aspectj.ajdt.internal.core.builder.AjState;
-import org.aspectj.bridge.IMessage;
import org.aspectj.testing.util.FileUtil;
public class AbstractMultiProjectIncrementalAjdeInteractionTestbed extends
protected void tearDown() throws Exception {
super.tearDown();
AjState.FORCE_INCREMENTAL_DURING_TESTING = false;
- configureBuildStructureModel(false);
- MyBuildOptionsAdapter.reset();
}
public void build(String projectName) {
constructUpToDateLstFile(projectName,"build.lst");
- build(projectName,"build.lst");
- if (AjdeInteractionTestbed.VERBOSE) printBuildReport();
+ doBuild(projectName);
+ if (AjdeInteractionTestbed.VERBOSE) printBuildReport(projectName);
}
public void fullBuild(String projectName) {
constructUpToDateLstFile(projectName,"build.lst");
- fullBuild(projectName,"build.lst");
- if (AjdeInteractionTestbed.VERBOSE) printBuildReport();
+ doFullBuild(projectName);
+ if (AjdeInteractionTestbed.VERBOSE) printBuildReport(projectName);
}
private void constructUpToDateLstFile(String pname, String configname) {
}
}
- public void checkForError(String anError) {
- List messages = MyTaskListManager.getErrorMessages();
- for (Iterator iter = messages.iterator(); iter.hasNext();) {
- IMessage element = (IMessage) iter.next();
- if (element.getMessage().indexOf(anError)!=-1) return;
- }
- fail("Didn't find the error message:\n'"+anError+"'.\nErrors that occurred:\n"+MyTaskListManager.getErrorMessages());
- }
-
private void collectUpFiles(File location, File base, List collectionPoint) {
String contents[] = location.list();
if (contents==null) return;
File destination=new File(getWorkingDir(),p);
if (!destination.exists()) {destination.mkdir();}
copy(projectSrc,destination);//,false);
+ // create the AjCompiler instance associated with this project
+ // (has id of the form c:\temp\ajcSandbox\<workspace_name>\<project_name>)
+ CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + p);
}
- /*
+ /**
* Applies an overlay onto the project being tested - copying
* the contents of the specified overlay directory.
*/
" in the aop.xml file but found " + aspectCount + " occurrences");
}
}
-
}
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
+/********************************************************************
+ * Copyright (c) 2005 Contributors.All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Andy Clement initial implementation
- * ******************************************************************/
+ * Andy Clement initial implementation
+ * Helen Hawkins Converted to new interface (bug 148190)
+ *******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
-import org.aspectj.ajde.Ajde;
-import org.aspectj.ajde.BuildOptionsAdapter;
-import org.aspectj.ajde.BuildProgressMonitor;
-import org.aspectj.ajde.ErrorHandler;
-import org.aspectj.ajde.OutputLocationManager;
-import org.aspectj.ajde.ProjectPropertiesAdapter;
-import org.aspectj.ajde.TaskListManager;
-import org.aspectj.ajde.internal.AspectJBuildManager;
+import org.aspectj.ajde.core.AjCompiler;
+import org.aspectj.ajde.core.IBuildMessageHandler;
+import org.aspectj.ajde.core.IOutputLocationManager;
import org.aspectj.ajdt.internal.core.builder.AbstractStateListener;
import org.aspectj.ajdt.internal.core.builder.AjState;
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
import org.aspectj.asm.AsmManager;
import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.IMessage.Kind;
import org.aspectj.tools.ajc.Ajc;
/**
* This class uses Ajde in the same way that an IDE (e.g. AJDT) does.
*
- * The build is driven through 'build(projectName,configFile)' but the
+ * The build is driven through 'doBuild(projectName)' but the
* build can be configured by the methods beginning 'configure***'.
* Information about what happened during a build is accessible
* through the get*, was*, print* public methods...
*
- * There are many methods across the multiple listeners that communicate
- * info with Ajde - not all are implemented. Those that are are
- * task tagged DOESSOMETHING :)
*/
public class AjdeInteractionTestbed extends TestCase {
- public static boolean VERBOSE = false; // do you want the gory details?
+ public static boolean VERBOSE = false; // do you want the gory details?
- public static String testdataSrcDir = "../tests/multiIncremental";
- protected static File sandboxDir;
+ public static String testdataSrcDir = "../tests/multiIncremental";
+ protected static File sandboxDir;
private static boolean buildModel;
-
+
// Methods for configuring the build
- public static void configureBuildStructureModel(boolean b) { buildModel = b;}
-
- public static void configureNewProjectDependency(String fromProject, String projectItDependsOn) {
- MyProjectPropertiesAdapter.addDependancy(fromProject,projectItDependsOn);
+ public void configureNewProjectDependency(String fromProjectName, String projectItDependsOn) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + fromProjectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).addDependancy(projectItDependsOn);
}
- public static void configureNonStandardCompileOptions(String options) {
- MyBuildOptionsAdapter.setNonStandardOptions(options);
+ public void configureNonStandardCompileOptions(String projectName, String options) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setNonStandardOptions(options);
}
- public static void configureAspectPath(Set aspectpath) {
- MyProjectPropertiesAdapter.setAspectpath(aspectpath);
+ public void configureAspectPath(String projectName, Set aspectpath) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setAspectPath(aspectpath);
}
- public static void configureInPath(Set inpath) {
- MyProjectPropertiesAdapter.setInpath(inpath);
+ public void configureResourceMap(String projectName, Map resourcesMap) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setSourcePathResources(resourcesMap);
}
- public static void configureOutputLocationManager(OutputLocationManager mgr) {
- MyProjectPropertiesAdapter.setOutputLocationManager(mgr);
+ public void configureJavaOptionsMap(String projectName, Map options) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setJavaOptions(options);
}
- public static void configureOutputLocationManager(OutputLocationManager mgr, boolean hasOutputPath) {
- MyProjectPropertiesAdapter.setOutputLocationManager(mgr,hasOutputPath);
+ public static void configureInPath(String projectName, Set inpath) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setInpath(inpath);
}
- public static void configureResourceMap(Map resourcesMap) {
- MyProjectPropertiesAdapter.setSourcePathResources(resourcesMap);
+ public static void configureOutputLocationManager(String projectName, IOutputLocationManager mgr) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setOutputLocationManager(mgr);
}
+
+ public void configureShowWeaveInfoMessages(String projectName, boolean showWeaveInfo) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ IBuildMessageHandler handler = compiler.getMessageHandler();
+ if (showWeaveInfo) {
+ handler.dontIgnore(IMessage.WEAVEINFO);
+ } else {
+ handler.ignore(IMessage.WEAVEINFO);
+ }
+ }
+
// End of methods for configuring the build
+ public AjCompiler getCompilerForProjectWithName(String projectName) {
+ return CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ }
protected File getWorkingDir() { return sandboxDir; }
protected void setUp() throws Exception {
super.setUp();
- if (AjState.stateListener==null) AjState.stateListener=MyStateListener.getInstance();
- MyStateListener.reset();
- MyBuildProgressMonitor.reset();
- MyTaskListManager.reset();
- MyProjectPropertiesAdapter.reset();
+ // need this line because otherwise reset in previous tests
+ AsmManager.attemptIncrementalModelRepairs = true;
+ if (AjState.stateListener==null) {
+ AjState.stateListener=MyStateListener.getInstance();
+ }
+ MyStateListener.reset();
// Create a sandbox in which to work
sandboxDir = Ajc.createEmptySandbox();
-
- IncrementalStateManager.debugIncrementalStates = true;
}
protected void tearDown() throws Exception {
super.tearDown();
AjState.stateListener=null;
+ CompilerFactory.clearCompilerMap();
IncrementalStateManager.clearIncrementalStates();
}
/** Drives a build */
- public boolean build(String projectName,String configFile) {
- return AjdeManager.build(projectName,configFile);
+ public boolean doBuild(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ resetCompilerRecords(compiler);
+ addSourceFilesToBuild(projectName, compiler);
+ pause(1000); // delay to allow previous runs build stamps to be OK
+ lognoln("Building project '"+projectName+"'");
+ compiler.build();
+ log("");
+ checkForErrors(compiler);
+ log("Build finished, time taken = " +((MultiProjTestBuildProgressMonitor)
+ compiler.getBuildProgressMonitor()).getTimeTaken()+"ms");
+ return true;
}
- public boolean fullBuild(String projectName,String configFile) {
- return AjdeManager.fullBuild(projectName,configFile);
+ /** Drives a full build **/
+ public boolean doFullBuild(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ resetCompilerRecords(compiler);
+ addSourceFilesToBuild(projectName, compiler);
+ pause(1000); // delay to allow previous runs build stamps to be OK
+ lognoln("Building project '"+projectName+"'");
+ compiler.buildFresh();
+ log("");
+ checkForErrors(compiler);
+ log("Build finished, time taken = " +((MultiProjTestBuildProgressMonitor)
+ compiler.getBuildProgressMonitor()).getTimeTaken()+"ms");
+ return true;
}
- /** Looks after communicating with the singleton Ajde instance */
- public static class AjdeManager {
-
- static {
- Ajde.init(null,
- MyTaskListManager.getInstance(),
- MyBuildProgressMonitor.getInstance(),
- MyProjectPropertiesAdapter.getInstance(),
- MyBuildOptionsAdapter.getInstance(),
- null,null,
- MyErrorHandler.getInstance());
-
- MyStateListener sl = MyStateListener.getInstance();
- AjState.stateListener = sl;
- }
-
- /**
- * Builds a specified project using a specified config file. Subsequent
- * calls to build the same project should result in incremental builds.
- */
- private static boolean build(String projectName,String configFile) {
- pause(1000); // delay to allow previous runs build stamps to be OK
- lognoln("Building project '"+projectName+"'");
-
- // Ajde.getDefault().enableLogging(System.out);
-
- //Ajde.getDefault().getBuildManager().setReportInfoMessages(true);
-
- // Configure the necessary providers and listeners for this compile
- MyBuildProgressMonitor.reset();
- MyTaskListManager.reset();
- MyStateListener.reset();
- // MyBuildOptionsAdapter.reset(); needs manually resetting in a test
-
- MyProjectPropertiesAdapter.setActiveProject(projectName);
- AsmManager.attemptIncrementalModelRepairs=true;
- IncrementalStateManager.recordIncrementalStates=true;
-
- Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
-
- // Do the compile
- Ajde.getDefault().getBuildManager().build(getFile(projectName,configFile));
-
- // Wait for it to complete
- while (!MyBuildProgressMonitor.hasFinished()) {
- lognoln(".");
- pause(100);
- }
- log("");
-
- // What happened?
- if (MyTaskListManager.hasErrorMessages()) {
- System.err.println("Build errors:");
- for (Iterator iter = MyTaskListManager.getErrorMessages().iterator(); iter.hasNext();) {
- IMessage element = (IMessage) iter.next();
- System.err.println(element);
+ /**
+ * Clears any maps associated with the compiler
+ */
+ private void resetCompilerRecords(AjCompiler compiler) {
+ ((MultiProjTestBuildProgressMonitor)compiler.getBuildProgressMonitor()).reset();
+ ((MultiProjTestMessageHandler)compiler.getMessageHandler()).reset();
+ }
+
+ /**
+ * Find the source files associated with the given project and add them to the
+ * list of projectSourceFiles in the MultiProjTestCompilerConfiguration to be
+ * used in the subsequent build
+ */
+ private void addSourceFilesToBuild(String pname, AjCompiler compiler) {
+ File projectBase = new File(sandboxDir,pname);
+ List filesForCompilation = new ArrayList();
+ collectUpFiles(projectBase,projectBase,filesForCompilation);
+ ((MultiProjTestCompilerConfiguration)compiler.getCompilerConfiguration()).setProjectSourceFiles(filesForCompilation);
+ }
+
+ private void collectUpFiles(File location, File base, List collectionPoint) {
+ String contents[] = location.list();
+ if (contents==null) return;
+ for (int i = 0; i < contents.length; i++) {
+ String string = contents[i];
+ File f = new File(location,string);
+ if (f.isDirectory()) {
+ collectUpFiles(f,base,collectionPoint);
+ } else if (f.isFile() && (f.getName().endsWith(".aj") || f.getName().endsWith(".java"))) {
+ String fileFound;
+ try {
+ fileFound = f.getCanonicalPath();
+ collectionPoint.add(fileFound);
+// String toRemove = base.getCanonicalPath();
+// if (!fileFound.startsWith(toRemove)) throw new RuntimeException("eh? "+fileFound+" "+toRemove);
+// collectionPoint.add(fileFound.substring(toRemove.length()+1));//+1 captures extra separator
+ } catch (IOException e) {
+ e.printStackTrace();
}
- System.err.println("---------");
}
- log("Build finished, time taken = "+MyBuildProgressMonitor.getTimeTaken()+"ms");
- return true;
}
-
- private static boolean fullBuild(String projectName,String configFile) {
- pause(1000); // delay to allow previous runs build stamps to be OK
- lognoln("Building project '"+projectName+"'");
-
- // Ajde.getDefault().enableLogging(System.out);
-
- //Ajde.getDefault().getBuildManager().setReportInfoMessages(true);
-
- // Configure the necessary providers and listeners for this compile
- MyBuildProgressMonitor.reset();
- MyTaskListManager.reset();
- MyStateListener.reset();
-
- MyProjectPropertiesAdapter.setActiveProject(projectName);
- //AsmManager.attemptIncrementalModelRepairs=true;
- //IncrementalStateManager.recordIncrementalStates=true;
-
- Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
-
- // Do the compile
- Ajde.getDefault().getBuildManager().buildFresh(getFile(projectName,configFile));
-
- // Wait for it to complete
- while (!MyBuildProgressMonitor.hasFinished()) {
- lognoln(".");
- pause(100);
- }
- log("");
-
- // What happened?
- if (MyTaskListManager.hasErrorMessages()) {
- System.err.println("Build errors:");
- for (Iterator iter = MyTaskListManager.getErrorMessages().iterator(); iter.hasNext();) {
- IMessage element = (IMessage) iter.next();
- System.err.println(element);
- }
- System.err.println("---------");
+ }
+
+ /**
+ * Make sure no errors have been recorded
+ */
+ private void checkForErrors(AjCompiler compiler) {
+ MultiProjTestMessageHandler handler = (MultiProjTestMessageHandler) compiler.getMessageHandler();
+ if (handler.hasErrorMessages()) {
+ System.err.println("Build errors:");
+ for (Iterator iter = handler.getErrorMessages().iterator(); iter.hasNext();) {
+ IMessage element = (IMessage) iter.next();
+ System.err.println(element);
}
- log("Build finished, time taken = "+MyBuildProgressMonitor.getTimeTaken()+"ms");
- return true;
- }
-
- private static void pause(int millis) {
- try {
- Thread.sleep(millis);
- } catch (InterruptedException ie) {}
- }
-
- public static void setMessageHandler(IMessageHandler handler) {
- Ajde.getDefault().setMessageHandler(handler);
+ System.err.println("---------");
}
-
- public static IMessageHandler getMessageHandler() {
- AspectJBuildManager buildManager = (AspectJBuildManager) Ajde.getDefault().getBuildManager();
- return buildManager.getCompilerAdapter().getMessageHandler();
+ }
+
+ public List getErrorMessages(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getErrorMessages();
+ }
+
+ public List getWarningMessages(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWarningMessages();
+ }
+
+ public List getWeavingMessages(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getWeavingMessages();
+ }
+
+ public List getCompilerErrorMessages(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestMessageHandler) compiler.getMessageHandler()).getCompilerErrors();
+ }
+
+ public void checkForError(String projectName, String anError) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ List messages = ((MultiProjTestMessageHandler)compiler.getMessageHandler()).getErrorMessages();
+ for (Iterator iter = messages.iterator(); iter.hasNext();) {
+ IMessage element = (IMessage) iter.next();
+ if (element.getMessage().indexOf(anError)!=-1) return;
}
-// public static boolean lastCompileDefaultedToBatch() {
-// return MyTaskListManager.defaultedToBatch();
-// }
+ fail("Didn't find the error message:\n'"+anError+"'.\nErrors that occurred:\n"+messages);
}
+ private void pause(int millis) {
+ try {
+ Thread.sleep(millis);
+ } catch (InterruptedException ie) {}
+ }
// Methods for querying what happened during a build and accessing information
// about the build:
* Helper method for dumping info about which files were compiled and
* woven during the last build.
*/
- public String printCompiledAndWovenFiles() {
+ public String printCompiledAndWovenFiles(String projectName) {
StringBuffer sb = new StringBuffer();
- if (getCompiledFiles().size()==0 && getWovenClasses().size()==0)
+ if (getCompiledFiles(projectName).size()==0 && getWovenClasses(projectName).size()==0)
sb.append("No files were compiled or woven\n");
- for (Iterator iter = getCompiledFiles().iterator(); iter.hasNext();) {
+ for (Iterator iter = getCompiledFiles(projectName).iterator(); iter.hasNext();) {
Object element = (Object) iter.next();
sb.append("compiled: "+element+"\n");
}
- for (Iterator iter = getWovenClasses().iterator(); iter.hasNext();) {
+ for (Iterator iter = getWovenClasses(projectName).iterator(); iter.hasNext();) {
Object element = (Object) iter.next();
sb.append("woven: "+element+"\n");
}
/**
* Summary report on what happened in the most recent build
*/
- public void printBuildReport() {
+ public void printBuildReport(String projectName) {
System.out.println("\n============== BUILD REPORT =================");
- System.out.println("Build took: "+getTimeTakenForBuild()+"ms");
- List compiled=getCompiledFiles();
+ System.out.println("Build took: "+getTimeTakenForBuild(projectName)+"ms");
+ List compiled=getCompiledFiles(projectName);
System.out.println("Compiled: "+compiled.size()+" files");
for (Iterator iter = compiled.iterator(); iter.hasNext();) {
System.out.println(" :"+iter.next());
}
- List woven=getWovenClasses();
+ List woven=getWovenClasses(projectName);
System.out.println("Wove: "+woven.size()+" files");
for (Iterator iter = woven.iterator(); iter.hasNext();) {
System.out.println(" :"+iter.next());
if (wasFullBuild()) System.out.println("It was a batch (full) build");
System.out.println("=============================================");
}
-
+
/**
* Check we compiled/wove the right number of files, passing '-1' indicates you don't care about
* that number.
*/
- public void checkCompileWeaveCount(int expCompile,int expWoven) {
- if (expCompile!=-1 && getCompiledFiles().size()!=expCompile)
- fail("Expected compilation of "+expCompile+" files but compiled "+getCompiledFiles().size()+
- "\n"+printCompiledAndWovenFiles());
- if (expWoven!=-1 && getWovenClasses().size()!=expWoven)
- fail("Expected weaving of "+expWoven+" files but wove "+getWovenClasses().size()+
- "\n"+printCompiledAndWovenFiles());
+ public void checkCompileWeaveCount(String projectName,int expCompile,int expWoven) {
+ if (expCompile!=-1 && getCompiledFiles(projectName).size()!=expCompile)
+ fail("Expected compilation of "+expCompile+" files but compiled "+getCompiledFiles(projectName).size()+
+ "\n"+printCompiledAndWovenFiles(projectName));
+ if (expWoven!=-1 && getWovenClasses(projectName).size()!=expWoven)
+ fail("Expected weaving of "+expWoven+" files but wove "+getWovenClasses(projectName).size()+
+ "\n"+printCompiledAndWovenFiles(projectName));
}
public void checkWasntFullBuild() {
}
- public long getTimeTakenForBuild() {
- return MyBuildProgressMonitor.getTimeTaken();
+ public long getTimeTakenForBuild(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestBuildProgressMonitor)compiler.getBuildProgressMonitor()).getTimeTaken();
}
- public List getCompiledFiles() {
- return MyBuildProgressMonitor.getCompiledFiles();
+ public List getCompiledFiles(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestBuildProgressMonitor)compiler.getBuildProgressMonitor()).getCompiledFiles();
}
- public List getWovenClasses() {
- return MyBuildProgressMonitor.getWovenClasses();
+ public List getWovenClasses(String projectName) {
+ AjCompiler compiler = CompilerFactory.getCompilerForProjectWithDir(sandboxDir + File.separator + projectName);
+ return ((MultiProjTestBuildProgressMonitor)compiler.getBuildProgressMonitor()).getWovenClasses();
}
// Infrastructure below here
protected static String getFile(String projectName, String path) {
return new File(sandboxDir,projectName+File.separatorChar + path).getAbsolutePath();
}
-
- // Helper classes that communicate with Ajde
-
- static class MyErrorHandler implements ErrorHandler {
- static MyErrorHandler _instance = new MyErrorHandler();
- private List errorMessages = new ArrayList();
-
- private MyErrorHandler() {}
-
- public static ErrorHandler getInstance() {
- return _instance;
- }
-
- public void handleWarning(String message) {
- log("ErrorHandler.handleWarning("+message+")");
- }
-
- public void handleError(String message) {
- log("ErrorHandler.handleWarning("+message+")");
- errorMessages.add(message);
- }
-
- public void handleError(String message, Throwable t) {
- log("ErrorHandler.handleError("+message+","+t+")");
- if (VERBOSE) t.printStackTrace();
- errorMessages.add(message+","+t+")");
- }
-
- public static List/*String*/ getErrorMessages() {
- return _instance.errorMessages;
- }
-
- }
-
- // -----------------
-
- static class MyProjectPropertiesAdapter implements ProjectPropertiesAdapter {
-
- private final static boolean VERBOSE = false;
-
- static MyProjectPropertiesAdapter _instance = new MyProjectPropertiesAdapter();
- private MyProjectPropertiesAdapter() {}
-
- public static MyProjectPropertiesAdapter getInstance() {
- return _instance;
- }
-
- public static void reset() {
- _instance.aspectPath=null;
- _instance.inpath = null;
- _instance.sourcePathResources=null;
- _instance.outputLocationManager=null;
- _instance.hasOutputPath = true;
- _instance.outputPath = null;
- }
-
- private String projectName = null;
- private String outputPath = null;
- private String classPath = "";
- private Set aspectPath = null;
- private Set inpath = null;
- private Map sourcePathResources = null;
- private OutputLocationManager outputLocationManager = null;
- private boolean hasOutputPath = true;
-
- public static void setActiveProject(String n) {
- _instance.projectName = n;
- }
-
- private static Hashtable dependants = new Hashtable();
-
- public static void addDependancy(String project, String projectItDependsOn) {
- List l = (List)dependants.get(project);
- if (l == null) {
- List ps = new ArrayList();
- ps.add(projectItDependsOn);
- dependants.put(project,ps);
- } else {
- l.add(projectItDependsOn);
- }
- }
-
- public static void setSourcePathResources(Map m) {
- _instance.sourcePathResources = m;
- }
-
- public void setClasspath(String path) {
- this.classPath = path;
- }
-
- public static void setAspectpath(Set path) {
- _instance.aspectPath = path;
- }
-
- public static void setInpath(Set path) {
- _instance.inpath = path;
- }
-
- // interface impl below
-
- // DOESSOMETHING
- public String getProjectName() {
- log("MyProjectProperties.getProjectName() [returning "+projectName+"]");
- return projectName;
- }
-
- // DOESSOMETHING
- public String getRootProjectDir() {
- String dir = testdataSrcDir+File.separatorChar+projectName;
- log("MyProjectProperties.getRootProjectDir() [returning "+dir+"]");
- return dir;
- }
-
- public List getBuildConfigFiles() {
- log("MyProjectProperties.getBuildConfigFiles()");
- return null;
- }
-
- public String getDefaultBuildConfigFile() {
- log("MyProjectProperties.getDefaultBuildConfigFile()");
- return null;
- }
-
- public String getLastActiveBuildConfigFile() {
- log("MyProjectProperties.getLastActiveBuildConfigFile()");
- return null;
- }
-
- public List getProjectSourceFiles() {
- log("MyProjectProperties.getProjectSourceFiles()");
- return null;
- }
-
- public String getProjectSourcePath() {
- log("MyProjectProperties.getProjectSourcePath()");
- return null;
- }
-
- // DOESSOMETHING
- public String getClasspath() {
- log("MyProjectProperties.getClasspath()");
- // AJDT has all the output directories on it's classpath
- StringBuffer sb = new StringBuffer();
- String outputPath = getOutputPath();
- sb.append(outputPath);
- if (outputLocationManager != null) {
- List allOutputPaths = outputLocationManager.getAllOutputLocations();
- for (Iterator iterator = allOutputPaths.iterator(); iterator
- .hasNext();) {
- File dir = (File) iterator.next();
- if (!dir.getAbsolutePath().equals(getOutputPath())) {
- sb.append(File.pathSeparator + dir.getAbsolutePath());
- }
- }
- }
- String cp =
- sb.toString() + File.pathSeparator +
- new File(testdataSrcDir) + File.pathSeparator +
- System.getProperty("sun.boot.class.path") +
- File.pathSeparator + "../runtime/bin" +
- File.pathSeparator + this.classPath +
- File.pathSeparator + System.getProperty("aspectjrt.path") +
- File.pathSeparator + "../lib/junit/junit.jar" +
- "c:/batik/batik-1.6/lib/batik-util.jar;"+
- "c:/batik/batik-1.6/lib/batik-awt-util.jar;"+
- "c:/batik/batik-1.6/lib/batik-dom.jar;"+
- "c:/batik/batik-1.6/lib/batik-svggen.jar;"+
- File.pathSeparator+".."+File.separator+"lib" + File.separator+"test"+File.separator+"aspectjrt.jar";
-
- // look at dependant projects
- List projects = (List)dependants.get(projectName);
- if (projects!=null) {
- for (Iterator iter = projects.iterator(); iter.hasNext();) {
- cp = getFile((String)iter.next(),"bin")+File.pathSeparator+cp;
- }
- }
- //System.err.println("For project "+projectName+" getClasspath() returning "+cp);
- return cp;
- }
-
- public String getOutputPath() {
- if (!hasOutputPath) return null;
-
- String dir = getFile(projectName,"bin");
- log("MyProjectProperties.getOutputPath() [returning "+dir+"]");
- return dir;
- //return null;
- }
-
- public static void setOutputLocationManager(OutputLocationManager mgr,boolean hasOutputPath ) {
- _instance.hasOutputPath = hasOutputPath;
- _instance.outputLocationManager = mgr;
- }
-
- public static void setOutputLocationManager(OutputLocationManager mgr) {
- _instance.outputLocationManager = mgr;
- }
-
- public OutputLocationManager getOutputLocationManager() {
- return outputLocationManager;
-// if (testHasSetOutputLocationManager) {
-// return outputLocationManager;
-// }
-// return new MyOutputLocationManager(sandboxDir + File.separator + projectName);
- }
-
- public String getBootClasspath() {
- log("MyProjectProperties.getBootClasspath()");
- return null;
- }
-
- public String getClassToExecute() {
- log("MyProjectProperties.getClassToExecute()");
- return null;
- }
-
- public String getExecutionArgs() {
- log("MyProjectProperties.getExecutionArgs()");
- return null;
- }
-
- public String getVmArgs() {
- log("MyProjectProperties.getVmArgs()");
- return null;
- }
-
- public Set getInJars() {
- log("MyProjectProperties.getInJars()");
- return null;
- }
-
- public Set getInpath() {
- log("MyProjectProperties.getInPath(" + inpath + ")");
- return inpath;
- }
-
- public Map getSourcePathResources() {
- log("MyProjectProperties.getSourcePathResources()");
- return sourcePathResources;
- }
-
- public String getOutJar() {
- log("MyProjectProperties.getOutJar()");
- return null;
- }
-
- public Set getSourceRoots() {
- log("MyProjectProperties.getSourceRoots()");
- return null;
- }
-
- public Set getAspectPath() {
- log("MyProjectProperties.getAspectPath("+aspectPath+")");
- return aspectPath;
- }
-
- public static void log(String s) {
- if (VERBOSE) System.out.println(s);
- }
-
- }
-
- // -----------------------
- static class MyBuildProgressMonitor implements BuildProgressMonitor {
-
- public static boolean VERBOSE = false;
- private static MyBuildProgressMonitor _instance = new MyBuildProgressMonitor();
- private MyBuildProgressMonitor() {}
-
- private List compiledFiles=new ArrayList();
- private List wovenClasses=new ArrayList();
-
-
- public static BuildProgressMonitor getInstance() {
- return _instance;
- }
-
- public static void reset() {
- _instance.finished = false;
- _instance.wasFullBuild=true;
- _instance.compiledFiles.clear();
- _instance.wovenClasses.clear();
- }
-
- public static boolean hasFinished() {
- return _instance.finished;
- }
-
- public static List getCompiledFiles() { return _instance.compiledFiles;}
- public static List getWovenClasses() { return _instance.wovenClasses; }
-
- //---
-
- private long starttime = 0;
- private long totaltimetaken = 0;
- private boolean finished = false;
- private boolean wasFullBuild = true;
-
- public void start(String configFile) {
- starttime = System.currentTimeMillis();
- log("BuildProgressMonitor.start("+configFile+")");
- }
-
- public void setProgressText(String text) {
- log("BuildProgressMonitor.setProgressText("+text+")");
- if (text.startsWith("compiled: ")) {
- compiledFiles.add(text.substring(10));
- } else if (text.startsWith("woven class ")) {
- wovenClasses.add(text.substring(12));
- } else if (text.startsWith("woven aspect ")) {
- wovenClasses.add(text.substring(13));
- }
- }
-
- public void setProgressBarVal(int newVal) {
- log("BuildProgressMonitor.setProgressBarVal("+newVal+")");
- }
-
- public void incrementProgressBarVal() {
- log("BuildProgressMonitor.incrementProgressBarVal()");
- }
-
- public void setProgressBarMax(int maxVal) {
- log("BuildProgressMonitor.setProgressBarMax("+maxVal+")");
- }
-
- public int getProgressBarMax() {
- log("BuildProgressMonitor.getProgressBarMax() [returns 100]");
- return 100;
- }
-
- public void finish(boolean b) {
- log("BuildProgressMonitor.finish()");
- _instance.finished=true;
- _instance.wasFullBuild = b;
- _instance.totaltimetaken=(System.currentTimeMillis()-starttime);
- }
-
- public static long getTimeTaken() {
- return _instance.totaltimetaken;
- }
-
- public static void log(String s) {
- if (VERBOSE) System.out.println(s);
- }
-
- public static boolean wasFullBuild() {
- return _instance.wasFullBuild;
- }
-
-
- }
-
- // ----
-
- static class MyTaskListManager implements TaskListManager {
-
- private static final String CANT_BUILD_INCREMENTAL_INDICATION = "Unable to perform incremental build";
- private static final String DOING_BATCH_BUILD_INDICATION = "Performing batch build for config";
-
- private final static boolean VERBOSE = false;
- static MyTaskListManager _instance = new MyTaskListManager();
- private MyTaskListManager() {}
-
- private boolean receivedNonIncrementalBuildMessage = false;
- private boolean receivedBatchBuildMessage = false;
- private List errorMessages = new ArrayList();
- private List warningMessages = new ArrayList();
- private List weavingMessages = new ArrayList();
-
- public static void reset() {
- _instance.receivedNonIncrementalBuildMessage=false;
- _instance.receivedBatchBuildMessage=false;
- _instance.errorMessages.clear();
- _instance.warningMessages.clear();
- _instance.weavingMessages.clear();
- }
-
-// public static boolean defaultedToBatch() {
-// return _instance.receivedNonIncrementalBuildMessage;
-// }
-//
-// public static boolean didBatchBuild() {
-// return _instance.receivedBatchBuildMessage;
-// }
-
- public static boolean hasErrorMessages() {
- return !_instance.errorMessages.isEmpty();
- }
-
- public static List/*IMessage*/ getErrorMessages() {
- return _instance.errorMessages;
- }
-
- public static List/*IMessage*/ getWarningMessages() {
- return _instance.warningMessages;
- }
-
- public static List/*IMessage*/ getWeavingMessages() {
- return _instance.weavingMessages;
- }
-
- public static TaskListManager getInstance() {
- return _instance;
- }
-
- public void addSourcelineTask(String message, ISourceLocation sourceLocation, Kind kind) {
- log("TaskListManager.addSourcelineTask("+message+","+sourceLocation+","+kind+")");
- }
-
- // DOESSOMETHING
- public void addSourcelineTask(IMessage message) {
-// if (message.getKind()==IMessage.INFO) {
-// if (message.getMessage().startsWith(CANT_BUILD_INCREMENTAL_INDICATION)) _instance.receivedNonIncrementalBuildMessage=true;
-// if (message.getMessage().startsWith(DOING_BATCH_BUILD_INDICATION)) _instance.receivedBatchBuildMessage=true;
-// }
- if (message.getKind()==IMessage.ERROR) errorMessages.add(message);
- if (message.getKind()==IMessage.WARNING) warningMessages.add(message);
- if (message.getKind()==IMessage.WEAVEINFO) weavingMessages.add(message);
- log("TaskListManager.addSourcelineTask("+message+")");
- }
-
- public boolean hasWarning() {
- log("TaskListManager.hasWarning() [returning "+(!warningMessages.isEmpty())+"]");
- return !warningMessages.isEmpty();
- }
-
- public void addProjectTask(String message, Kind kind) {
- log("TaskListManager.addProjectTask("+message+","+kind+")");
- }
-
- public void clearTasks() {
- log("TaskListManager.clearTasks()");
- }
-
- public static void log(String s) {
- if (VERBOSE) System.out.println(s);
- }
- }
-
- // ----
-
- static class MyBuildOptionsAdapter implements BuildOptionsAdapter {
- static MyBuildOptionsAdapter _instance = new MyBuildOptionsAdapter();
- private MyBuildOptionsAdapter() {}
-
- private Map javaOptionsMap;
-
- public static void setJavaOptionsMap(Map options) {
- _instance.javaOptionsMap = options;
- }
-
- public static void setNonStandardOptions(String options) {
- _instance.nonstandardoptions = options;
- }
-
- private String nonstandardoptions=null;
-
- public static void reset() {
- _instance.nonstandardoptions=null;
- _instance.javaOptionsMap = null;
- }
-
- public static BuildOptionsAdapter getInstance() {
- return _instance;
- }
-
- public Map getJavaOptionsMap() {
- if (javaOptionsMap != null && !javaOptionsMap.isEmpty() ) return javaOptionsMap;
-
- Hashtable ht = new Hashtable();
- ht.put("org.eclipse.jdt.core.compiler.compliance","1.5");
- ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
- ht.put("org.eclipse.jdt.core.compiler.source","1.5");
- return ht;
- }
-
- public boolean getUseJavacMode() {
- return false;
- }
-
- public String getWorkingOutputPath() {
- return null;
- }
-
- public boolean getPreprocessMode() {
- return false;
- }
-
- public String getCharacterEncoding() {
- return null;
- }
-
- public boolean getSourceOnePointFourMode() {
- return false;
- }
-
- // DOESSOMETHING
- public boolean getIncrementalMode() {
- return true;
- }
-
- public boolean getLenientSpecMode() {
- return false;
- }
-
- public boolean getStrictSpecMode() {
- return false;
- }
-
- public boolean getPortingMode() {
- return false;
- }
-
- public String getNonStandardOptions() {
- return nonstandardoptions;
- }
-
- public String getComplianceLevel() {
- // AJDT doesn't set the compliance level directly
- // instead it relies on the javaOptionsMap
- return null;
- }
-
- public String getSourceCompatibilityLevel() {
- // AJDT doesn't set the source compatibility level
- // instead it relies on the javaOptionsMap
- return null;
- }
-
- public Set getWarnings() {
- return null;
- }
-
- public Set getDebugLevel() {
- return null;
- }
-
- public boolean getNoImportError() {
- return false;
- }
-
- public boolean getPreserveAllLocals() {
- return false;
- }
- }
-
- // ----
-
- static class MyOutputLocationManager implements OutputLocationManager {
-
- private File classOutputLoc;
- private File resourceOutputLoc;
- private String testProjectOutputPath;
- private List allOutputLocations;
- private File outputLoc;
-
- public MyOutputLocationManager(String testProjectPath) {
- this.testProjectOutputPath = testProjectPath + File.separator + "bin";
- outputLoc = new File(testProjectOutputPath);
-
- allOutputLocations = new ArrayList();
- allOutputLocations.add(outputLoc);
- }
-
- public File getOutputLocationForClass(File compilationUnit) {
- return outputLoc;
- }
-
- public File getOutputLocationForResource(File resource) {
- return outputLoc;
- }
-
- public List /*File*/ getAllOutputLocations() {
- return allOutputLocations;
- }
-
- public File getDefaultOutputLocation() {
- return outputLoc;
- }
-
- }
-
- // ----
static class MyStateListener extends AbstractStateListener {
-/* *******************************************************************
- * Copyright (c) 2006 Contributors.
- * All rights reserved.
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
*
* Contributors:
* Adrian Colyer Initial implementation
- * ******************************************************************/
+ * Helen Hawkins Converted to new interface (bug 148190)
+ *******************************************************************/
package org.aspectj.systemtest.incremental.tools;
* @param args workspace_root_dir project_name
*/
public static void main(String[] args) throws Exception {
- //AjdeInteractionTestbed.VERBOSE = true;
- //MultiProjectIncrementalTests.VERBOSE = true;
AjdeInteractionTestbedLauncher.testdataSrcDir = args[0];
- AjdeInteractionTestbedLauncher launcher = new AjdeInteractionTestbedLauncher();
+ AjdeInteractionTestbedLauncher launcher = new AjdeInteractionTestbedLauncher(args[1]);
launcher.setUp();
launcher.buildProject(args[1]);
- launcher.printBuildReport();
+ //launcher.printBuildReport();
launcher.tearDown();
}
- public AjdeInteractionTestbedLauncher() {
+ public AjdeInteractionTestbedLauncher(String projectName) {
String classPath = System.getProperty("java.class.path");
- ((MyProjectPropertiesAdapter)MyProjectPropertiesAdapter.getInstance()).setClasspath(classPath);
+ ((MultiProjTestCompilerConfiguration)getCompilerForProjectWithName(projectName)
+ .getCompilerConfiguration()).setClasspath(classPath);
}
private void buildProject(String projectName) {
- configureBuildStructureModel(true);
initialiseProject(projectName);
build(projectName);
}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version (bug 148190)
+ *******************************************************************/
+package org.aspectj.systemtest.incremental.tools;
+
+import java.util.Collection;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.aspectj.ajde.core.AjCompiler;
+
+/**
+ * Manages the different compilers for the different projects within one test run
+ */
+public class CompilerFactory {
+
+ private static Map compilerMap = new Hashtable();
+
+ /**
+ * If an AjCompiler exists for the given projectDir then returns
+ * that, otherwise creates a new one.
+ */
+ public static AjCompiler getCompilerForProjectWithDir(String projectDir) {
+ if (compilerMap.containsKey(projectDir)) {
+ return (AjCompiler) compilerMap.get(projectDir);
+ }
+
+ AjCompiler compiler = new AjCompiler(
+ projectDir,
+ new MultiProjTestCompilerConfiguration(projectDir),
+ new MultiProjTestBuildProgressMonitor(),
+ new MultiProjTestMessageHandler());
+ compilerMap.put(projectDir,compiler);
+ return compiler;
+ }
+
+ /**
+ * Clears the current map - before doing so clears the state of
+ * each compiler (this ensures everything is cleaned up in the
+ * IncrementalStateManager)
+ */
+ public static void clearCompilerMap() {
+ Collection compilers = compilerMap.values();
+ for (Iterator iterator = compilers.iterator(); iterator.hasNext();) {
+ AjCompiler compiler = (AjCompiler) iterator.next();
+ compiler.clearLastState();
+ }
+ compilerMap.clear();
+ }
+
+}
import java.util.ArrayList;
import java.util.List;
-import org.aspectj.ajde.OutputLocationManager;
+import org.aspectj.ajde.core.IOutputLocationManager;
/**
public void testPr166580() {
initialiseProject("PR166580");
- configureOutputLocationManager(new MyOutputLocationManager("PR166580",2));
+ configureOutputLocationManager("PR166580",new MyOutputLocationManager("PR166580",2));
build("PR166580");
checkWasFullBuild();
alter("PR166580","inc1");
/**
* Will send output from src dir 'srcX' to directory 'binX'
*/
- private class MyOutputLocationManager implements OutputLocationManager {
+ private class MyOutputLocationManager implements IOutputLocationManager {
private String projectDir;
private int numberOfSrcDirs;
import java.util.Map;
import java.util.Set;
-import org.aspectj.ajde.OutputLocationManager;
+import org.aspectj.ajde.core.IOutputLocationManager;
import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
import org.aspectj.ajdt.internal.core.builder.AjBuildManager;
import org.aspectj.ajdt.internal.core.builder.AjState;
initialiseProject("inpathTesting");
inpathTestingDir = getWorkingDir() + File.separator + "inpathTesting";
expectedOutputDir = inpathTestingDir + File.separator + "bin";
- configureOutputLocationManager(new MyOutputLocationManager(inpathTestingDir), false);
+ configureOutputLocationManager("inpathTesting",new SingleDirOutputLocMgr(inpathTestingDir));
}
/**
// expect to compile the aspect in 'inpathTesting' project and weave
// both the aspect and the class on the inpath.
- checkCompileWeaveCount(1,2);
+ checkCompileWeaveCount("inpathTesting",1,2);
// get hold of the state for this project - expect to find one
AjState state = getState();
build("inpathTesting");
// expect to compile the aspect in 'inpathTesting' project and weave
// both the aspect and the class in the jar on the inpath.
- checkCompileWeaveCount(1,2);
+ checkCompileWeaveCount("inpathTesting",1,2);
AjState state = getState();
}
public void testOutxml() {
- configureNonStandardCompileOptions("-outxml");
+ configureNonStandardCompileOptions("inpathTesting","-outxml");
build("inpathTesting");
String resource = expectedOutputDir + File.separator + "META-INF" + File.separator + "aop-ajc.xml";
File f = new File(resource);
}
public void testAspectsRecordedOnlyOnceInState() {
- configureNonStandardCompileOptions("-outxml");
+ configureNonStandardCompileOptions("inpathTesting","-outxml");
build("inpathTesting");
AjState state = getState();
Map m = state.getAspectNamesToFileNameMap();
private AjState getState() {
// get hold of the state for this project - expect to find one
- AjState state = IncrementalStateManager.retrieveStateFor(inpathTestingDir + File.separator + "build.lst" );
+ AjState state = IncrementalStateManager.retrieveStateFor(inpathTestingDir);
assertNotNull("expected to find AjState for build config " + inpathTestingDir
- + File.separator + "build.lst but didn't", state);
+ + " but didn't", state);
return state;
}
private void addInpathEntry(String entry) {
if (entry == null) {
- configureInPath(null);
+ configureInPath("inpathTesting",null);
return;
}
File f = new File(entry);
Set s = new HashSet();
s.add(f);
- configureInPath(s);
+ configureInPath("inpathTesting",s);
}
/**
* Sends all output to the same directory
*/
- private static class SingleDirOutputLocMgr implements OutputLocationManager {
+ private static class SingleDirOutputLocMgr implements IOutputLocationManager {
private File classOutputLoc;
private File resourceOutputLoc;
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version (bug 148190)
+ *******************************************************************/
+package org.aspectj.systemtest.incremental.tools;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.ajde.core.IBuildProgressMonitor;
+
+/**
+ * IBuildProgressMonitor that records how many files were compiled and
+ * woven as well as whether or not the build was a full build. Will print
+ * progress information to the screen if VERBOSE is true.
+ */
+public class MultiProjTestBuildProgressMonitor implements IBuildProgressMonitor {
+
+ public boolean VERBOSE = false;
+
+ private List compiledFiles=new ArrayList();
+ private List wovenClasses=new ArrayList();
+
+ private long starttime = 0;
+ private long totaltimetaken = 0;
+ private boolean wasFullBuild = true;
+
+ public void finish(boolean wasFullBuild) {
+ log("IBuildProgressMonitor.finish(" + wasFullBuild + ")");
+ this.wasFullBuild = wasFullBuild;
+ totaltimetaken=(System.currentTimeMillis()-starttime);
+ }
+
+ public boolean isCancelRequested() {
+ log("IBuildProgressMonitor.isCancelRequested()");
+ return false;
+ }
+
+ public void setProgress(double percentDone) {
+ log("IBuildProgressMonitor.setProgress("+percentDone+")");
+ }
+
+ public void setProgressText(String text) {
+ log("BuildProgressMonitor.setProgressText("+text+")");
+ if (text.startsWith("compiled: ")) {
+ compiledFiles.add(text.substring(10));
+ } else if (text.startsWith("woven class ")) {
+ wovenClasses.add(text.substring(12));
+ } else if (text.startsWith("woven aspect ")) {
+ wovenClasses.add(text.substring(13));
+ }
+ }
+
+ public void begin() {
+ starttime = System.currentTimeMillis();
+ log("IBuildProgressMonitor.start()");
+ }
+
+ public List getCompiledFiles() { return compiledFiles;}
+ public List getWovenClasses() { return wovenClasses; }
+
+ public void log(String s) {
+ if (VERBOSE) System.out.println(s);
+ }
+
+ public long getTimeTaken() {
+ return totaltimetaken;
+ }
+
+ public boolean wasFullBuild() {
+ return wasFullBuild;
+ }
+
+ public void reset() {
+ wasFullBuild=true;
+ compiledFiles.clear();
+ wovenClasses.clear();
+ }
+}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version (bug 148190)
+ *******************************************************************/
+package org.aspectj.systemtest.incremental.tools;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.aspectj.ajde.core.ICompilerConfiguration;
+import org.aspectj.ajde.core.IOutputLocationManager;
+
+/**
+ * ICompilerConfiguration which mirrors the way AJDT behaves. Always returns
+ * that its 1.5 compliant and enables the setting of all options except
+ * output jar.
+ */
+public class MultiProjTestCompilerConfiguration implements ICompilerConfiguration {
+
+ private boolean verbose = false;
+
+ private String classPath = "";
+ private Set aspectPath = null;
+ private Map sourcePathResources = null;
+ private IOutputLocationManager outputLocationManager = null;
+ private List dependants;
+ private Map javaOptionsMap;
+ private Set inpath;
+ private String outjar;
+ private String nonstandardoptions;
+ private List projectSourceFiles = new ArrayList();
+ private String projectPath;
+
+ public MultiProjTestCompilerConfiguration(String projectPath) {
+ this.projectPath = projectPath;
+ }
+
+ public Set getAspectPath() {
+ log("ICompilerConfiguration.getAspectPath("+aspectPath+")");
+ return aspectPath;
+ }
+
+ public String getClasspath() {
+ log("ICompilerConfiguration.getClasspath()");
+ // AJDT has all the output directories on it's classpath
+ StringBuffer sb = new StringBuffer();
+ List allOutputPaths = getOutputLocationManager().getAllOutputLocations();
+ for (Iterator iterator = allOutputPaths.iterator(); iterator.hasNext();) {
+ File dir = (File) iterator.next();
+ sb.append(File.pathSeparator + dir.getAbsolutePath());
+ }
+ String cp =
+ sb.toString() + File.pathSeparator +
+ new File(AjdeInteractionTestbed.testdataSrcDir) + File.pathSeparator +
+ System.getProperty("sun.boot.class.path") +
+ File.pathSeparator + "../runtime/bin" +
+ File.pathSeparator + this.classPath +
+ File.pathSeparator + System.getProperty("aspectjrt.path") +
+ File.pathSeparator + "../lib/junit/junit.jar" +
+ "c:/batik/batik-1.6/lib/batik-util.jar;"+
+ "c:/batik/batik-1.6/lib/batik-awt-util.jar;"+
+ "c:/batik/batik-1.6/lib/batik-dom.jar;"+
+ "c:/batik/batik-1.6/lib/batik-svggen.jar;"+
+ File.pathSeparator+".."+File.separator+"lib" + File.separator+"test"+File.separator+"aspectjrt.jar";
+
+ // look at dependant projects
+ if (dependants!=null) {
+ for (Iterator iter = dependants.iterator(); iter.hasNext();) {
+ cp = AjdeInteractionTestbed.getFile((String)iter.next(),"bin")+File.pathSeparator+cp;
+ }
+ }
+ //System.err.println("For project "+projectPath+" getClasspath() returning "+cp);
+ return cp;
+ }
+
+ public Set getInpath() {
+ log("ICompilerConfiguration.getInPath()");
+ return inpath;
+ }
+
+ public Map getJavaOptionsMap() {
+ log("ICompilerConfiguration.getJavaOptionsMap()");
+ if (javaOptionsMap != null && !javaOptionsMap.isEmpty() ) return javaOptionsMap;
+
+ Hashtable ht = new Hashtable();
+ ht.put("org.eclipse.jdt.core.compiler.compliance","1.5");
+ ht.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
+ ht.put("org.eclipse.jdt.core.compiler.source","1.5");
+ return ht;
+ }
+
+ public String getNonStandardOptions() {
+ log("ICompilerConfiguration.getNonStandardOptions( " + nonstandardoptions +")");
+ return nonstandardoptions;
+ }
+
+ public String getOutJar() {
+ log("ICompilerConfiguration.getOutJar()");
+ return null;
+ }
+
+ public IOutputLocationManager getOutputLocationManager() {
+ log("ICompilerConfiguration.getOutputLocationManager()");
+ if (outputLocationManager == null) {
+ outputLocationManager = new MultiProjTestOutputLocationManager(projectPath);
+ }
+ return outputLocationManager;
+ }
+
+ public List getProjectSourceFiles() {
+ log("ICompilerConfiguration.getProjectSourceFiles()");
+ return projectSourceFiles;
+ }
+
+ public Map getSourcePathResources() {
+ log("ICompilerConfiguration.getSourcePathResources()");
+ return sourcePathResources;
+ }
+
+ public void log(String s) {
+ if (verbose) System.out.println(s);
+ }
+
+ public void addDependancy(String projectItDependsOn) {
+ if (dependants == null) {
+ dependants = new ArrayList();
+ }
+ dependants.add(projectItDependsOn);
+ }
+
+ // -------------------- setter methods useful for testing ---------------
+ public void setAspectPath(Set aspectPath) {
+ this.aspectPath = aspectPath;
+ }
+
+ public void setInpath(Set inpath) {
+ this.inpath = inpath;
+ }
+
+ public void setOutjar(String outjar) {
+ this.outjar = outjar;
+ }
+
+ public void setJavaOptions(Map javaOptions) {
+ this.javaOptionsMap = javaOptions;
+ }
+
+ public void setNonStandardOptions(String options) {
+ this.nonstandardoptions = options;
+ }
+
+ public void setProjectSourceFiles(List projectSourceFiles) {
+ this.projectSourceFiles = projectSourceFiles;
+ }
+
+ public void setSourcePathResources(Map sourcePathResources) {
+ this.sourcePathResources = sourcePathResources;
+ }
+
+ public void setOutputLocationManager(IOutputLocationManager manager) {
+ this.outputLocationManager = manager;
+ }
+
+ public void setClasspath(String path) {
+ this.classPath = path;
+ }
+}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version (bug 148190)
+ *******************************************************************/
+package org.aspectj.systemtest.incremental.tools;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.ajde.core.IBuildMessageHandler;
+import org.aspectj.bridge.AbortException;
+import org.aspectj.bridge.IMessage;
+import org.aspectj.bridge.IMessage.Kind;
+
+/**
+ * IMessageHandler which by default ignores INFO and WEAVEINFO messages.
+ * Records the warning, weaving, compiler errors and error messages and
+ * provides methods to get them.
+ */
+public class MultiProjTestMessageHandler implements IBuildMessageHandler {
+
+ private final boolean VERBOSE = false;
+
+ private boolean receivedNonIncrementalBuildMessage = false;
+ private boolean receivedBatchBuildMessage = false;
+
+ private List errorMessages;
+ private List warningMessages;
+ private List weavingMessages;
+ private List compilerErrors;
+ private List ignoring;
+
+ public MultiProjTestMessageHandler() {
+ ignoring = new ArrayList();
+ errorMessages = new ArrayList();
+ warningMessages = new ArrayList();
+ weavingMessages = new ArrayList();
+ compilerErrors = new ArrayList();
+ ignore(IMessage.INFO);
+ ignore(IMessage.WEAVEINFO);
+ }
+
+ public boolean handleMessage(IMessage message) throws AbortException {
+ IMessage.Kind kind = message.getKind();
+ if (isIgnoring(kind)) {
+ return true;
+ }
+ if (kind.equals(IMessage.ABORT) || message.getThrown() != null) {
+ log("> AjCompiler error: "+message.getMessage() +", " + message.getThrown() + ")"); //$NON-NLS-1$
+ message.getThrown().printStackTrace();
+ compilerErrors.add(message + ", (" + message.getThrown() +")");
+ if (VERBOSE && (message.getThrown() != null)) message.getThrown().printStackTrace();
+ return true;
+ }
+ if (message.getKind()==IMessage.ERROR) errorMessages.add(message);
+ if (message.getKind()==IMessage.WARNING) warningMessages.add(message);
+ if (message.getKind()==IMessage.WEAVEINFO) weavingMessages.add(message);
+ log("IMessageHandler.handleMessage("+message+")");
+ return true;
+ }
+
+ public void dontIgnore(Kind kind) {
+ if (null != kind) {
+ ignoring.remove(kind);
+ }
+ }
+
+ public boolean isIgnoring(Kind kind) {
+ return ((null != kind) && (ignoring.contains(kind)));
+ }
+
+ public void ignore(Kind kind) {
+ if ((null != kind) && (!ignoring.contains(kind))) {
+ ignoring.add(kind);
+ }
+ }
+
+ public boolean hasWarning() {
+ return !warningMessages.isEmpty();
+ }
+
+ public boolean hasErrorMessages() {
+ return !errorMessages.isEmpty();
+ }
+
+ public boolean hasCompilerErrorMessages() {
+ return !compilerErrors.isEmpty();
+ }
+
+ public List/*IMessage*/ getErrorMessages() {
+ return errorMessages;
+ }
+
+ public List/*IMessage*/ getWarningMessages() {
+ return warningMessages;
+ }
+
+ public List/*IMessage*/ getWeavingMessages() {
+ return weavingMessages;
+ }
+
+ public List/*IMessage*/ getCompilerErrors() {
+ return compilerErrors;
+ }
+
+
+ public void log(String s) {
+ if (VERBOSE) System.out.println(s);
+ }
+
+
+ public void reset() {
+ receivedNonIncrementalBuildMessage=false;
+ receivedBatchBuildMessage=false;
+ errorMessages.clear();
+ warningMessages.clear();
+ weavingMessages.clear();
+ compilerErrors.clear();
+ }
+}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2007 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version (bug 148190)
+ *******************************************************************/
+package org.aspectj.systemtest.incremental.tools;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aspectj.ajde.core.IOutputLocationManager;
+
+/**
+ * An IOutputLocationManager which by default sends all output to the
+ * testProjectPath\bin directory. However, there are getter methods which
+ * enable sending resources and classes to different output dirs. Doesn't
+ * enable sending different classes to different output locations.
+ */
+public class MultiProjTestOutputLocationManager implements IOutputLocationManager {
+
+ private String testProjectOutputPath;
+ private File classOutputLoc;
+ private File resourceOutputLoc;
+ private List allOutputLocations;
+
+ public MultiProjTestOutputLocationManager(String testProjectPath) {
+ this.testProjectOutputPath = testProjectPath + File.separator + "bin";
+ }
+
+ public File getOutputLocationForClass(File compilationUnit) {
+ initLocations();
+ return classOutputLoc;
+ }
+
+ public File getOutputLocationForResource(File resource) {
+ initLocations();
+ return resourceOutputLoc;
+ }
+
+ public List getAllOutputLocations() {
+ if(allOutputLocations == null) {
+ allOutputLocations = new ArrayList();
+ initLocations();
+ allOutputLocations.add(classOutputLoc);
+ if (!classOutputLoc.equals(resourceOutputLoc)) {
+ allOutputLocations.add(resourceOutputLoc);
+ }
+ }
+ return allOutputLocations;
+ }
+
+ public File getDefaultOutputLocation() {
+ return classOutputLoc;
+ }
+
+ private void initLocations() {
+ if (classOutputLoc == null) {
+ classOutputLoc = new File(testProjectOutputPath);
+ }
+ if (resourceOutputLoc == null) {
+ resourceOutputLoc = new File(testProjectOutputPath);
+ }
+ }
+
+ // -------------- setter methods useful for testing -------------
+ public void setOutputLocForClass(File f) {
+ classOutputLoc = f;
+ }
+
+ public void setOutputLocForResource(File f) {
+ resourceOutputLoc = f;
+ }
+
+}
-/* *******************************************************************
- * Copyright (c) 2005 Contributors.
- * All rights reserved.
+/********************************************************************
+ * Copyright (c) 2005 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Andy Clement initial implementation
-* ******************************************************************/
+ * Andy Clement initial implementation
+ * Helen Hawkins Converted to new interface (bug 148190)
+ *******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.io.File;
import java.util.List;
import java.util.Set;
-import org.aspectj.ajde.Ajde;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
import org.aspectj.ajdt.internal.core.builder.AjState;
import org.aspectj.ajdt.internal.core.builder.IncrementalStateManager;
import org.aspectj.asm.internal.JDTLikeHandleProvider;
import org.aspectj.asm.internal.Relationship;
import org.aspectj.bridge.IMessage;
-import org.aspectj.bridge.IMessageHandler;
-import org.aspectj.bridge.IMessageHolder;
import org.aspectj.tools.ajc.Ajc;
import org.aspectj.util.FileUtil;
-import org.aspectj.weaver.LintMessage;
/**
* The superclass knows all about talking through Ajde to the compiler.
public void testDontLoseAdviceMarkers_pr134471() {
try {
// see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
- configureBuildStructureModel(true);
initialiseProject("P4");
build("P4");
Ajc.dumpAJDEStructureModel("after full build where advice is applying");
} finally {
// see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=true;
- configureBuildStructureModel(false);
+ //configureBuildStructureModel(false);
}
}
build("P1"); // This first build will be batch
build("P1");
checkWasntFullBuild();
- checkCompileWeaveCount(0,0);
+ checkCompileWeaveCount("P1",0,0);
}
// source code doesnt matter, we are checking invalid path handling
File f = new File("foo.jar");
Set s = new HashSet();
s.add(f);
- configureAspectPath(s);
+ configureAspectPath("P1",s);
build("P1"); // This first build will be batch
- checkForError("invalid aspectpath entry");
+ checkForError("P1","invalid aspectpath entry");
}
build("P1"); // This first build will be batch
alter("P1","inc1"); // adds a single class
build("P1");
- checkCompileWeaveCount(1,-1);
+ checkCompileWeaveCount("P1",1,-1);
build("P1");
- checkCompileWeaveCount(0,-1);
+ checkCompileWeaveCount("P1",0,-1);
}
alter("P1","inc1"); // adds a class
alter("P1","inc2"); // adds an aspect
build("P1"); // build 1,
- long timeTakenForFullBuildAndWeave = getTimeTakenForBuild();
+ long timeTakenForFullBuildAndWeave = getTimeTakenForBuild("P1");
checkWasFullBuild(); // it *will* be a full build under the new
// "back-to-the-source strategy
- checkCompileWeaveCount(5,3); // we compile X and A (the delta) find out that
+ checkCompileWeaveCount("P1",5,3); // we compile X and A (the delta) find out that
// an aspect has changed, go back to the source
// and compile X,A,C, then weave them all.
build("P1");
- long timeTakenForSimpleIncBuild = getTimeTakenForBuild();
+ long timeTakenForSimpleIncBuild = getTimeTakenForBuild("P1");
// I don't think this test will have timing issues as the times should be *RADICALLY* different
// On my config, first build time is 2093ms and the second is 30ms
assertTrue("Should not take longer for the trivial incremental build! first="+timeTakenForFullBuildAndWeave+
public void testBuildingTwoProjectsInTurns() {
- configureBuildStructureModel(true);
initialiseProject("P1");
initialiseProject("P2");
build("P1");
*/
public void testBuildingTwoProjectsMakingSmallChanges() {
- configureBuildStructureModel(true);
-
initialiseProject("P1");
initialiseProject("P2");
build("PR134371");
alter("PR134371","inc1");
build("PR134371");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
+ assertTrue("There should be no exceptions handled:\n"
+ +getErrorMessages("PR134371"),getErrorMessages("PR134371").isEmpty());
}
* structure model is right after each build
*/
public void testBuildingTwoProjectsAndVerifyingModel() {
-
- configureBuildStructureModel(true);
-
initialiseProject("P1");
initialiseProject("P2");
// Setup up two simple projects and build them in turn - check the
// structure model is right after each build
public void testBuildingTwoProjectsAndVerifyingStuff() {
- configureBuildStructureModel(true);
-
initialiseProject("P1");
initialiseProject("P2");
public void testPr125405() {
initialiseProject("PR125405");
build("PR125405");
- checkCompileWeaveCount(1,1);
+ checkCompileWeaveCount("PR125405",1,1);
alter("PR125405","inc1");
build("PR125405");
// "only abstract aspects can have type parameters"
- checkForError("only abstract aspects can have type parameters");
+ checkForError("PR125405","only abstract aspects can have type parameters");
alter("PR125405","inc2");
build("PR125405");
- checkCompileWeaveCount(1,1);
- assertTrue("Should be no errors, but got "+MyTaskListManager.getErrorMessages(),MyTaskListManager.getErrorMessages().size()==0);
+ checkCompileWeaveCount("PR125405",1,1);
+ assertTrue("Should be no errors, but got "+getErrorMessages("PR125405"),
+ getErrorMessages("PR125405").size()==0);
}
public void testPr128618() {
initialiseProject("PR128618_2");
configureNewProjectDependency("PR128618_2","PR128618_1");
assertTrue("there should be no warning messages before we start",
- MyTaskListManager.getWarningMessages().isEmpty());
+ getWarningMessages("PR128618_1").isEmpty());
+ assertTrue("there should be no warning messages before we start",
+ getWarningMessages("PR128618_2").isEmpty());
+
build("PR128618_1");
build("PR128618_2");
- List warnings = MyTaskListManager.getWarningMessages();
+ List l = getWarningMessages("PR128618_2");
+
+ // there should be one warning against "PR128618_2"
+ List warnings = getWarningMessages("PR128618_2");
assertTrue("Should be one warning, but there are #"+warnings.size(),warnings.size()==1);
- IMessage msg = (IMessage)(MyTaskListManager.getWarningMessages().get(0));
+ IMessage msg = (IMessage)(getWarningMessages("PR128618_2").get(0));
assertEquals("warning should be against the FFDC.aj resource","FFDC.aj",msg.getSourceLocation().getSourceFile().getName());
+
+
alter("PR128618_2","inc1");
build("PR128618_2");
+
checkWasntFullBuild();
- IMessage msg2 = (IMessage)(MyTaskListManager.getWarningMessages().get(0));
+ IMessage msg2 = (IMessage)(getWarningMessages("PR128618_2").get(0));
assertEquals("warning should be against the FFDC.aj resource","FFDC.aj",msg2.getSourceLocation().getSourceFile().getName());
assertFalse("a new warning message should have been generated", msg.equals(msg2));
}
public void testPr119570() {
initialiseProject("PR119570");
build("PR119570");
- assertTrue("Should be no errors, but got "+MyTaskListManager.getErrorMessages(),MyTaskListManager.getErrorMessages().size()==0);
+ assertNoErrors("PR119570");
}
public void testPr119570_2() {
initialiseProject("PR119570_2");
build("PR119570_2");
- List l = MyTaskListManager.getWarningMessages();
+ List l = getWarningMessages("PR119570_2");
assertTrue("Should be no warnings, but got "+l,l.size()==0);
}
public void testPr117209() {
try {
initialiseProject("pr117209");
- configureNonStandardCompileOptions("-proceedOnError");
+ configureNonStandardCompileOptions("pr117209","-proceedOnError");
build("pr117209");
- checkCompileWeaveCount(6,6);
+ checkCompileWeaveCount("pr117209",6,6);
} finally {
- MyBuildOptionsAdapter.reset();
+ //MyBuildOptionsAdapter.reset();
}
}
}
public void testPr157054() {
- configureBuildStructureModel(true);
- MyBuildOptionsAdapter.setNonStandardOptions("-showWeaveInfo");
initialiseProject("PR157054");
+ configureNonStandardCompileOptions("PR157054","-showWeaveInfo");
+ configureShowWeaveInfoMessages("PR157054",true);
build("PR157054");
checkWasFullBuild();
- List weaveMessages = MyTaskListManager.getWeavingMessages();
+ List weaveMessages = getWeavingMessages("PR157054");
assertTrue("Should be two weaving messages but there are "+weaveMessages.size(),weaveMessages.size()==2);
alter("PR157054","inc1");
build("PR157054");
- weaveMessages = MyTaskListManager.getWeavingMessages();
+ weaveMessages = getWeavingMessages("PR157054");
assertTrue("Should be three weaving messages but there are "+weaveMessages.size(),weaveMessages.size()==3);
checkWasntFullBuild();
fullBuild("PR157054");
- weaveMessages = MyTaskListManager.getWeavingMessages();
+ weaveMessages = getWeavingMessages("PR157054");
assertTrue("Should be three weaving messages but there are "+weaveMessages.size(),weaveMessages.size()==3);
}
public void testPr121384() {
// AjdeInteractionTestbed.VERBOSE=true;
// AsmManager.setReporting("c:/foo.txt",true,true,true,false);
- MyBuildOptionsAdapter.setNonStandardOptions("-showWeaveInfo");
- configureBuildStructureModel(true);
initialiseProject("pr121384");
+ configureNonStandardCompileOptions("pr121384","-showWeaveInfo");
build("pr121384");
checkWasFullBuild();
alter("pr121384","inc1");
public void testPr113531() {
initialiseProject("PR113531");
build("PR113531");
- assertFalse("build should have compiled ok",
- MyTaskListManager.hasErrorMessages());
+ assertTrue("build should have compiled ok",
+ getErrorMessages("PR113531").isEmpty());
alter("PR113531","inc1");
build("PR113531");
assertEquals("error message should be 'foo cannot be resolved' ",
"foo cannot be resolved",
- ((IMessage)MyTaskListManager.getErrorMessages().get(0))
+ ((IMessage)getErrorMessages("PR113531").get(0))
.getMessage());
alter("PR113531","inc2");
build("PR113531");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
+ assertTrue("There should be no exceptions handled:\n"
+ +getCompilerErrorMessages("PR113531"),
+ getCompilerErrorMessages("PR113531").isEmpty());
assertEquals("error message should be 'foo cannot be resolved' ",
"foo cannot be resolved",
- ((IMessage)MyTaskListManager.getErrorMessages().get(0))
+ ((IMessage)getErrorMessages("PR113531").get(0))
.getMessage());
}
public void testPr119882() {
initialiseProject("PR119882");
build("PR119882");
- assertFalse("build should have compiled ok",MyTaskListManager.hasErrorMessages());
+ assertTrue("build should have compiled ok",getErrorMessages("PR119882").isEmpty());
alter("PR119882","inc1");
build("PR119882");
//fullBuild("PR119882");
- List errors = MyTaskListManager.getErrorMessages();
+ List errors = getErrorMessages("PR119882");
assertTrue("Should be at least one error, but got none",errors.size()==1);
assertEquals("error message should be 'i cannot be resolved' ",
"i cannot be resolved",
.getMessage());
alter("PR119882","inc2");
build("PR119882");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
+ assertTrue("There should be no exceptions handled:\n"
+ +getCompilerErrorMessages("PR119882"),
+ getCompilerErrorMessages("PR119882").isEmpty());
assertEquals("error message should be 'i cannot be resolved' ",
"i cannot be resolved",
((IMessage)errors.get(0))
//Bugzilla Bug 152257 - Incremental compiler doesn't handle exception declaration correctly
public void testPr152257() {
- configureNonStandardCompileOptions("-XnoInline");
initialiseProject("PR152257");
+ configureNonStandardCompileOptions("PR152257","-XnoInline");
build("PR152257");
- List errors = MyTaskListManager.getErrorMessages();
+ List errors = getErrorMessages("PR152257");
assertTrue("Should be no warnings, but there are #"+errors.size(),errors.size()==0);
checkWasFullBuild();
alter("PR152257","inc1");
build("PR152257");
- errors = MyTaskListManager.getErrorMessages();
+ errors = getErrorMessages("PR152257");
assertTrue("Should be no warnings, but there are #"+errors.size(),errors.size()==0);
checkWasntFullBuild();
}
public void testPr128655() {
- configureNonStandardCompileOptions("-showWeaveInfo");
initialiseProject("pr128655");
+ configureNonStandardCompileOptions("pr128655","-showWeaveInfo");
+ configureShowWeaveInfoMessages("pr128655",true);
build("pr128655");
- List firstBuildMessages = MyTaskListManager.getWeavingMessages();
+ List firstBuildMessages = getWeavingMessages("pr128655");
assertTrue("Should be at least one message about the dec @type, but there were none",firstBuildMessages.size()>0);
alter("pr128655","inc1");
build("pr128655");
checkWasntFullBuild(); // back to the source
- List secondBuildMessages = MyTaskListManager.getWeavingMessages();
+ List secondBuildMessages = getWeavingMessages("pr128655");
// check they are the same
for (int i = 0; i < firstBuildMessages.size(); i++) {
IMessage m1 = (IMessage)firstBuildMessages.get(i);
// Similar to above, but now the annotation is in the default package
public void testPr128655_2() {
- configureNonStandardCompileOptions("-showWeaveInfo");
initialiseProject("pr128655_2");
+ configureNonStandardCompileOptions("pr128655_2","-showWeaveInfo");
+ configureShowWeaveInfoMessages("pr128655_2", true);
build("pr128655_2");
- List firstBuildMessages = MyTaskListManager.getWeavingMessages();
+ List firstBuildMessages = getWeavingMessages("pr128655_2");
assertTrue("Should be at least one message about the dec @type, but there were none",firstBuildMessages.size()>0);
alter("pr128655_2","inc1");
build("pr128655_2");
checkWasntFullBuild(); // back to the source
- List secondBuildMessages = MyTaskListManager.getWeavingMessages();
+ List secondBuildMessages = getWeavingMessages("pr128655_2");
// check they are the same
for (int i = 0; i < firstBuildMessages.size(); i++) {
IMessage m1 = (IMessage)firstBuildMessages.get(i);
// test for comment #31 - NPE
public void testPr129163() {
- configureBuildStructureModel(true);
initialiseProject("PR129613");
build("PR129613");
alter("PR129613","inc1");
build("PR129613");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
+ assertTrue("There should be no exceptions handled:\n"+getCompilerErrorMessages("PR129613"),
+ getCompilerErrorMessages("PR129613").isEmpty());
assertEquals("warning message should be 'no match for this type name: File [Xlint:invalidAbsoluteTypeName]' ",
"no match for this type name: File [Xlint:invalidAbsoluteTypeName]",
- ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+ ((IMessage)getWarningMessages("PR129613").get(0))
.getMessage());
- configureBuildStructureModel(false);
}
// test for comment #0 - adding a comment to a class file shouldn't
// we shouldn't go back to source.
public void testPr129163_2() {
// want to behave like AJDT
- configureBuildStructureModel(true);
initialiseProject("pr129163_2");
build("pr129163_2");
checkWasFullBuild();
build("pr129163_2");
checkWasntFullBuild(); // shouldn't be a full build because the
// aspect hasn't changed
- configureBuildStructureModel(false);
}
// test for comment #6 - simulates AJDT core builder test testBug99133a -
// logic within CrosscuttingMembers and various equals methods to decide
// correctly that we don't have to go back to source.
public void testPr129163_3() {
- configureBuildStructureModel(true);
initialiseProject("PR129163_4");
build("PR129163_4");
checkWasFullBuild(); // should be a full build because initializing project
checkWasntFullBuild(); // should be an incremental build because nothing has
// changed within the class and no aspects have changed
// within the running of the test
- configureBuildStructureModel(false);
}
public void testPr133117() {
// System.gc();
// System.exit();
- configureNonStandardCompileOptions("-Xlint:warning");
initialiseProject("PR133117");
+ configureNonStandardCompileOptions("PR133117","-Xlint:warning");
build("PR133117");
assertTrue("There should only be one xlint warning message reported:\n"
- +MyTaskListManager.getWarningMessages(),
- MyTaskListManager.getWarningMessages().size()==1);
+ +getWarningMessages("PR133117"),
+ getWarningMessages("PR133117").size()==1);
alter("PR133117","inc1");
build("PR133117");
- List warnings = MyTaskListManager.getWarningMessages();
+ List warnings = getWarningMessages("PR133117");
List noGuardWarnings = new ArrayList();
for (Iterator iter = warnings.iterator(); iter.hasNext();) {
IMessage element = (IMessage) iter.next();
}
public void testPr131505() {
- configureNonStandardCompileOptions("-outxml");
initialiseProject("PR131505");
+ configureNonStandardCompileOptions("PR131505","-outxml");
build("PR131505");
checkWasFullBuild();
String outputDir = getWorkingDir().getAbsolutePath() + File.separatorChar
build("PR136585");
alter("PR136585","inc1");
build("PR136585");
- assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(),
- MyTaskListManager.getErrorMessages().isEmpty());
+ assertTrue("There should be no errors reported:\n"+getErrorMessages("PR136585"),
+ getErrorMessages("PR136585").isEmpty());
}
public void testPr133532() {
build("PR133532");
alter("PR133532","inc2");
build("PR133532");
- assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(),
- MyTaskListManager.getErrorMessages().isEmpty());
+ assertTrue("There should be no errors reported:\n"+getErrorMessages("PR133532"),
+ getErrorMessages("PR133532").isEmpty());
}
public void testPr133532_2() {
build("pr133532_2");
alter("pr133532_2","inc2");
build("pr133532_2");
- assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(),
- MyTaskListManager.getErrorMessages().isEmpty());
+ assertTrue("There should be no errors reported:\n"+getErrorMessages("pr133532_2"),
+ getErrorMessages("pr133532_2").isEmpty());
String decisions = AjdeInteractionTestbed.MyStateListener.getDecisions();
String expect="Need to recompile 'A.aj'";
assertTrue("Couldn't find build decision: '"+expect+"' in the list of decisions made:\n"+decisions,
build("PR133532_3");
alter("PR133532_3","inc1");
build("PR133532_3");
- assertTrue("There should be no errors reported:\n"+MyTaskListManager.getErrorMessages(),
- MyTaskListManager.getErrorMessages().isEmpty());
+ assertTrue("There should be no errors reported:\n"+getErrorMessages("PR133532_3"),
+ getErrorMessages("PR133532_3").isEmpty());
}
public void testPr134541() {
initialiseProject("PR134541");
build("PR134541");
assertEquals("[Xlint:adviceDidNotMatch] should be associated with line 5",5,
- ((IMessage)MyTaskListManager.getWarningMessages().get(0)).getSourceLocation().getLine());
+ ((IMessage)getWarningMessages("PR134541").get(0)).getSourceLocation().getLine());
alter("PR134541","inc1");
build("PR134541");
if (AsmManager.getDefault().getHandleProvider().dependsOnLocation())
else
checkWasntFullBuild(); // the line number has changed... but nothing structural about the code
assertEquals("[Xlint:adviceDidNotMatch] should now be associated with line 7",7,
- ((IMessage)MyTaskListManager.getWarningMessages().get(0)).getSourceLocation().getLine());
+ ((IMessage)getWarningMessages("PR134541").get(0)).getSourceLocation().getLine());
}
public void testJDTLikeHandleProviderWithLstFile_pr141730() {
IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider();
AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider());
- configureBuildStructureModel(true);
try {
// The JDTLike-handles should start with the name
// of the buildconfig file
build("JDTLikeHandleProvider");
IHierarchy top = AsmManager.getDefault().getHierarchy();
IProgramElement pe = top.findElementForType("pkg","A");
- String expectedHandle = "build<pkg*A.aj}A";
+ String expectedHandle = "JDTLikeHandleProvider<pkg*A.aj}A";
assertEquals("expected handle to be " + expectedHandle + ", but found "
+ pe.getHandleIdentifier(),expectedHandle,pe.getHandleIdentifier());
} finally {
AsmManager.getDefault().setHandleProvider(handleProvider);
- configureBuildStructureModel(false);
}
}
public void testMovingAdviceDoesntChangeHandles_pr141730() {
IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider();
AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider());
- configureBuildStructureModel(true);
try {
initialiseProject("JDTLikeHandleProvider");
build("JDTLikeHandleProvider");
pe.getHandleIdentifier(),pe2.getHandleIdentifier());
} finally {
AsmManager.getDefault().setHandleProvider(handleProvider);
- configureBuildStructureModel(false);
}
}
public void testSwappingAdviceAndHandles_pr141730() {
IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider();
AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider());
- configureBuildStructureModel(true);
try {
initialiseProject("JDTLikeHandleProvider");
build("JDTLikeHandleProvider");
exec.getHandleIdentifier(), newCall.getHandleIdentifier());
} finally {
AsmManager.getDefault().setHandleProvider(handleProvider);
- configureBuildStructureModel(false);
}
}
public void testInitializerCountForJDTLikeHandleProvider_pr141730() {
IElementHandleProvider handleProvider = AsmManager.getDefault().getHandleProvider();
AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider());
- configureBuildStructureModel(true);
try {
initialiseProject("JDTLikeHandleProvider");
build("JDTLikeHandleProvider");
- String expected = "build<pkg*A.aj[C|1";
+ String expected = "JDTLikeHandleProvider<pkg*A.aj[C|1";
IHierarchy top = AsmManager.getDefault().getHierarchy();
IProgramElement init = top.findElementForLabel(top.getRoot(),
} finally {
AsmManager.getDefault().setHandleProvider(handleProvider);
- configureBuildStructureModel(false);
}
}
public void testPr134471_IncrementalCompilationAndModelUpdates() {
try {
// see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
- configureBuildStructureModel(true);
- configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
// Step1. Build the code, simple advice from aspect A onto class C
initialiseProject("PR134471");
+ configureNonStandardCompileOptions("PR134471","-showWeaveInfo -emacssym");
+ configureShowWeaveInfoMessages("PR134471",true);
build("PR134471");
// Step2. Quick check that the advice points to something...
// now the advice moves down a few lines - hopefully the model will notice... see discussion in 134471
public void testPr134471_MovingAdvice() {
- configureBuildStructureModel(true);
- configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
// Step1. build the project
initialiseProject("PR134471_2");
+ configureNonStandardCompileOptions("PR134471_2","-showWeaveInfo -emacssym");
+ configureShowWeaveInfoMessages("PR134471_2",true);
build("PR134471_2");
// Step2. confirm advice is from correct location
public void testAddingAndRemovingDecwWithStructureModel() {
- configureBuildStructureModel(true);
initialiseProject("P3");
build("P3");
alter("P3","inc1");
build("P3");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
+ assertTrue("There should be no exceptions handled:\n"+getCompilerErrorMessages("P3"),
+ getCompilerErrorMessages("P3").isEmpty());
alter("P3","inc2");
build("P3");
- assertTrue("There should be no exceptions handled:\n"+MyErrorHandler.getErrorMessages(),
- MyErrorHandler.getErrorMessages().isEmpty());
- configureBuildStructureModel(false);
+ assertTrue("There should be no exceptions handled:\n"+getCompilerErrorMessages("P3"),
+ getCompilerErrorMessages("P3").isEmpty());
}
public void testPr134471_IncrementallyRecompilingTheAffectedClass() {
try {
// see pr148027 AsmHierarchyBuilder.shouldAddUsesPointcut=false;
- configureBuildStructureModel(true);
- configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
-
// Step1. build the project
initialiseProject("PR134471");
+ configureNonStandardCompileOptions("PR134471","-showWeaveInfo -emacssym");
+ configureShowWeaveInfoMessages("PR134471",true);
build("PR134471");
// Step2. confirm advice is from correct location
// similar to previous test but with 'declare warning' as well as advice
public void testPr134471_IncrementallyRecompilingAspectContainingDeclare() {
- configureBuildStructureModel(true);
- configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
// Step1. build the project
initialiseProject("PR134471_3");
+ configureNonStandardCompileOptions("PR134471_3","-showWeaveInfo -emacssym");
+ configureShowWeaveInfoMessages("PR134471_3",true);
build("PR134471_3");
checkWasFullBuild();
programElement = getFirstRelatedElement(findCode(checkForNode("pkg","C",true),7));
line = programElement.getSourceLocation().getLine();
assertTrue("declare warning should be at line 12 - but is at line "+line,line==12);
-
- configureBuildStructureModel(false);
}
// similar to previous test but with 'declare warning' as well as advice
public void testPr134471_IncrementallyRecompilingTheClassAffectedByDeclare() {
- configureBuildStructureModel(true);
- configureNonStandardCompileOptions("-showWeaveInfo -emacssym");
// Step1. build the project
initialiseProject("PR134471_3");
+ configureNonStandardCompileOptions("PR134471_3","-showWeaveInfo -emacssym");
+ configureShowWeaveInfoMessages("PR134471_3",true);
build("PR134471_3");
checkWasFullBuild();
programElement = getFirstRelatedElement(findCode(checkForNode("pkg","C",true),7));
line = programElement.getSourceLocation().getLine();
assertTrue("declare warning should be at line 12 - but is at line "+line,line==12);
-
- configureBuildStructureModel(false);
}
public void testDontLoseXlintWarnings_pr141556() {
- configureNonStandardCompileOptions("-Xlint:warning");
initialiseProject("PR141556");
+ configureNonStandardCompileOptions("PR141556","-Xlint:warning");
build("PR141556");
checkWasFullBuild();
String warningMessage = "can not build thisJoinPoint " +
"[Xlint:noGuardForLazyTjp]";
assertEquals("warning message should be '" + warningMessage + "'",
warningMessage,
- ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+ ((IMessage)getWarningMessages("PR141556").get(0))
.getMessage());
// add a space to the Aspect but dont do a build
build("PR141556");
checkWasntFullBuild();
assertTrue("there should still be a warning message ",
- !MyTaskListManager.getWarningMessages().isEmpty());
+ !getWarningMessages("PR141556").isEmpty());
assertEquals("warning message should be '" + warningMessage + "'",
warningMessage,
- ((IMessage)MyTaskListManager.getWarningMessages().get(0))
+ ((IMessage)getWarningMessages("PR141556").get(0))
.getMessage());
}
-
- public void testLintMessage_pr141564() {
- configureNonStandardCompileOptions("-Xlint:warning");
- initialiseProject("PR141556");
- build("PR141556");
- IMessageHandler handler = AjdeManager.getMessageHandler();
- // the handler used to be an IMessageHolder (extended MessageHandler)
- // which stored the messages, consequently we checked that none
- // were being stored. Since we no longer stored any messages (fix
- // for bug 141564) it was unnecessary to be an IMessageHolder as all the
- // IMessageHolder methods in MessageHander used the list of stored
- // messages. Therefore, rather than checking that the list of messages
- // is empty we can check that we're an IMessageHandler but not an
- // IMessageHolder.
- assertFalse("expected the handler not to be an IMessageHolder but was ",
- handler instanceof IMessageHolder);
-
- List tasklistMessages = MyTaskListManager.getWarningMessages();
- assertTrue("Should be one message but found "+tasklistMessages.size(),tasklistMessages.size()==1);
-
- IMessage msg = (IMessage)tasklistMessages.get(0);
- assertTrue("expected message to be a LintMessage but wasn't",
- msg instanceof LintMessage);
- assertTrue("expected message to be noGuardForLazyTjp xlint message but" +
- " instead was " + ((LintMessage)msg).getKind().toString(),
- ((LintMessage)msg).getLintKind().equals("noGuardForLazyTjp"));
-
- assertTrue("expected message to be against file in project 'PR141556' but wasn't",
- msg.getSourceLocation().getSourceFile().getAbsolutePath().indexOf("PR141556") != -1);
- }
public void testAdviceDidNotMatch_pr152589() {
initialiseProject("PR152589");
build("PR152589");
- List warnings = MyTaskListManager.getWarningMessages();
+ List warnings = getWarningMessages("PR152589");
assertTrue("There should be no warnings:\n"+warnings,
warnings.isEmpty());
alter("PR152589","inc1");
checkWasntFullBuild(); // the line number has changed... but nothing structural about the code
// checkWasFullBuild();
- warnings = MyTaskListManager.getWarningMessages();
+ warnings = getWarningMessages("PR152589");
assertTrue("There should be no warnings after adding a whitespace:\n"
+warnings,warnings.isEmpty());
}
AsmManager.getDefault().setHandleProvider(new JDTLikeHandleProvider());
initialiseProject("PR158573");
build("PR158573");
- List warnings = MyTaskListManager.getWarningMessages();
+ List warnings = getWarningMessages("PR158573");
assertTrue("There should be no warnings:\n"+warnings,warnings.isEmpty());
alter("PR158573","inc1");
build("PR158573");
checkWasntFullBuild();
- warnings = MyTaskListManager.getWarningMessages();
+ warnings = getWarningMessages("PR158573");
assertTrue("There should be no warnings after changing the value of a " +
"variable:\n"+warnings,warnings.isEmpty());
AsmManager.getDefault().setHandleProvider(handleProvider);
* java 6.
*/
public void testPR164384_1() {
+ initialiseProject("PR164384");
+
Hashtable javaOptions = new Hashtable();
javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.6");
javaOptions.put("org.eclipse.jdt.core.compiler.source","1.6");
- MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+ configureJavaOptionsMap("PR164384",javaOptions);
- initialiseProject("PR164384");
build("PR164384");
- List errors = MyTaskListManager.getErrorMessages();
+ List errors = getErrorMessages("PR164384");
- if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) {
assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
* 5.0 then expect an error saying that we don't support java 6.
*/
public void testPR164384_2() {
+ initialiseProject("PR164384");
+
Hashtable javaOptions = new Hashtable();
javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.5");
javaOptions.put("org.eclipse.jdt.core.compiler.source","1.5");
- MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+ configureJavaOptionsMap("PR164384",javaOptions);
- initialiseProject("PR164384");
build("PR164384");
- List errors = MyTaskListManager.getErrorMessages();
- if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ List errors = getErrorMessages("PR164384");
+ if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) {
assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
* java 6.
*/
public void testPR164384_3() {
+ initialiseProject("PR164384");
+
Hashtable javaOptions = new Hashtable();
javaOptions.put("org.eclipse.jdt.core.compiler.compliance","1.6");
javaOptions.put("org.eclipse.jdt.core.compiler.codegen.targetPlatform","1.6");
javaOptions.put("org.eclipse.jdt.core.compiler.source","1.5");
- MyBuildOptionsAdapter.setJavaOptionsMap(javaOptions);
+ configureJavaOptionsMap("PR164384",javaOptions);
- initialiseProject("PR164384");
build("PR164384");
- List errors = MyTaskListManager.getErrorMessages();
+ List errors = getErrorMessages("PR164384");
- if (Ajde.getDefault().compilerIsJava6Compatible()) {
+ if (getCompilerForProjectWithName("PR164384").isJava6Compatible()) {
assertTrue("There should be no errros:\n"+errors,errors.isEmpty());
} else {
String expectedError = "Java 6.0 compliance level is unsupported";
" error but only found that one",errors.size() > 1);
}
}
-
+
public void testPr168840() throws Exception {
initialiseProject("inpathTesting");
File f = new File(inpathDir);
Set s = new HashSet();
s.add(f);
- configureInPath(s);
+ configureInPath("inpathTesting",s);
build("inpathTesting");
// the declare warning matches one place so expect one warning message
+ List warnings = getWarningMessages("inpathTesting");
assertTrue("Expected there to be one warning message but found "
- + MyTaskListManager.getWarningMessages().size() + ": " + MyTaskListManager.getWarningMessages(),
- MyTaskListManager.getWarningMessages().size() == 1);
+ + warnings.size() + ": " + warnings, warnings.size() == 1);
// copy over the updated version of the inpath class file
File from = new File(testdataSrcDir+File.separatorChar+"inpathTesting"
checkWasntFullBuild();
// the newly copied inpath class means the declare warning now matches two
// places, therefore expect two warning messages
+ warnings = getWarningMessages("inpathTesting");
assertTrue("Expected there to be two warning message but found "
- + MyTaskListManager.getWarningMessages().size() + ": " + MyTaskListManager.getWarningMessages(),
- MyTaskListManager.getWarningMessages().size() == 2);
+ + warnings.size() + ": " + warnings, warnings.size() == 2);
}
// --- helper code ---
// ---------------------------------------------------------------------------------------------------
-
private IProgramElement checkForNode(String packageName,String typeName,boolean shouldBeFound) {
IProgramElement ipe = AsmManager.getDefault().getHierarchy().findElementForType(packageName,typeName);
if (shouldBeFound) {
private static void log(String msg) {
if (VERBOSE) System.out.println(msg);
}
-
+
private File getProjectRelativePath(String p,String filename) {
File projDir = new File(getWorkingDir(),p);
return new File(projDir,filename);
return new File(projDir,"bin"+File.separator+filename);
}
- private void assertNoErrors() {
- assertTrue("Should be no errors, but got "+MyTaskListManager.getErrorMessages(),MyTaskListManager.getErrorMessages().size()==0);
+ private void assertNoErrors(String projectName) {
+ assertTrue("Should be no errors, but got "+getErrorMessages(projectName),getErrorMessages(projectName).size()==0);
}
}
\ No newline at end of file
-/* *******************************************************************
- * Copyright (c) 2006 Contributors.
- * All rights reserved.
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved.
* This program and the accompanying materials are made available
* under the terms of the Eclipse Public License v1.0
* which accompanies this distribution and is available at
* http://eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Adrian Colyer initial implementation
-* ******************************************************************/
+ * Adrian Colyer initial implementation
+ * Helen Hawkins Converted to new interface (bug 148190)
+ *******************************************************************/
package org.aspectj.systemtest.incremental.tools;
import java.io.File;
import java.util.List;
import java.util.Map;
-import org.aspectj.ajde.OutputLocationManager;
+import org.aspectj.ajde.core.IOutputLocationManager;
/**
* Test the OutputLocationManager support used to enable multiple output folders.
super.setUp();
initialiseProject(PROJECT_NAME);
this.outputLocationManager = new MyOutputLocationManager(new File(getFile(PROJECT_NAME, "")));
- configureOutputLocationManager(this.outputLocationManager);
+ configureOutputLocationManager(PROJECT_NAME,this.outputLocationManager);
}
public void testDefaultOutputLocationUsedWhenNoOutputLocationManager() {
- configureOutputLocationManager(null);
+ configureOutputLocationManager(PROJECT_NAME,null);
build(PROJECT_NAME);
assertFileExists(PROJECT_NAME,"bin/a/A.class");
assertFileExists(PROJECT_NAME,"bin/b/B.class");
Map resourceMap = new HashMap();
resourceMap.put("resourceOne.txt", new File(getFile(PROJECT_NAME,"srcRootOne/resourceOne.txt")));
resourceMap.put("resourceTwo.txt", new File(getFile(PROJECT_NAME,"srcRootTwo/resourceTwo.txt")));
- configureResourceMap(resourceMap);
+ configureResourceMap(PROJECT_NAME,resourceMap);
build(PROJECT_NAME);
assertFileExists(PROJECT_NAME,"target/main/classes/resourceOne.txt");
assertFileExists(PROJECT_NAME,"target/test/classes/resourceTwo.txt");
}
public void testGeneratedClassesPlacedInAppropriateOutputFolder() {
- configureNonStandardCompileOptions("-XnoInline");
+ configureNonStandardCompileOptions(PROJECT_NAME,"-XnoInline");
build(PROJECT_NAME);
assertFileExists(PROJECT_NAME,"target/main/classes/a/A.class");
assertFileExists(PROJECT_NAME,"target/main/classes/a/A$AjcClosure1.class");
}
-
+
/**
* Tests the case when we have two aspects, each of which are
* sent to a different output location. There should be an
* aop.xml file in each of the two output directories.
*/
public void testOutXmlForAspectsWithDifferentOutputDirs() {
- configureNonStandardCompileOptions("-outxml");
+ configureNonStandardCompileOptions(PROJECT_NAME,"-outxml");
build(PROJECT_NAME);
assertFileExists(PROJECT_NAME,"target/main/classes/META-INF/aop-ajc.xml");
assertFileExists(PROJECT_NAME,"target/test/classes/META-INF/aop-ajc.xml");
checkXMLAspectCount(PROJECT_NAME,"c.C$AnAspect",1,getFile(PROJECT_NAME,"target/anotherTest/classes"));
}
-
protected void assertFileExists(String project, String relativePath) {
assertTrue("file " + relativePath + " should have been created as a result of building " + project,
new File(getFile(project, relativePath)).exists());
}
- private static class MyOutputLocationManager implements OutputLocationManager {
+ private static class MyOutputLocationManager implements IOutputLocationManager {
private File projectHome;
private List allOutputDirs;