aboutsummaryrefslogtreecommitdiffstats
path: root/ajde
diff options
context:
space:
mode:
authoraclement <aclement>2007-01-15 08:44:45 +0000
committeraclement <aclement>2007-01-15 08:44:45 +0000
commit4f5615f0e9f56d9078faf5dd89330897298755c1 (patch)
tree321c6f7a1d44ab03cc0fded741bd0fd2a7746f4f /ajde
parenta010542247f01c64386cef5a0ad3f8e502f0f306 (diff)
downloadaspectj-4f5615f0e9f56d9078faf5dd89330897298755c1.tar.gz
aspectj-4f5615f0e9f56d9078faf5dd89330897298755c1.zip
148190#32
Diffstat (limited to 'ajde')
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeModuleTests.java7
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java174
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AjdeTests.java53
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java210
-rw-r--r--ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java197
-rw-r--r--ajde/testsrc/org/aspectj/ajde/BuildCancellingTest.java405
-rw-r--r--ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java626
-rw-r--r--ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java159
-rw-r--r--ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java85
-rw-r--r--ajde/testsrc/org/aspectj/ajde/DuplicateManifestTest.java72
-rw-r--r--ajde/testsrc/org/aspectj/ajde/GenericsTest.java33
-rw-r--r--ajde/testsrc/org/aspectj/ajde/InpathTestcase.java472
-rw-r--r--ajde/testsrc/org/aspectj/ajde/JarManifestTest.java86
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java68
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java61
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java29
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeManager.java91
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java45
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java169
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java109
-rw-r--r--ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java27
-rw-r--r--ajde/testsrc/org/aspectj/ajde/OutxmlTest.java146
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java289
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java427
-rw-r--r--ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java113
-rw-r--r--ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java424
-rw-r--r--ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java32
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java117
-rw-r--r--ajde/testsrc/org/aspectj/ajde/StructureModelTest.java177
-rw-r--r--ajde/testsrc/org/aspectj/ajde/TestBuildListener.java45
-rw-r--r--ajde/testsrc/org/aspectj/ajde/VersionTest.java48
31 files changed, 139 insertions, 4857 deletions
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeModuleTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeModuleTests.java
index 6a243c62b..b6a1daa55 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeModuleTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeModuleTests.java
@@ -1,4 +1,3 @@
-package org.aspectj.ajde;
/* *******************************************************************
* Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
@@ -11,9 +10,7 @@ package org.aspectj.ajde;
* Contributors:
* Xerox/PARC initial implementation
* ******************************************************************/
-
-
-// default package
+package org.aspectj.ajde;
import junit.framework.*;
@@ -22,8 +19,6 @@ public class AjdeModuleTests extends TestCase {
public static TestSuite suite() {
TestSuite suite = new TestSuite(AjdeModuleTests.class.getName());
suite.addTest(org.aspectj.ajde.AjdeTests.suite());
- suite.addTest(org.aspectj.ajde.internal.AjdeInternalTests.suite());
- suite.addTest(org.aspectj.ajde.ui.AjdeUiTests.suite());
return suite;
}
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
index 60073f400..b6d9cf02c 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTestCase.java
@@ -1,77 +1,153 @@
-/* *******************************************************************
+/********************************************************************
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
* 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://www.eclipse.org/legal/epl-v10.html
+ * http://eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
+ * Xerox/PARC initial implementation
+ * Helen Hawkins Converted to new interface (bug 148190) and
+ * to use a sandbox directory
+ *******************************************************************/
package org.aspectj.ajde;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
-import org.aspectj.asm.AsmManager;
+import javax.swing.JFrame;
+import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
-public class AjdeTestCase extends TestCase {
-
-// private static final String TEST_DATA_PATH = AjdeTests.testDataPath(null);
+import org.aspectj.ajde.Ajde;
+import org.aspectj.ajde.IconRegistry;
+import org.aspectj.ajde.core.AjCompiler;
+import org.aspectj.ajde.ui.utils.TestBuildProgressMonitor;
+import org.aspectj.ajde.ui.utils.TestCompilerConfiguration;
+import org.aspectj.ajde.ui.utils.TestEditorAdapter;
+import org.aspectj.ajde.ui.utils.TestIdeUIAdapter;
+import org.aspectj.ajde.ui.utils.TestMessageHandler;
+import org.aspectj.ajde.ui.utils.TestRuntimeProperties;
+import org.aspectj.asm.AsmManager;
+import org.aspectj.tools.ajc.Ajc;
- protected NullIdeManager ideManager = NullIdeManager.getIdeManager();
- protected TestBuildListener testerBuildListener = new TestBuildListener();
- protected String currTestDataPath;
+public class AjdeTestCase extends TestCase {
- public AjdeTestCase() {
- super("");
- }
+ public final static String testdataSrcDir = "../ajde/testdata";
+ protected static File sandboxDir;
- public AjdeTestCase(String name) {
- super(name);
- }
- public void testEmptyAddedForAntJUnit() {}
-
- protected File openFile(String path) {
- return new File(currTestDataPath + File.separatorChar + path);
- }
-
- /**
- * Waits on the build complete.
- */
- protected boolean doSynchronousBuild(String configFilePath) {
- testerBuildListener.reset();
- File configFile = openFile(configFilePath);
- Ajde.getDefault().getBuildManager().build(configFile.getAbsolutePath());
- while(!testerBuildListener.getBuildFinished()) {
- try {
- Thread.sleep(300);
- } catch (InterruptedException ie) { }
- }
- return testerBuildListener.getBuildSucceeded();
- }
-
- protected void setUp(String testDataPath) throws Exception {
- currTestDataPath = AjdeTests.testDataPath(testDataPath);
+ private String projectDir;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // Create a sandbox in which to work
+ sandboxDir = Ajc.createEmptySandbox();
// AMC - added this next line as a temporary workaround for
// listener leakage in AsmManager induced by the Ajde test suite.
AsmManager.getDefault().removeAllListeners();
- ideManager.init(currTestDataPath);
- super.setUp();
- assertTrue(NullIdeManager.getIdeManager().isInitialized());
- Ajde.getDefault().getBuildManager().addListener(testerBuildListener);
}
-
+
protected void tearDown() throws Exception {
super.tearDown();
+ projectDir = null;
+ sandboxDir = null;
+ }
+
+ /**
+ * Fill in the working directory with the project files and
+ * creates a compiler instance for this project
+ */
+ public void initialiseProject(String projectName) {
+
+ // need to initialize via AjdeUIManager
+ Ajde.getDefault().init(
+ new TestCompilerConfiguration(projectName),
+ new TestMessageHandler(),
+ new TestBuildProgressMonitor(),
+ new TestEditorAdapter(),
+ new TestIdeUIAdapter(),
+ new IconRegistry(),
+ new JFrame(),
+ new TestRuntimeProperties(),
+ true);
+
+ File projectSrc=new File(testdataSrcDir + File.separatorChar + projectName);
+ File destination=new File(getWorkingDir(),projectName);
+ if (!destination.exists()) {destination.mkdir();}
+ copy(projectSrc,destination);
+ projectDir = destination.getAbsolutePath();
+
+// compiler = new AjCompiler(
+// projectDir,
+// new TestCompilerConfiguration(projectDir),
+// new TestBuildProgressMonitor(),
+// new TestMessageHandler());
+ }
+
+ /**
+ * @return the working directory
+ */
+ protected File getWorkingDir() {
+ return sandboxDir;
+ }
+
+ /**
+ * @return the absolute path of the project directory
+ * for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject
+ */
+ protected String getAbsoluteProjectDir() {
+ return projectDir;
+ }
+
+ /**
+ * Copy the contents of some directory to another location - the
+ * copy is recursive.
+ */
+ private void copy(File from, File to) {
+ String contents[] = from.list();
+ if (contents==null) return;
+ for (int i = 0; i < contents.length; i++) {
+ String string = contents[i];
+ File f = new File(from,string);
+ File t = new File(to,string);
+
+ if (f.isDirectory()) {
+ t.mkdir();
+ copy(f,t);
+ } else if (f.isFile()) {
+ try {
+ org.aspectj.util.FileUtil.copyFile(f,t);
+ } catch (IOException e) {
+ throw new AssertionFailedError("Unable to copy " + f + " to " + t);
+ }
+ }
+ }
+ }
+
+ protected File openFile(String path) {
+ return new File(projectDir + File.separatorChar + path);
+ }
+
+ public void doBuild(String configFile) {
+ getCompilerForConfigFileWithName(configFile).build();
+ }
+
+ public AjCompiler getCompilerForConfigFileWithName(String configFileName) {
+ return Ajde.getDefault().getCompilerForConfigFile(projectDir + File.separator + configFileName);
}
+ public List getErrorMessages(String configFileName) {
+ return ((TestMessageHandler)getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getErrors();
+ }
+
+ public List getMessages(String configFileName) {
+ return ((TestMessageHandler)getCompilerForConfigFileWithName(configFileName).getMessageHandler()).getMessages();
+ }
+
protected String genStructureModelExternFilePath(String configFilePath) {
return configFilePath.substring(0, configFilePath.lastIndexOf(".lst")) + ".ajsym";
}
-
}
diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
index 2c3fcc045..c48b9d2fe 100644
--- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
+++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java
@@ -9,58 +9,31 @@
*
* Contributors:
* Xerox/PARC initial implementation
+ * Helen Hawkins updated for bug 148190
* ******************************************************************/
-
-
package org.aspectj.ajde;
-import java.io.File;
-
-import org.aspectj.util.FileUtil;
+import org.aspectj.ajde.internal.AspectJBuildManagerTest;
+import org.aspectj.ajde.internal.LstBuildConfigManagerTest;
+import org.aspectj.ajde.ui.StructureSearchManagerTest;
+import org.aspectj.ajde.ui.StructureViewManagerTest;
-import junit.framework.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
public class AjdeTests extends TestCase {
- // TODO-path
- private static final File TESTDATA_PATH;
- static {
- String[] paths = { "../ajde/testdata" };
- TESTDATA_PATH = FileUtil.getBestFile(paths);
- }
- public static String testDataPath(String file) {
- if (null == file) {
- return TESTDATA_PATH.getPath();
- }
- File f = new File(TESTDATA_PATH, file);
- f = FileUtil.getBestFile(f);
- return (null == f ? "" : f.getPath());
- }
-
public static Test suite() {
TestSuite suite = new TestSuite(AjdeTests.class.getName());
//$JUnit-BEGIN$
suite.addTestSuite(SymbolFileGenerationTest.class);
- suite.addTestSuite(ShowWeaveMessagesTestCase.class);
- suite.addTestSuite(DuplicateManifestTest.class);
- suite.addTestSuite(BuildOptionsTest.class);
- suite.addTestSuite(BuildConfigurationTests.class);
- suite.addTestSuite(StructureModelRegressionTest.class);
- suite.addTestSuite(StructureModelTest.class);
- suite.addTestSuite(VersionTest.class);
- suite.addTestSuite(CompilerMessagesTest.class);
- suite.addTestSuite(AsmDeclarationsTest.class);
- suite.addTestSuite(AsmRelationshipsTest.class);
- suite.addTestSuite(InpathTestcase.class);
- suite.addTestSuite(ReweavableTestCase.class);
- suite.addTestSuite(ResourceCopyTestCase.class);
- suite.addTestSuite(ModelPerformanceTest.class);
- suite.addTestSuite(SavedModelConsistencyTest. class);
- suite.addTestSuite(BuildCancellingTest.class);
- suite.addTestSuite(JarManifestTest.class);
suite.addTestSuite(ExtensionTests.class);
- suite.addTestSuite(GenericsTest.class);
- suite.addTestSuite(OutxmlTest.class);
+ suite.addTestSuite(AspectJBuildManagerTest.class);
+ suite.addTestSuite(LstBuildConfigManagerTest.class);
+ suite.addTestSuite(StructureSearchManagerTest.class);
+ suite.addTestSuite(StructureViewManagerTest.class);
+ suite.addTestSuite(AjdeCompilerTests.class);
//$JUnit-END$
return suite;
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
deleted file mode 100644
index bc44c6ebe..000000000
--- a/ajde/testsrc/org/aspectj/ajde/AsmDeclarationsTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import org.aspectj.asm.*;
-
-/**
- * @author Mik Kersten
- */
-public class AsmDeclarationsTest extends AjdeTestCase {
-
- private IHierarchy model = null;
- // TODO-path
- private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
-
- public AsmDeclarationsTest(String name) {
- super(name);
- }
-
- public void testRoot() {
- IProgramElement root = (IProgramElement)model.getRoot();
- assertNotNull(root);
- assertEquals(root.toLabelString(), "coverage.lst");
- }
-
- public void testAspectAccessibility() {
- IProgramElement packageAspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
- assertNotNull(packageAspect);
- assertEquals(IProgramElement.Accessibility.PACKAGE, packageAspect.getAccessibility());
- assertEquals("aspect should not have public in it's signature","aspect AdviceNamingCoverage",packageAspect.getSourceSignature());
- }
-
- public void testStaticModifiers() {
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "ModifiersCoverage");
- assertNotNull(aspect);
-
- IProgramElement staticA = model.findElementForSignature(aspect, IProgramElement.Kind.FIELD, "staticA");
- assertTrue(staticA.getModifiers().contains(IProgramElement.Modifiers.STATIC));
-
- IProgramElement finalA = model.findElementForSignature(aspect, IProgramElement.Kind.FIELD, "finalA");
- assertTrue(!finalA.getModifiers().contains(IProgramElement.Modifiers.STATIC));
- assertTrue(finalA.getModifiers().contains(IProgramElement.Modifiers.FINAL));
-
- }
-
- public void testFileInPackageAndDefaultPackage() {
- IProgramElement root = model.getRoot();
- assertEquals(root.toLabelString(), "coverage.lst");
- IProgramElement pkg = (IProgramElement)root.getChildren().get(1);
- assertEquals(pkg.toLabelString(), "pkg");
- assertEquals(((IProgramElement)pkg.getChildren().get(0)).toLabelString(), "InPackage.java");
- assertEquals(((IProgramElement)root.getChildren().get(0)).toLabelString(), "ModelCoverage.java");
- }
-
- public void testDeclares() {
- IProgramElement node = (IProgramElement)model.getRoot();
- assertNotNull(node);
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "DeclareCoverage");
- assertNotNull(aspect);
-
- String label = "declare error: \"Illegal construct..\"";
- IProgramElement decErrNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_ERROR, "declare error");
- assertNotNull(decErrNode);
- assertEquals(decErrNode.toLabelString(), label);
-
- String decWarnMessage = "declare warning: \"Illegal call.\"";
- IProgramElement decWarnNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_WARNING, "declare warning");
- assertNotNull(decWarnNode);
- assertEquals(decWarnNode.toLabelString(), decWarnMessage);
-
- String decParentsMessage = "declare parents: implements Serializable";
- IProgramElement decParentsNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PARENTS, "declare parents");
- assertNotNull(decParentsNode);
- assertEquals(decParentsNode.toLabelString(), decParentsMessage);
- // check the next two relative to this one
- int declareIndex = decParentsNode.getParent().getChildren().indexOf(decParentsNode);
- String decParentsPtnMessage = "declare parents: extends Observable";
- assertEquals(decParentsPtnMessage,((IProgramElement)aspect.getChildren().get(declareIndex+1)).toLabelString());
- String decParentsTPMessage = "declare parents: extends Observable";
- assertEquals(decParentsTPMessage,((IProgramElement)aspect.getChildren().get(declareIndex+2)).toLabelString());
-
- String decSoftMessage = "declare soft: SizeException";
- IProgramElement decSoftNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_SOFT, "declare soft");
- assertNotNull(decSoftNode);
- assertEquals(decSoftNode.toLabelString(), decSoftMessage);
-
- String decPrecMessage = "declare precedence: AdviceCoverage, InterTypeDecCoverage, <type pattern>";
- IProgramElement decPrecNode = model.findElementForSignature(aspect, IProgramElement.Kind.DECLARE_PRECEDENCE, "declare precedence");
- assertNotNull(decPrecNode);
- assertEquals(decPrecNode.toLabelString(), decPrecMessage);
- }
-
- public void testInterTypeMemberDeclares() {
- IProgramElement node = (IProgramElement)model.getRoot();
- assertNotNull(node);
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "InterTypeDecCoverage");
- assertNotNull(aspect);
-
- String fieldMsg = "Point.xxx";
- IProgramElement fieldNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_FIELD, fieldMsg);
- assertNotNull(fieldNode);
- assertEquals(fieldNode.toLabelString(), fieldMsg);
-
- String methodMsg = "Point.check(int,Line)";
- IProgramElement methodNode = model.findElementForLabel(aspect, IProgramElement.Kind.INTER_TYPE_METHOD, methodMsg);
- assertNotNull(methodNode);
- assertEquals(methodNode.toLabelString(), methodMsg);
-
- // TODO: enable
-// String constructorMsg = "Point.new(int, int, int)";
-// ProgramElementNode constructorNode = model.findNode(aspect, ProgramElementNode.Kind.INTER_TYPE_CONSTRUCTOR, constructorMsg);
-// assertNotNull(constructorNode);
-// assertEquals(constructorNode.toLabelString(), constructorMsg);
- }
-
- public void testPointcuts() {
- IProgramElement node = (IProgramElement)model.getRoot();
- assertNotNull(node);
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
- assertNotNull(aspect);
-
- String ptct = "named()";
- IProgramElement ptctNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, ptct);
- assertNotNull(ptctNode);
- assertEquals(ptctNode.toLabelString(), ptct);
-
- String params = "namedWithArgs(int,int)";
- IProgramElement paramsNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, params);
- assertNotNull(paramsNode);
- assertEquals(paramsNode.toLabelString(), params);
- }
-
- public void testAbstract() {
- IProgramElement node = (IProgramElement)model.getRoot();
- assertNotNull(node);
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AbstractAspect");
- assertNotNull(aspect);
-
- String abst = "abPtct()";
- IProgramElement abstNode = model.findElementForSignature(aspect, IProgramElement.Kind.POINTCUT, abst);
- assertNotNull(abstNode);
- assertEquals(abstNode.toLabelString(), abst);
- }
-
- public void testAdvice() {
- IProgramElement node = (IProgramElement)model.getRoot();
- assertNotNull(node);
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage");
- assertNotNull(aspect);
-
- String anon = "before(): <anonymous pointcut>";
- IProgramElement anonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, anon);
- assertNotNull(anonNode);
- assertEquals(anonNode.toLabelString(), anon);
-
- String named = "before(): named..";
- IProgramElement namedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, named);
- assertNotNull(namedNode);
- assertEquals(namedNode.toLabelString(), named);
-
- String namedWithOneArg = "around(int): namedWithOneArg..";
- IProgramElement namedWithOneArgNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, namedWithOneArg);
- assertNotNull(namedWithOneArgNode);
- assertEquals(namedWithOneArgNode.toLabelString(), namedWithOneArg);
-
- String afterReturning = "afterReturning(int,int): namedWithArgs..";
- IProgramElement afterReturningNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, afterReturning);
- assertNotNull(afterReturningNode);
- assertEquals(afterReturningNode.toLabelString(), afterReturning);
-
- String around = "around(int): namedWithOneArg..";
- IProgramElement aroundNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, around);
- assertNotNull(aroundNode);
- assertEquals(aroundNode.toLabelString(), around);
-
- String compAnon = "before(int): <anonymous pointcut>..";
- IProgramElement compAnonNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compAnon);
- assertNotNull(compAnonNode);
- assertEquals(compAnonNode.toLabelString(), compAnon);
-
- String compNamed = "before(int): named()..";
- IProgramElement compNamedNode = model.findElementForLabel(aspect, IProgramElement.Kind.ADVICE, compNamed);
- assertNotNull(compNamedNode);
- assertEquals(compNamedNode.toLabelString(), compNamed);
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
- model = AsmManager.getDefault().getHierarchy();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java b/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
deleted file mode 100644
index cb32415ed..000000000
--- a/ajde/testsrc/org/aspectj/ajde/AsmRelationshipsTest.java
+++ /dev/null
@@ -1,197 +0,0 @@
-
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder;
-import org.aspectj.asm.AsmManager;
-import org.aspectj.asm.IProgramElement;
-import org.aspectj.asm.IRelationship;
-
-/**
- * @author Mik Kersten
- */
-public class AsmRelationshipsTest extends AjdeTestCase {
-
- private AsmManager manager = null;
- // TODO-path
- private static final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
-
- public AsmRelationshipsTest(String name) {
- super(name);
- }
-
- // see pr148027
- public void testUsesPointcut() {
- if (!AsmHierarchyBuilder.shouldAddUsesPointcut) return;
-
- IProgramElement ptUsage = AsmManager.getDefault().getHierarchy().findElementForType(null, "PointcutUsage");
- assertNotNull(ptUsage);
- IProgramElement pts = AsmManager.getDefault().getHierarchy().findElementForType(null, "Pointcuts");
- assertNotNull(pts);
-
- IProgramElement pUsesA = manager.getHierarchy().findElementForLabel(
- ptUsage,
- IProgramElement.Kind.POINTCUT,
- "usesA()"/*Point"*/);
- assertNotNull(pUsesA);
-
- IProgramElement ptsA = manager.getHierarchy().findElementForLabel(
- pts,
- IProgramElement.Kind.POINTCUT,
- "a()"/*Point"*/);
- assertNotNull(ptsA);
-
- assertTrue(AsmManager.getDefault().getRelationshipMap().get(pUsesA).size()>0);
- assertTrue(AsmManager.getDefault().getRelationshipMap().get(ptsA).size()>0);
- }
-
- public void testDeclareParents() {
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "DeclareCoverage");
-
- IProgramElement dp = manager.getHierarchy().findElementForLabel(
- aspect,
- IProgramElement.Kind.DECLARE_PARENTS,
- "declare parents: implements Serializable"/*Point"*/);
-
- assertNotNull(dp);
- /*List relations = */manager.getRelationshipMap().get(dp);
-
- List rels = AsmManager.getDefault().getRelationshipMap().get(dp);
- assertTrue(rels.size()>0);
-
-// assertTrue(rel.getTargets().size() > 0);
-//
-// checkDeclareMapping("DeclareCoverage", "Point", ,
-// "Point", "matched by", "matches declare",
-// IProgramElement.Kind.DECLARE_PARENTS);
- }
-
- public void testDeclareWarningAndError() {
- checkDeclareMapping("DeclareCoverage", "Point", "declare warning: \"Illegal call.\"",
- "method-call(void Point.setX(int))", "matched by", "matches declare", IProgramElement.Kind.DECLARE_WARNING);
- }
-
- public void testInterTypeDeclarations() {
- checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.xxx", "Point",
- "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_FIELD);
- checkInterTypeMapping("InterTypeDecCoverage", "Point", "Point.check(int,Line)",
- "Point", "declared on", "aspect declarations", IProgramElement.Kind.INTER_TYPE_METHOD);
- }
-
- public void testAdvice() {
- checkMapping("AdvisesRelationshipCoverage", "Point", "before(): methodExecutionP..",
- "setX(int)", "advises", "advised by");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): getP..",
- "field-get(int Point.x)", "advises");
- checkUniDirectionalMapping("AdvisesRelationshipCoverage", "Point", "before(): setP..",
- "field-set(int Point.x)", "advises");
- }
-
- private void checkDeclareMapping(String fromType, String toType, String from, String to,
- String forwardRelName, String backRelName, IProgramElement.Kind kind) {
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
- assertNotNull(aspect);
- String beforeExec = from;
- IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, kind, beforeExec);
- assertNotNull(beforeExecNode);
- IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.DECLARE, forwardRelName);
- assertTrue(rel.getTargets().size() > 0);
- String handle = (String)rel.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
-
- IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
- assertNotNull(clazz);
- String set = to;
- IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.CODE, set);
- assertNotNull(setNode);
- IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.DECLARE, backRelName);
- String handle2 = (String)rel2.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
- }
-
- private void checkUniDirectionalMapping(String fromType, String toType, String from,
- String to, String relName) {
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
- assertNotNull(aspect);
- String beforeExec = from;
- IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
- assertNotNull(beforeExecNode);
- IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, relName);
- for (Iterator it = rel.getTargets().iterator(); it.hasNext(); ) {
- String currHandle = (String)it.next();
- if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(to)) return;
- }
- fail(); // didn't find it
- }
-
- private void checkMapping(String fromType, String toType, String from, String to,
- String forwardRelName, String backRelName) {
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
- assertNotNull(aspect);
- String beforeExec = from;
- IProgramElement beforeExecNode = manager.getHierarchy().findElementForLabel(aspect, IProgramElement.Kind.ADVICE, beforeExec);
- assertNotNull(beforeExecNode);
- IRelationship rel = manager.getRelationshipMap().get(beforeExecNode, IRelationship.Kind.ADVICE, forwardRelName);
- String handle = (String)rel.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
-
- IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
- assertNotNull(clazz);
- String set = to;
- IProgramElement setNode = manager.getHierarchy().findElementForLabel(clazz, IProgramElement.Kind.METHOD, set);
- assertNotNull(setNode);
- IRelationship rel2 = manager.getRelationshipMap().get(setNode, IRelationship.Kind.ADVICE, backRelName);
- String handle2 = (String)rel2.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle2).toString(), from);
- }
-
- private void checkInterTypeMapping(String fromType, String toType, String from,
- String to, String forwardRelName, String backRelName, IProgramElement.Kind declareKind) {
-
- IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, fromType);
- assertNotNull(aspect);
- String beforeExec = from;
- IProgramElement fromNode = manager.getHierarchy().findElementForLabel(aspect, declareKind, beforeExec);
- assertNotNull(fromNode);
- IRelationship rel = manager.getRelationshipMap().get(fromNode, IRelationship.Kind.DECLARE_INTER_TYPE, forwardRelName);
- String handle = (String)rel.getTargets().get(0);
- assertEquals(manager.getHierarchy().findElementForHandle(handle).toString(), to);
-
- IProgramElement clazz = AsmManager.getDefault().getHierarchy().findElementForType(null, toType);
- assertNotNull(clazz);
-// String set = to;
- IRelationship rel2 = manager.getRelationshipMap().get(clazz, IRelationship.Kind.DECLARE_INTER_TYPE, backRelName);
-// String handle2 = (String)rel2.getTargets().get(0);
- for (Iterator it = rel2.getTargets().iterator(); it.hasNext(); ) {
- String currHandle = (String)it.next();
- if (manager.getHierarchy().findElementForHandle(currHandle).toLabelString().equals(from)) return;
- }
- fail(); // didn't find it
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
- manager = AsmManager.getDefault();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/BuildCancellingTest.java b/ajde/testsrc/org/aspectj/ajde/BuildCancellingTest.java
deleted file mode 100644
index 3d4937de6..000000000
--- a/ajde/testsrc/org/aspectj/ajde/BuildCancellingTest.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement Initial version
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.aspectj.ajde.internal.CompilerAdapter;
-import org.aspectj.util.FileUtil;
-
-/**
- * It is now possible to cancel the compiler during either the
- * compilation or weaving phases - this testcase verifies a few
- * cases, making sure the process stops when expected. It can
- * check the disk contents, but it doesn't right now.
- *
- * Two different .lst files are used during these tests: LoadsaCode.lst and
- * EvenMoreCode.lst which contain mixes of aspects and classes
- *
- * Here are some things to think about that will help you understand what is
- * on the disk when we cancel the compiler.
- *
- * There are 3 important phases worth remembering :
- * - Compile all the types
- * - Weave all the aspects
- * - Weave all the classes
- *
- * Each of those steps goes through all the types. This
- * means during the 'weave all the aspects' step we are
- * jumping over classes and during the 'weave all the
- * classes ' step we are jumping over aspects. Why is this important?
- *
- *
- * We only write bytes out during the 'weave all the classes ' phase and it is even
- * during that phase that we write out the bytes for aspects. This means if you cancel
- * during compilation or during the weaving of aspects - there will be nothing on the
- * disk. If you cancel whilst in the 'weave all the classes ' phase then the disk
- * will contain anything finished with by the cancellation point.
- */
-public class BuildCancellingTest extends AjdeTestCase {
-
- private CompilerAdapter compilerAdapter;
- public static final String PROJECT_DIR = "BuildCancelling";
- public static final String binDir = "bin";
- private static final boolean debugTests = false;
-
- public BuildCancellingTest(String arg0) {
- super(arg0);
- }
-
- // Ensure the output directory is clean
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
-
-
- /**
- * After first compilation message, get it to cancel, there should be one more warning
- * message about cancelling the compile and their should be nothing on the disk.
- */
- public void testCancelFirstCompile() {
- if (debugTests) System.out.println("\n\n\ntestCancelFirstCompile: Building with LoadsaCode.lst");
- compilerAdapter = new CompilerAdapter();
- BuildProgMon programmableBPM = new BuildProgMon();
-
- programmableBPM.cancelOn("compiled:",1); // Force a cancel after the first compile occurs
-
- compilerAdapter.compile(
- (String) openFile("LoadsaCode.lst").getAbsolutePath(),
- programmableBPM,
- false);
-
- assertTrue("Should have cancelled after first compile?:"+programmableBPM.numCompiledMessages,
- programmableBPM.numCompiledMessages==1);
-
-// Comment out to check the disk contents
-// assertTrue("As weaving was cancelled, no files should have been written out, but I found:"+wovenClassesFound(),
-// wovenClassesFound()==0);
-
- boolean expectedCancelMessageFound = checkFor("Compilation cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about compilation being cancelled!", expectedCancelMessageFound);
- }
-
-
-
- /**
- * After third compilation message, get it to cancel, there should be one more warning
- * message about cancelling the compile and their should be nothing on the disk.
- */
- public void testCancelThirdCompile() {
- if (debugTests) System.out.println("\n\n\ntestCancelThirdCompile: Building with LoadsaCode.lst");
- compilerAdapter = new CompilerAdapter();
- BuildProgMon programmableBPM = new BuildProgMon();
-
- programmableBPM.cancelOn("compiled:",3); // Force a cancel after the third compile occurs
-
- compilerAdapter.compile(
- (String) openFile("LoadsaCode.lst").getAbsolutePath(),
- programmableBPM,
- false);
-
- assertTrue("Should have cancelled after third compile?:"+programmableBPM.numCompiledMessages,
- programmableBPM.numCompiledMessages==3);
-
-// Comment out to check the disk contents
-// assertTrue("As weaving was cancelled, no files should have been written out, but I found:"+wovenClassesFound(),
-// wovenClassesFound()==0);
-
- boolean expectedCancelMessageFound = checkFor("Compilation cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about compilation being cancelled!", expectedCancelMessageFound);
- }
-
-
- /**
- * After first weave aspect message, get it to cancel, there should be one more warning
- * message about cancelling the weave and their should be nothing on the disk.
- */
- public void testCancelFirstAspectWeave() {
- if (debugTests) System.out.println("\n\n\ntestCancelFirstAspectWeave: Building with LoadsaCode.lst");
- compilerAdapter = new CompilerAdapter();
- BuildProgMon programmableBPM = new BuildProgMon();
-
- programmableBPM.cancelOn("woven aspect ",1); // Force a cancel after the first weave aspect occurs
-
- compilerAdapter.compile((String) openFile("LoadsaCode.lst").getAbsolutePath(),programmableBPM,false);
-
- assertTrue("Should have cancelled after first aspect weave?:"+programmableBPM.numWovenAspectMessages,
- programmableBPM.numWovenAspectMessages==1);
-
-// Comment out to check the disk contents
-// assertTrue("As weaving was cancelled, no files should have been written out?:"+wovenClassesFound(),
-// wovenClassesFound()==0);
-
- boolean expectedCancelMessageFound = checkFor("Weaving cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about weaving being cancelled!", expectedCancelMessageFound);
- }
-
-
-
- /**
- * After third weave aspect message, get it to cancel, there should be one more warning
- * message about cancelling the weave and their should be nothing on the disk.
- */
- public void testCancelThirdAspectWeave() {
- if (debugTests) System.out.println("\n\n\ntestCancelThirdAspectWeave: Building with LoadsaCode.lst");
- compilerAdapter = new CompilerAdapter();
-
- BuildProgMon programmableBPM = new BuildProgMon();
- // Force a cancel after the third weave occurs.
- // This should leave two class files on disk - I think?
- programmableBPM.cancelOn("woven aspect ",3);
-
- compilerAdapter.compile(
- (String) openFile("LoadsaCode.lst").getAbsolutePath(),
- programmableBPM,
- false);
-
- assertTrue("Should have cancelled after third weave?:"+programmableBPM.numWovenAspectMessages,
- programmableBPM.numWovenAspectMessages==3);
-
-// Comment out to check disk contents
-// assertTrue("As weaving was cancelled, no files should have been written out?:"+wovenClassesFound(),
-// wovenClassesFound()==0);
-
- boolean expectedCancelMessageFound = checkFor("Weaving cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about weaving being cancelled!", expectedCancelMessageFound);
-
- }
-
- /**
- * After first weave class message, get it to cancel, there should be one more
- * warning message about cancelling the weave and their should be nothing on the
- * disk.
- *
- * EvenMoreCode.lst contains:
- * A1.aj
- * Cl1.java
- * A2.aj
- * Cl2.java
- * HW.java
- * A3.aj
- * Cl3.java
- * A4.aj
- *
- */
- public void testCancelFirstClassWeave() {
- if (debugTests) System.out.println("testCancelFirstClassWeave: Building with EvenMoreCode.lst");
- compilerAdapter = new CompilerAdapter();
- BuildProgMon programmableBPM = new BuildProgMon();
-
- programmableBPM.cancelOn("woven class",1);
-
- compilerAdapter.compile(
- (String) openFile("EvenMoreCode.lst").getAbsolutePath(),
- programmableBPM,
- false);
-
-// Should just be A1 on the disk - uncomment this line to verify that! (and uncomment diskContents())
-// assertTrue("Incorrect disk contents found",diskContents("A1"));
-
- assertTrue("Should have cancelled after first class weave?:"+programmableBPM.numWovenClassMessages,
- programmableBPM.numWovenClassMessages==1);
-
- boolean expectedCancelMessageFound = checkFor("Weaving cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about weaving being cancelled!", expectedCancelMessageFound);
- }
-
-
- /**
- * After first weave aspect message, get it to cancel, there should be one more
- * warning message about cancelling the weave and their should be nothing on the
- * disk.
- *
- * EvenMoreCode.lst contains:
- * A1.aj
- * Cl1.java
- * A2.aj
- * Cl2.java
- * HW.java
- * A3.aj
- * Cl3.java
- * A4.aj
- *
- */
- public void testCancelSecondClassWeave() {
- if (debugTests) System.out.println("testCancelSecondClassWeave: Building with EvenMoreCode.lst");
- compilerAdapter = new CompilerAdapter();
- BuildProgMon programmableBPM = new BuildProgMon();
-
- programmableBPM.cancelOn("woven class",2);
-
- compilerAdapter.compile(
- (String) openFile("EvenMoreCode.lst").getAbsolutePath(),
- programmableBPM,
- false);
-
-// Uncomment this line to verify disk contents(and uncomment diskContents())
-// assertTrue("Incorrect disk contents found",diskContents("A1 Cl1 A2"));
-
- assertTrue("Should have cancelled after first class weave?:"+programmableBPM.numWovenClassMessages,
- programmableBPM.numWovenClassMessages==2);
-
- boolean expectedCancelMessageFound = checkFor("Weaving cancelled as requested");
- if (!expectedCancelMessageFound) dumpTaskData(); // Useful for debugging
- assertTrue("Failed to get warning message about weaving being cancelled!", expectedCancelMessageFound);
-
- }
-
-
- // ----
- // Helper classes and methods
-
-
- private class BuildProgMon implements BuildProgressMonitor {
-
- public int numWovenClassMessages = 0;
- public int numWovenAspectMessages = 0;
- public int numCompiledMessages = 0;
-
- private String programmableString;
- private int count;
- private List messagesReceived = new ArrayList();
- private int currentVal;
-
- public void start(String configFile) {
- currentVal = 0;
- }
-
- public void cancelOn(String string,int count) {
- programmableString = string;
- this.count = count;
- }
-
- public void setProgressText(String text) {
- String newText = text+" [Percentage="+currentVal+"%]";
- messagesReceived.add(newText);
- if (text.startsWith("woven aspect ")) numWovenAspectMessages++;
- if (text.startsWith("woven class ")) numWovenClassMessages++;
- if (text.startsWith("compiled:")) numCompiledMessages++;
- if (programmableString != null
- && text.indexOf(programmableString) != -1) {
- count--;
- if (count==0) {
- if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel");
- compilerAdapter.requestCompileExit();
- programmableString = null;
- }
- }
- }
-
- public boolean containsMessage(String prefix,String distinguishingMarks) {
- for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- if (element.startsWith(prefix) &&
- element.indexOf(distinguishingMarks)!=-1) return true;
- }
- return false;
- }
-
- public void dumpMessages() {
- System.out.println("ProgressMonitorMessages");
- for (Iterator iter = messagesReceived.iterator(); iter.hasNext();) {
- String element = (String) iter.next();
- System.out.println(element);
- }
- }
-
- public void setProgressBarVal(int newVal) {
- this.currentVal = newVal;
- }
-
- public void incrementProgressBarVal() {
- System.err.println("ipbv");
- }
-
- public void setProgressBarMax(int maxVal) {
- System.err.println("spbm"+maxVal);
- }
-
- public int getProgressBarMax() {
- return 100; // Causes setProgressBarVal() to be fed what are effectively percentages
- }
-
- public void finish(boolean b) {
- }
-
- }
-
-// private boolean diskContents(String shouldExist) {
-// String[] fullList = new String[] { "A1","A2","A3","A4","Cl1","Cl2","Cl3","HW"};
-// boolean isOK = true;
-// for (int i = 0; i < fullList.length; i++) {
-// String file = fullList[i];
-// if (shouldExist.indexOf(file)!=-1) {
-// // There should be a class file called this
-// if (!openFile("bin/"+file+".class").exists()) {
-// isOK=false;
-// System.out.println("Couldn't find this expected file: "+file+".class");
-// }
-// } else {
-// // There should NOT be a class file called this
-// if (openFile("bin/"+file+".class").exists()) {
-// isOK=false;
-// System.out.println("Found this file when not expected: "+file+".class");
-// }
-// }
-// }
-// return isOK;
-// }
-//
-// private int wovenClassesFound() {
-// int found = 0;
-// File fA1 = openFile("bin/A1.class");
-// File fA2 = openFile("bin/A2.class");
-// File fA3 = openFile("bin/A3.class");
-// File fA4 = openFile("bin/A4.class");
-// File fHW = openFile("bin/HW.class");
-//
-// found+=(fA1.exists()?1:0);
-// found+=(fA2.exists()?1:0);
-// found+=(fA3.exists()?1:0);
-// found+=(fA4.exists()?1:0);
-// found+=(fHW.exists()?1:0);
-// return found;
-// }
-
-
- private boolean checkFor(String what) {
- List ll = ideManager.getCompilationSourceLineTasks();
- for (Iterator iter = ll.iterator(); iter.hasNext();) {
- Object element = (Object) iter.next();
- if (element.toString().indexOf(what) != -1)
- return true;
- }
- return false;
- }
-
- private void dumpTaskData() {
- if (!debugTests) return;
- List ll = ideManager.getCompilationSourceLineTasks();
- for (Iterator iter = ll.iterator(); iter.hasNext();) {
- Object element = (Object) iter.next();
- System.out.println("RecordedMessage>"+element);
- }
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java b/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java
deleted file mode 100644
index fc5eb96f1..000000000
--- a/ajde/testsrc/org/aspectj/ajde/BuildConfigurationTests.java
+++ /dev/null
@@ -1,626 +0,0 @@
-/**********************************************************************
-Copyright (c) 2003 IBM Corporation and others.
-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://www.eclipse.org/legal/epl-v10.html
-Contributors:
-Adrian Colyer - initial version
-...
-**********************************************************************/
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestSuite;
-
-import org.aspectj.ajde.NullIdeTaskListManager.SourceLineTask;
-import org.aspectj.ajde.internal.CompilerAdapter;
-import org.aspectj.ajde.ui.UserPreferencesAdapter;
-import org.aspectj.ajde.ui.internal.AjcBuildOptions;
-import org.aspectj.ajde.ui.internal.UserPreferencesStore;
-import org.aspectj.ajdt.internal.core.builder.AjBuildConfig;
-import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
-import org.aspectj.util.LangUtil;
-
-/**
- * Tests that a correctly populated AjBuildConfig object is created
- * in reponse to the setting in BuildOptionsAdapter and
- * ProjectPropretiesAdapter
- */
-public class BuildConfigurationTests extends AjdeTestCase {
-
- private CompilerAdapter compilerAdapter;
- private AjBuildConfig buildConfig = null;
- private AjcBuildOptions buildOptions = null;
- private UserPreferencesAdapter preferencesAdapter = null;
- private NullIdeProperties projectProperties = null;
- private NullIdeTaskListManager taskListManager;
- private static final String configFile =
- AjdeTests.testDataPath("examples/figures-coverage/all.lst");
-
-
- public BuildConfigurationTests( String name ) {
- super( name );
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(BuildConfigurationTests.class);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(BuildConfigurationTests.class);
- return result;
- }
-
-
- // The tests...
- public void testCharacterEncoding() {
- buildOptions.setCharacterEncoding( "UTF-8" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String encoding = (String) options.get( CompilerOptions.OPTION_Encoding );
- assertEquals( "character encoding", "UTF-8", encoding );
- }
-
- public void testComplianceLevelJava13() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance);
- assertEquals( "source level", CompilerOptions.VERSION_1_3, sourceLevel );
- }
-
- public void testComplianceLevelJava14() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance);
- assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel );
- }
-
- public void testCompilanceLevelJava6() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_16 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
-
- if (Ajde.getDefault().compilerIsJava6Compatible()) {
- assertEquals("expected compliance level to be 1.6 but found " + compliance, "1.6", compliance);
- assertEquals("expected source level to be 1.6 but found " + sourceLevel, "1.6", sourceLevel );
- assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
- } else {
- List l = taskListManager.getSourceLineTasks();
- String expectedError = "Java 6.0 compliance level is unsupported";
- String found = ((SourceLineTask)l.get(0)).getContainedMessage().getMessage();
- assertEquals("Expected 'Java 6.0 compliance level is unsupported'" +
- " error message but found " + found ,expectedError,found);
- }
- }
-
- public void testSourceCompatibilityLevelJava6() {
- buildOptions.setSourceCompatibilityLevel(BuildOptionsAdapter.VERSION_16 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
-
- if (Ajde.getDefault().compilerIsJava6Compatible()) {
- assertEquals("expected compliance level to be 1.6 but found " + compliance, "1.6", compliance);
- assertEquals("expected source level to be 1.6 but found " + sourceLevel, "1.6", sourceLevel );
- assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
- } else {
- List l = taskListManager.getSourceLineTasks();
- String expectedError = "Java 6.0 source level is unsupported";
- String found = ((SourceLineTask)l.get(0)).getContainedMessage().getMessage();
- assertEquals("Expected 'Java 6.0 compliance level is unsupported'" +
- " error message but found " + found ,expectedError,found);
- }
- }
-
- public void testCompilanceLevelJava5() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
- assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
- assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
- }
-
- public void testSourceCompatibilityLevel() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_13);
- buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14);
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals( "compliance level", CompilerOptions.VERSION_1_3, compliance);
- assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel );
- }
-
- public void testSourceIncompatibilityLevel() {
- // this config should "fail" and leave source level at 1.4
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14);
- buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_13);
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals( "compliance level", CompilerOptions.VERSION_1_4, compliance);
- assertEquals( "source level", CompilerOptions.VERSION_1_4, sourceLevel );
- }
-
- public void testSourceCompatibilityLevelJava5() {
- buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_15);
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
- assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
- assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
- }
-
- public void testSourceIncompatibilityLevelJava5() {
- // because compliance is set to be 1.5 then source compatibility
- // will be set to 1.5
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_15);
- buildOptions.setSourceCompatibilityLevel( BuildOptionsAdapter.VERSION_14);
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String compliance = (String) options.get(CompilerOptions.OPTION_Compliance);
- String sourceLevel = (String) options.get(CompilerOptions.OPTION_Source);
- assertEquals("expected compliance level to be 1.5 but found " + compliance, CompilerOptions.VERSION_1_5, compliance);
- assertEquals("expected source level to be 1.5 but found " + sourceLevel, CompilerOptions.VERSION_1_5, sourceLevel );
- assertTrue("expected to 'behaveInJava5Way' but aren't",buildConfig.getBehaveInJava5Way());
- }
-
- public void testNullWarnings() {
- buildOptions.setWarnings( null );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with the default warnings
- assertOptionEquals( "report overriding package default",
- options,
- CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
- CompilerOptions.WARNING);
- assertOptionEquals( "report method with cons name",
- options,
- CompilerOptions.OPTION_ReportMethodWithConstructorName,
- CompilerOptions.WARNING);
- assertOptionEquals( "report deprecation",
- options,
- CompilerOptions.OPTION_ReportDeprecation,
- CompilerOptions.WARNING);
- assertOptionEquals( "report hidden catch block",
- options,
- CompilerOptions.OPTION_ReportHiddenCatchBlock,
- CompilerOptions.WARNING);
- assertOptionEquals( "report unused local",
- options,
- CompilerOptions.OPTION_ReportUnusedLocal,
- CompilerOptions.IGNORE);
- assertOptionEquals( "report unused param",
- options,
- CompilerOptions.OPTION_ReportUnusedParameter,
- CompilerOptions.IGNORE);
- assertOptionEquals( "report synthectic access",
- options,
- CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
- CompilerOptions.IGNORE);
- assertOptionEquals( "report non-externalized string literal",
- options,
- CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
- CompilerOptions.IGNORE);
- assertOptionEquals( "report assert identifer",
- options,
- CompilerOptions.OPTION_ReportAssertIdentifier,
- CompilerOptions.WARNING);
- }
-
-// public void testEmptyWarnings() {
-// buildOptions.setWarnings( new HashSet() );
-// buildConfig = compilerAdapter.genBuildConfig( configFile );
-// Map options = buildConfig.getJavaOptions();
-//
-// // this should leave us with the user specifiable warnings
-// // turned off
-// assertOptionEquals( "report overriding package default",
-// options,
-// CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report method with cons name",
-// options,
-// CompilerOptions.OPTION_ReportMethodWithConstructorName,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report deprecation",
-// options,
-// CompilerOptions.OPTION_ReportDeprecation,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report hidden catch block",
-// options,
-// CompilerOptions.OPTION_ReportHiddenCatchBlock,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report unused local",
-// options,
-// CompilerOptions.OPTION_ReportUnusedLocal,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report unused param",
-// options,
-// CompilerOptions.OPTION_ReportUnusedParameter,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report synthectic access",
-// options,
-// CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report non-externalized string literal",
-// options,
-// CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
-// CompilerOptions.WARNING);
-// assertOptionEquals( "report assert identifer",
-// options,
-// CompilerOptions.OPTION_ReportAssertIdentifier,
-// CompilerOptions.WARNING);
-// }
-
- public void testSetOfWarnings() {
- HashSet warnings = new HashSet();
- warnings.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER );
- warnings.add( BuildOptionsAdapter.WARN_CONSTRUCTOR_NAME );
- warnings.add( BuildOptionsAdapter.WARN_DEPRECATION );
- warnings.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS );
- warnings.add( BuildOptionsAdapter.WARN_PACKAGE_DEFAULT_METHOD );
- warnings.add( BuildOptionsAdapter.WARN_SYNTHETIC_ACCESS );
- warnings.add( BuildOptionsAdapter.WARN_UNUSED_ARGUMENTS );
- warnings.add( BuildOptionsAdapter.WARN_UNUSED_IMPORTS );
- warnings.add( BuildOptionsAdapter.WARN_UNUSED_LOCALS );
- warnings.add( BuildOptionsAdapter.WARN_NLS );
-
- buildOptions.setWarnings( warnings );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with all the user specifiable warnings
- // turned on
- assertOptionEquals( "report overriding package default",
- options,
- CompilerOptions.OPTION_ReportOverridingPackageDefaultMethod,
- CompilerOptions.WARNING);
- assertOptionEquals( "report method with cons name",
- options,
- CompilerOptions.OPTION_ReportMethodWithConstructorName,
- CompilerOptions.WARNING);
- assertOptionEquals( "report deprecation",
- options,
- CompilerOptions.OPTION_ReportDeprecation,
- CompilerOptions.WARNING);
- assertOptionEquals( "report hidden catch block",
- options,
- CompilerOptions.OPTION_ReportHiddenCatchBlock,
- CompilerOptions.WARNING);
- assertOptionEquals( "report unused local",
- options,
- CompilerOptions.OPTION_ReportUnusedLocal,
- CompilerOptions.WARNING);
- assertOptionEquals( "report unused param",
- options,
- CompilerOptions.OPTION_ReportUnusedParameter,
- CompilerOptions.WARNING);
- assertOptionEquals( "report synthectic access",
- options,
- CompilerOptions.OPTION_ReportSyntheticAccessEmulation,
- CompilerOptions.WARNING);
- assertOptionEquals( "report non-externalized string literal",
- options,
- CompilerOptions.OPTION_ReportNonExternalizedStringLiteral,
- CompilerOptions.WARNING);
- assertOptionEquals( "report assert identifer",
- options,
- CompilerOptions.OPTION_ReportAssertIdentifier,
- CompilerOptions.WARNING);
- }
-
- public void testNoDebugOptions() {
- buildOptions.setDebugLevel( null );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with the default debug settings
- assertOptionEquals( "debug source",
- options,
- CompilerOptions.OPTION_SourceFileAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug lines",
- options,
- CompilerOptions.OPTION_LineNumberAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug vars",
- options,
- CompilerOptions.OPTION_LocalVariableAttribute,
- CompilerOptions.GENERATE);
- }
-
- public void testEmptyDebugOptions() {
- buildOptions.setDebugLevel( new HashSet() );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with the default debug
- assertOptionEquals( "debug source",
- options,
- CompilerOptions.OPTION_SourceFileAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug lines",
- options,
- CompilerOptions.OPTION_LineNumberAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug vars",
- options,
- CompilerOptions.OPTION_LocalVariableAttribute,
- CompilerOptions.GENERATE);
- }
-
- public void testDebugAll() {
- HashSet debugOpts = new HashSet();
- debugOpts.add( BuildOptionsAdapter.DEBUG_ALL );
- buildOptions.setDebugLevel( debugOpts );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with all debug on
- assertOptionEquals( "debug source",
- options,
- CompilerOptions.OPTION_SourceFileAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug lines",
- options,
- CompilerOptions.OPTION_LineNumberAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug vars",
- options,
- CompilerOptions.OPTION_LocalVariableAttribute,
- CompilerOptions.GENERATE);
-
- }
-
- public void testDebugSet() {
- HashSet debugOpts = new HashSet();
- debugOpts.add( BuildOptionsAdapter.DEBUG_SOURCE );
- debugOpts.add( BuildOptionsAdapter.DEBUG_VARS );
- buildOptions.setDebugLevel( debugOpts );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
-
- // this should leave us with all debug on
- assertOptionEquals( "debug source",
- options,
- CompilerOptions.OPTION_SourceFileAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug lines",
- options,
- CompilerOptions.OPTION_LineNumberAttribute,
- CompilerOptions.GENERATE);
- assertOptionEquals( "debug vars",
- options,
- CompilerOptions.OPTION_LocalVariableAttribute,
- CompilerOptions.GENERATE);
- }
-
- public void testNoImport() {
- buildOptions.setNoImportError( true );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
-// Map options = buildConfig.getJavaOptions();
-// String noImport = (String) options.get( CompilerOptions.OPTION_ReportInvalidImport );
-// assertEquals( "no import", CompilerOptions.WARNING, noImport );
-// buildOptions.setNoImportError( false );
- }
-
- public void testPreserveAllLocals() {
- buildOptions.setPreserveAllLocals( true );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- Map options = buildConfig.getOptions().getMap();
- String preserve = (String) options.get( CompilerOptions.OPTION_PreserveUnusedLocal );
- assertEquals( "preserve unused", CompilerOptions.PRESERVE, preserve );
- }
-
- public void testNonStandardOptions() {
- buildOptions.setNonStandardOptions( "-XterminateAfterCompilation" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- assertTrue( "XterminateAfterCompilation", buildConfig.isTerminateAfterCompilation() );
- buildOptions.setNonStandardOptions( "-XserializableAspects" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() );
- buildOptions.setNonStandardOptions( "-XnoInline" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue( "XnoInline", buildConfig.isXnoInline());
- buildOptions.setNonStandardOptions( "-Xlint" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT,
- buildConfig.getLintMode());
- buildOptions.setNonStandardOptions( "-Xlint:error" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertEquals( "Xlint", AjBuildConfig.AJLINT_ERROR,
- buildConfig.getLintMode());
-
- // XXX test for lintfile
-// buildOptions.setNonStandardOptions( "-Xlintfile testdata/AspectJBuildManagerTest/lint.properties" );
-// buildConfig = compilerAdapter.genBuildConfig( configFile );
-// assertEquals( "Xlintfile", new File( "testdata/AspectJBuildManagerTest/lint.properties" ).getAbsolutePath(),
-// buildConfig.getLintSpecFile().toString());
- // and a few options thrown in at once
- buildOptions.setNonStandardOptions( "-Xlint -XnoInline -XserializableAspects" );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- assertEquals( "Xlint", AjBuildConfig.AJLINT_DEFAULT,
- buildConfig.getLintMode());
- assertTrue( "XnoInline", buildConfig.isXnoInline());
- assertTrue( "XserializableAspects", buildConfig.isXserializableAspects() );
- }
-
- public void testSourceRoots() {
- Set roots = new HashSet();
- projectProperties.setSourceRoots( roots );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List configRoots = buildConfig.getSourceRoots();
- assertTrue( "no source dirs", configRoots.isEmpty() );
-
- File f = new File( AjdeTests.testDataPath("examples/figures/figures-coverage" ));
- roots.add( f );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List configRoots2 = buildConfig.getSourceRoots();
- assertTrue( "one source dir", configRoots2.size() == 1 );
- assertTrue( "source dir", configRoots2.contains(f) );
-
-
- File f2 = new File( AjdeTests.testDataPath("examples/figures/figures-demo"));
- roots.add( f2 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List configRoots3 = buildConfig.getSourceRoots();
- assertTrue( "two source dirs", configRoots3.size() == 2 );
- assertTrue( "source dir 1", configRoots3.contains(f) );
- assertTrue( "source dir 2", configRoots3.contains(f2) );
- }
-
- public void testInJars() {
- Set jars = new HashSet();
- projectProperties.setInJars( jars );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List inJars = buildConfig.getInJars();
- assertTrue( "no in jars", inJars.isEmpty() );
-
- File f = new File( "jarone.jar" );
- jars.add( f );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List inJars2 = buildConfig.getInJars();
- assertTrue( "one in jar", inJars2.size() == 1 );
- assertTrue( "in jar", inJars2.contains(f) );
-
-
- File f2 = new File( "jartwo.jar" );
- jars.add( f2 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- List inJars3 = buildConfig.getInJars();
- assertTrue( "two in jars", inJars3.size() == 2 );
- assertTrue( "in jar 1", inJars3.contains(f) );
- assertTrue( "in jar 2", inJars3.contains(f2) );
- }
-
- public void testAspectPath() {
- Set aspects = new HashSet();
- projectProperties.setAspectPath( aspects );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List aPath = buildConfig.getAspectpath();
- assertTrue( "no aspect path", aPath.isEmpty() );
-
- File f = new File( "jarone.jar" );
- aspects.add( f );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List aPath2 = buildConfig.getAspectpath();
- assertEquals("aspectpath", 1, aPath2.size());
- assertTrue( "1 aspectpath", aPath2.contains(f) );
-
-
- File f2 = new File( "jartwo.jar" );
- aspects.add( f2 );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- List aPath3 = buildConfig.getAspectpath();
- assertTrue( "two jars in path", aPath3.size() == 2 );
- assertTrue( "1 aspectpath", aPath3.contains(f) );
- assertTrue( "2 aspectpath", aPath3.contains(f2) );
- }
-
- public void testOutJar() {
- String outJar = "mybuild.jar";
- projectProperties.setOutJar( outJar );
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- assertNotNull("output jar", buildConfig.getOutputJar());
- assertEquals( "out jar", outJar, buildConfig.getOutputJar().toString() );
- }
-
- public void testXHasMember() {
- buildOptions.setNonStandardOptions("-XhasMember");
- buildConfig = compilerAdapter.genBuildConfig( configFile );
- assertTrue(configFile + " failed", null != buildConfig);
- assertTrue( "XhasMember", buildConfig.isXHasMemberEnabled() );
- }
-
- protected void setUp() throws Exception {
- preferencesAdapter = new UserPreferencesStore(false);
- buildOptions = new AjcBuildOptions(preferencesAdapter);
- compilerAdapter = new CompilerAdapter();
- projectProperties = new NullIdeProperties( "" );
- taskListManager = new NullIdeTaskListManager();
- ErrorHandler handler = new NullIdeErrorHandler();
- try {
- Ajde.init(
- null,
- taskListManager,
- null,
- projectProperties,
- buildOptions,
- null,
- null,
- handler);
- } catch (Throwable t) {
- String s = "Unable to initialize AJDE "
- + LangUtil.renderException(t);
- assertTrue(s, false);
- }
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- preferencesAdapter = null;
- buildOptions = null;
- compilerAdapter = null;
- projectProperties = null;
- taskListManager = null;
- }
-
- private void assertOptionEquals( String reason, Map options, String optionName, String value) {
- String mapValue = (String) options.get(optionName);
- assertEquals( reason, value, mapValue );
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java b/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java
deleted file mode 100644
index 579912d5c..000000000
--- a/ajde/testsrc/org/aspectj/ajde/BuildOptionsTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * AMC 01.21.2003 extended to cover new AspectJ1.1 options
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import junit.framework.TestSuite;
-
-import org.aspectj.ajde.ui.UserPreferencesAdapter;
-import org.aspectj.ajde.ui.internal.AjcBuildOptions;
-import org.aspectj.ajde.ui.internal.UserPreferencesStore;
-
-public class BuildOptionsTest extends AjdeTestCase {
-
- private AjcBuildOptions buildOptions = null;
- private UserPreferencesAdapter preferencesAdapter = null;
-
- public BuildOptionsTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(BuildOptionsTest.class);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(BuildOptionsTest.class);
- return result;
- }
-
- public void testCharacterEncoding() {
- buildOptions.setCharacterEncoding("mumble");
- assertTrue("character encoding", buildOptions.getCharacterEncoding().equals("mumble"));
- }
-
-// public void testPortingMode() {
-// buildOptions.setPortingMode(true);
-// assertTrue("porting mode", buildOptions.getPortingMode());
-// }
-
- public void testVerboseMode() {
- buildOptions.setVerboseMode(true);
- assertTrue("verbose mode", buildOptions.getVerboseMode());
- }
-
- public void testNonStandardOptions() {
- buildOptions.setNonStandardOptions( "-Xlint" );
- assertEquals( "non std options", "-Xlint",
- buildOptions.getNonStandardOptions());
- }
-
- public void testComplianceLevel() {
- buildOptions.setComplianceLevel( BuildOptionsAdapter.VERSION_14 );
- assertEquals( "compliance level",
- BuildOptionsAdapter.VERSION_14,
- buildOptions.getComplianceLevel());
- }
-
- public void testSourceCompatibilityLevel() {
- buildOptions.setSourceCompatibilityLevel(BuildOptionsAdapter.VERSION_13);
- assertEquals( "source level",
- BuildOptionsAdapter.VERSION_13,
- buildOptions.getSourceCompatibilityLevel());
- }
-
- public void testWarnings() {
- buildOptions.setWarnings( null );
- assertNull( "null warning set", buildOptions.getWarnings());
- HashSet s = new HashSet();
- buildOptions.setWarnings( s );
- Set s2 = buildOptions.getWarnings();
- assertTrue( "empty warning set", s2.isEmpty() );
- s.add( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER );
- s.add( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS );
- buildOptions.setWarnings( s );
- s2 = buildOptions.getWarnings();
- assertTrue( "two warnings", s2.size() == 2 );
- boolean warn_assert_found = false;
- boolean warn_catch_found = false;
- Iterator it = s2.iterator();
- while (it.hasNext()) {
- String option = (String) it.next();
- if ( option.equals( BuildOptionsAdapter.WARN_ASSERT_IDENITIFIER ) ) {
- warn_assert_found = true;
- }
- if ( option.equals( BuildOptionsAdapter.WARN_MASKED_CATCH_BLOCKS ) ) {
- warn_catch_found = true;
- }
- }
- assertTrue( "assert warning found", warn_assert_found );
- assertTrue( "catch waning found", warn_catch_found );
- }
-
- public void testDebugLevel() {
- buildOptions.setDebugLevel( null );
- assertNull( "null debug set", buildOptions.getDebugLevel());
- HashSet s = new HashSet();
- buildOptions.setDebugLevel( s );
- Set s2 = buildOptions.getDebugLevel();
- assertTrue( "empty debug set", s2.isEmpty() );
- s.add( BuildOptionsAdapter.DEBUG_LINES );
- s.add( BuildOptionsAdapter.DEBUG_SOURCE );
- buildOptions.setDebugLevel( s );
- s2 = buildOptions.getDebugLevel();
- assertTrue( "two warnings", s2.size() == 2 );
- boolean debug_lines_found = false;
- boolean debug_source_found = false;
- Iterator it = s2.iterator();
- while (it.hasNext()) {
- String option = (String) it.next();
- if ( option.equals( BuildOptionsAdapter.DEBUG_LINES ) ) {
- debug_lines_found = true;
- }
- if ( option.equals( BuildOptionsAdapter.DEBUG_SOURCE ) ) {
- debug_source_found = true;
- }
- }
- assertTrue( "debug lines found", debug_lines_found );
- assertTrue( "debug source found", debug_source_found );
- }
-
- public void testNoImportError() {
- buildOptions.setNoImportError(true);
- assertTrue("no import error", buildOptions.getNoImportError());
- }
-
- public void testPreserveLocals() {
- buildOptions.setPreserveAllLocals(true);
- assertTrue("preserve all locals", buildOptions.getPreserveAllLocals());
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- preferencesAdapter = new UserPreferencesStore(false);
- buildOptions = new AjcBuildOptions(preferencesAdapter);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- buildOptions.setCharacterEncoding("");
-// buildOptions.setPortingMode(true);
- }
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java b/ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java
deleted file mode 100644
index 15c42545e..000000000
--- a/ajde/testsrc/org/aspectj/ajde/CompilerMessagesTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * AMC 2003 initial version
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.IOException;
-import java.util.List;
-
-//import org.aspectj.bridge.*;
-import org.aspectj.bridge.IMessage;
-
-/**
- * @author colyer
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class CompilerMessagesTest extends AjdeTestCase {
-
- // TODO-path
- private final String CONFIG_FILE_PATH = "../examples/declare-warning/all.lst";
-
- public CompilerMessagesTest(String name) {
- super(name);
- }
-
- public void testMessages() {
- // bug 33474
- // The build has happened, what messages did the compiler give, and do they
- // contain the information we expect?
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- if (2 != msgs.size()) {
- assertTrue("not two messages: " + msgs, false);
- }
- assertEquals("Two warning messages should be produced",2,msgs.size());
- NullIdeTaskListManager.SourceLineTask task =
- (NullIdeTaskListManager.SourceLineTask) msgs.get(0);
- assertEquals( 8, task.getContainedMessage().getSourceLocation().getLine());
- assertEquals( "Please don't call init methods", task.message.getMessage());
- try {
- String fullyQualifiedFile = task.getContainedMessage().getSourceLocation().getSourceFile().getCanonicalPath();
- // this name has a tester specific prefix, followed by the location of the file.
- // we can validate the ending.
- fullyQualifiedFile = fullyQualifiedFile.replace('\\','/'); // ignore platform differences in slashes
- assertTrue( "Fully-qualified source file location returned",
- fullyQualifiedFile.endsWith("/examples/declare-warning/apackage/SomeClass.java"));
- } catch (IOException ex) {
- assertTrue( "Unable to convert source file location: " + task.getContainedMessage().getSourceLocation().getSourceFile(), false);
- }
- }
-
-
- public void testDeclareMessageContents() {
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- IMessage msg = (IMessage)((NullIdeTaskListManager.SourceLineTask)msgs.get(1)).getContainedMessage();
- assertEquals( "Please don't call setters" , msg.getMessage());
- assertEquals("field-set(int apackage.SomeClass.x)", msg.getDetails());
- }
-
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp("examples");
- doSynchronousBuild(CONFIG_FILE_PATH);
- }
-
- /*
- * @see AjdeTestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/DuplicateManifestTest.java b/ajde/testsrc/org/aspectj/ajde/DuplicateManifestTest.java
deleted file mode 100644
index 620ccf081..000000000
--- a/ajde/testsrc/org/aspectj/ajde/DuplicateManifestTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster - initial implementation
- *******************************************************************************/
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-
-public class DuplicateManifestTest extends AjdeTestCase {
-
-
- public static final String PROJECT_DIR = "DuplicateManifestTest";
-
- public static final String injarName = "injar.jar";
- public static final String aspectjarName = "aspectjar.jar";
- public static final String outjarName = "outjar.jar";
-
-
- /*
- * Ensure the output directpry in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- }
-
- public void testWeave () {
- Set injars = new HashSet();
- injars.add(openFile(injarName));
- ideManager.getProjectProperties().setInJars(injars);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile(aspectjarName));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed", doSynchronousBuild("build.lst"));
- assertTrue(
- "Build warnings",
- ideManager.getCompilationSourceLineTasks().isEmpty());
- compareManifests(openFile(injarName),openFile(outjarName));
- outjar.delete(); // Tidy up !
- File rogueSymFile = new File(currTestDataPath + File.separatorChar + "build.ajsym");
- if (rogueSymFile.exists()) rogueSymFile.delete();
- }
-
- private void compareManifests (File inFile, File outFile) {
-
- try {
- JarFile inJar = new JarFile(inFile);
- Manifest inManifest = inJar.getManifest();
- inJar.close();
- JarFile outJar = new JarFile(outFile);
- Manifest outManifest = outJar.getManifest();
- outJar.close();
- assertTrue("The manifests in '" + inFile.getCanonicalPath() + "' and '" + outFile.getCanonicalPath() + "' sould be the same",inManifest.equals(outManifest));
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/GenericsTest.java b/ajde/testsrc/org/aspectj/ajde/GenericsTest.java
deleted file mode 100644
index df3006044..000000000
--- a/ajde/testsrc/org/aspectj/ajde/GenericsTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten - initial implementation
- *******************************************************************************/
-package org.aspectj.ajde;
-
-//import org.aspectj.asm.AsmManager;
-
-/**
- * @author Mik Kersten
- */
-public class GenericsTest extends AjdeTestCase {
-
- //private AsmManager manager = null;
- // TODO-path
- //private static final String CONFIG_FILE_PATH = "../bug-83565/build.lst";
-
- public void testBuild() {
-// assertTrue("build success", doSynchronousBuild(CONFIG_FILE_PATH));
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- //manager = AsmManager.getDefault();
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/InpathTestcase.java b/ajde/testsrc/org/aspectj/ajde/InpathTestcase.java
deleted file mode 100644
index b5a736253..000000000
--- a/ajde/testsrc/org/aspectj/ajde/InpathTestcase.java
+++ /dev/null
@@ -1,472 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * Andy Clement Copied/changed for -inpath testing
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.*;
-import java.util.*;
-import java.util.jar.JarInputStream;
-import java.util.zip.*;
-
-import org.aspectj.util.FileUtil;
-
-/**
- * @author websterm
- */
-public class InpathTestcase extends AjdeTestCase {
-
- public static final String PROJECT_DIR = "InpathTest";
- public static final String binDir = "bin";
-
- public static final String indir1Name = "indir1";
- public static final String indir2Name = "indir2";
- public static final String injarName = "injar.jar";
- public static final String outjarName = "/bin/output.jar";
-
- /**
- * Constructor for JarResourceCopyTestCase.
- * @param arg0
- */
- public InpathTestcase(String arg0) {
- super(arg0);
- }
-
-
-
- /*
- * Ensure the output directpry in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
-
-
- /**
- * Inputs to the compiler:
- * inpath = 'indir1/'
- * source = 'src'
- * output = a jar file
- *
- * Expected result = output jar file contains contents of indir1 and
- * class file for source that was in src
- */
- public void testInpathToOutjar() {
- Set inpath = new HashSet();
- File indir1 = openFile(indir1Name);
- inpath.add(indir1);
- ideManager.getProjectProperties().setInpath(inpath);
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed", doSynchronousBuild("build.lst"));
- assertTrue("Build warnings", ideManager.getCompilationSourceLineTasks().isEmpty());
-
- Set expectedOutputJarContents = new HashSet();
- // From indir1
-// If we don't copy resources, these next three files won't make it.
-// expectedOutputJarContents.add("META-INF/MANIFEST.MF");
-// expectedOutputJarContents.add("META-INF/test.xml");
-// expectedOutputJarContents.add("test/test.props");
- expectedOutputJarContents.add("test/TestProperties.class");
- // From src
- expectedOutputJarContents.add("Main.class");
-
- compareJars(indir1, "src", outjar, expectedOutputJarContents);
-
- // Tidy up
- FileUtil.deleteContents(openFile(binDir));
- openFile(binDir).delete();
- assertFalse(openFile(binDir).exists());
- }
-
-
-
- /**
- * Similar to the first test but outputs to a directory rather than
- * a jar.
- *
- */
- public void testInpathToBin() {
- Set inpath = new HashSet();
- File indir1 = openFile(indir1Name);
- inpath.add(indir1);
- ideManager.getProjectProperties().setInpath(inpath);
- assertTrue("Build failed", doSynchronousBuild("build.lst"));
- assertTrue(
- "Build warnings",
- ideManager.getCompilationSourceLineTasks().isEmpty());
-
- Set expectedBindirContents = new HashSet();
- // From indir1
-// If we don't copy resources, these next three files won't make it
-// expectedBindirContents.add("META-INF/MANIFEST.MF");
-// expectedBindirContents.add("META-INF/test.xml");
-// expectedBindirContents.add("test/test.props");
- expectedBindirContents.add("test/TestProperties.class");
- // From src
- expectedBindirContents.add("Main.class");
-
- compareIndirToBin(indir1, "src", "bin", expectedBindirContents);
-
- // Tidy up
- FileUtil.deleteContents(openFile(binDir));
- openFile(binDir).delete();
- assertFalse(openFile(binDir).exists());
- }
-
-
-
- /**
- * Inputs to the compiler:
- * inpath is 'indir2' that contains a helloworld source file and class file.
- * source is 'src2' which contains Aspect.java which weaves before advice into the HelloWorld code from 'indir2'
- *
- * Expected result: HelloWorld copied through to output jar and 'weaved'. Compiled version of Aspect.java put into
- * the output jar. The HelloWorld.java source file is also copied through to the output jar.
- *
- * An extra check is done at the end of this test to verify that HelloWorld has changed size (due to the weaving).
- */
- public void testInpathToOutjar2() {
- Set inpath = new HashSet();
- File indir2 = openFile(indir2Name);
- inpath.add(indir2);
- ideManager.getProjectProperties().setInpath(inpath);
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed", doSynchronousBuild("build2.lst"));
- assertTrue(
- "Build warnings",
- ideManager.getCompilationSourceLineTasks().isEmpty());
-
- Set expectedOutputJarContents = new HashSet();
- // From indir1
- expectedOutputJarContents.add("example/HelloWorld.class");
-
-// If we don't copy resources, this file won't make it
-// expectedOutputJarContents.add("example/HelloWorld.java");
- // From src
- expectedOutputJarContents.add("Aspect.class");
-
- compareJars(indir2, "src", outjar, expectedOutputJarContents);
-
- // Extra test. The HelloWorld class from the input directory should have been woven
- // by the aspect - verify that the size of the HelloWorld class in the output directory
- // is a different size to the input version.
- int outputsize = fetchFromJar(outjar, "example/HelloWorld.class");
- try {
- FileInputStream fis = new FileInputStream(openFile(indir2Name+"/example/HelloWorld.class"));
- byte[] filedata = FileUtil.readAsByteArray(fis);
- int inputsize = filedata.length;
- assertTrue("Weaving of Aspect should have occurred but the input and output size for HelloWorld.class are the same",
- (inputsize!=outputsize));
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
-
- FileUtil.deleteContents(openFile(binDir));
- openFile(binDir).delete();
- assertFalse(openFile(binDir).exists());
- }
-
-
-
- /**
- * More complex inpath - a jar and a directory
- *
- * Inputs:
- * -inpath injar.jar;indir2
- * source is 'src2' which contains Aspect.java
- *
- * Expected result: Result should be a directory containing the contents of injar.jar and indir2 and the
- * Aspect.class file.
- *
- */
- public void testInpathAndInjarToBin() {
- Set inpath = new HashSet();
- File indir2 = openFile(indir2Name);
- inpath.add(indir2);
- inpath.add(openFile(injarName));
- ideManager.getProjectProperties().setInpath(inpath);
- assertTrue("Build failed", doSynchronousBuild("build2.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-
- Set expectedBindirContents = new HashSet();
-
- // From indir1
- expectedBindirContents.add("example/HelloWorld.class");
-
-// If we don't copy resources, this file won't make it
-// expectedBindirContents.add("example/HelloWorld.java");
- // From injar.jar
- expectedBindirContents.add("props/resources.properties");
- // From src
- expectedBindirContents.add("Aspect.class");
-
- compareIndirToBin(indir2, "src", "bin", expectedBindirContents);
-
- // Check the input and output versions of HelloWorld.class are different sizes
- try {
- FileInputStream fis1 = new FileInputStream(openFile("indir2/example/HelloWorld.class"));
- byte[] filedata1 = FileUtil.readAsByteArray(fis1);
- int inputsize = filedata1.length;
- FileInputStream fis2 = new FileInputStream(openFile("bin/example/HelloWorld.class"));
- byte[] filedata2 = FileUtil.readAsByteArray(fis2);
- int outputsize = filedata2.length;
- assertTrue("Weaving of Aspect should have occurred but the input and output size for HelloWorld.class are the same",
- (outputsize!=inputsize));
-
- fis1.close();
- fis2.close();
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- }
-
- FileUtil.deleteContents(openFile(binDir));
- openFile(binDir).delete();
- assertFalse(openFile(binDir).exists());
- }
-
-
-
- // Return the size of specified entry from the output jar file
- public int fetchFromJar(File outjarFile, String filename) {
- int ret = -1;
- try {
- JarInputStream outjar;
-
- outjar =
- new JarInputStream(new java.io.FileInputStream(outjarFile));
-
- ZipEntry entry;
- while (null != (entry = (ZipEntry)outjar.getNextEntry())) {
- String zipentryname = entry.getName();
- if (zipentryname.equals(filename)) {
- byte[] filedata = FileUtil.readAsByteArray(outjar);
- ret = filedata.length;
- outjar.closeEntry();
- break;
- }
- outjar.closeEntry();
- }
- outjar.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return ret;
- }
- /*
- * Ensure -outjar contains all non-Java resouces from injars
- */
- public void compareJars(
- File dirFile,
- String sourceDir,
- File outjarFile,
- Set expectedOutputJarContents) {
-
- try {
- assertTrue(
- "outjar older than injar",
- (outjarFile.lastModified() > dirFile.lastModified()));
-
- // Go through the output jar file, for each element, remove it from
- // the expectedOutputJarContents - when we finish, the expectedOutputJarContents
- // set should be empty!
- JarInputStream outjar =
- new JarInputStream(new java.io.FileInputStream(outjarFile));
- ZipEntry entry;
- while (null != (entry = outjar.getNextEntry())) {
- String fileName = entry.getName();
- fileName = fileName.replace('\\', '/');
- if (fileName.indexOf("CVS") == -1) {
- boolean b = expectedOutputJarContents.remove(fileName);
- assertTrue(
- "Unexpectedly found : " + fileName + " in outjar",
- b);
- }
- outjar.closeEntry();
- }
- outjar.close();
-
- assertTrue(
- "Didnt make it into the output jar: "
- + expectedOutputJarContents.toString(),
- expectedOutputJarContents.isEmpty());
- } catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
- /*
- * Ensure -outjar contains all non-Java resouces from source and injars
- */
- public void compareSourceToOutjar(String indirName, File outjarFile) {
- HashSet resources = new HashSet();
- listSourceResources(indirName, resources);
-
- try {
-
- JarInputStream outjar =
- new JarInputStream(new java.io.FileInputStream(outjarFile));
- ZipEntry entry;
- while (null != (entry = outjar.getNextEntry())) {
- String fileName = entry.getName();
-
- if (!fileName.endsWith(".class")) {
- boolean b = resources.remove(fileName);
- assertTrue(fileName, b);
- }
- outjar.closeEntry();
- }
- outjar.close();
-
- assertTrue(
- "Missing resources: " + resources.toString(),
- resources.isEmpty());
- } catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
- /*
- * Ensure bin contains all non-Java resouces from source and injars
- */
- public void compareIndirToBin(
- File indirFile,
- String sourceDir,
- String outdirName,
- Set expectedOutdirContents) {
-
-// byte[] inManifest = null;
-
- File binBase = openFile(outdirName);
- String[] toResources = FileUtil.listFiles(binBase);
- for (int i = 0; i < toResources.length; i++) {
- String fileName = toResources[i];
- if (fileName.indexOf("CVS") == -1) {
- boolean b = expectedOutdirContents.remove(fileName);
- assertTrue("Extraneous resources: " + fileName, b);
- }
- }
-
- assertTrue(
- "Missing resources: " + expectedOutdirContents.toString(),
- expectedOutdirContents.isEmpty());
- }
-
- /**
- * @param resources
- */
-// private void dumpResources(HashSet resources) {
-// System.err.println("Dump: " + resources.size() + " resources");
-// for (Iterator iter = resources.iterator(); iter.hasNext();) {
-// Object element = (Object) iter.next();
-// System.err.println(" Resource: " + element);
-// }
-// }
-
- private void listSourceResources(String indirName, Set resources) {
- File srcBase = openFile(indirName);
- File[] fromResources =
- FileUtil.listFiles(srcBase, aspectjResourceFileFilter);
- for (int i = 0; i < fromResources.length; i++) {
- String name = FileUtil.normalizedPath(fromResources[i], srcBase);
- //System.err.println("Checking "+name);
- if (!name.startsWith("CVS/")
- && (-1 == name.indexOf("/CVS/"))
- && !name.endsWith("/CVS")) {
- resources.add(name);
- }
- }
- }
-
-// private byte[] listDirResources(File directory, Set resources) {
-// return listDirResources(
-// directory.getAbsolutePath(),
-// directory,
-// resources);
-// }
-
-// private byte[] listDirResources(
-// String prefix,
-// File directory,
-// Set resources) {
-// byte[] manifest = null;
-//
-// File[] resourceFiles = directory.listFiles(new FileFilter() {
-// public boolean accept(File arg0) {
-// boolean accept =
-// !arg0.getName().endsWith(".class") && !arg0.isDirectory();
-// return accept;
-// }
-// });
-// for (int i = 0; i < resourceFiles.length; i++) {
-// File f = resourceFiles[i];
-// String name = f.getAbsolutePath();
-// if (f.getAbsolutePath().startsWith(prefix))
-// name = name.substring(prefix.length());
-// name = name.replace('\\', '/');
-//
-// resources.add(resourceFiles[i]);
-// }
-// File[] subdirs = directory.listFiles(new FileFilter() {
-// public boolean accept(File arg0) {
-// return arg0.isDirectory();
-// }
-// });
-// for (int i = 0; i < subdirs.length; i++) {
-// listDirResources(prefix, subdirs[i], resources);
-// }
-//
-// return manifest;
-// }
-
- public static final FileFilter aspectjResourceFileFilter =
- new FileFilter() {
- public boolean accept(File pathname) {
- String name = pathname.getName().toLowerCase();
- return (
- !name.endsWith(".class")
- && !name.endsWith(".java")
- && !name.endsWith(".aj"));
-
- }
- };
-
- /*
- * Ensure bin contains all non-Java resouces from source and injars
- */
- public void compareDirs(String indirName, String outdirName) {
- File binBase = openFile(outdirName);
- File[] toResources =
- FileUtil.listFiles(binBase, aspectjResourceFileFilter);
-
- HashSet resources = new HashSet();
- listSourceResources(indirName, resources);
-
- for (int i = 0; i < toResources.length; i++) {
- String fileName = FileUtil.normalizedPath(toResources[i], binBase);
- boolean b = resources.remove(fileName);
- assertTrue("Extraneous resources: " + fileName, b);
- }
-
- assertTrue(
- "Missing resources: " + resources.toString(),
- resources.isEmpty());
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/JarManifestTest.java b/ajde/testsrc/org/aspectj/ajde/JarManifestTest.java
deleted file mode 100644
index 02115847c..000000000
--- a/ajde/testsrc/org/aspectj/ajde/JarManifestTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on 16-Mar-2004
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.jar.JarInputStream;
-import java.util.jar.Manifest;
-
-import org.aspectj.util.FileUtil;
-
-/**
- * @author websterm
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class JarManifestTest extends AjdeTestCase {
-
- public static final String PROJECT_DIR = "JarManifestTest";
- public static final String srcDir = PROJECT_DIR + "/src";
- public static final String binDir = "bin";
-
- public static final String outjarName = "/bin/output.jar";
-
- /**
- * Constructor for JarResourceCopyTestCase.
- * @param arg0
- */
- public JarManifestTest (String arg0) {
- super(arg0);
- }
-
- /*
- * Ensure the output directpry in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
- public void testWeave () {
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("weave.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- checkManifest(outjar);
- }
-
- public void testNoweave () {
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("noweave.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- checkManifest(outjar);
- }
-
- private void checkManifest (File outjarFile) {
- Manifest manifest = null;
-
- try {
- JarInputStream outjar = new JarInputStream(new FileInputStream(outjarFile));
- manifest = outjar.getManifest();
- outjar.close();
- assertNotNull("'" + outjarFile.getCanonicalPath() + "' should contain a manifest",manifest);
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java b/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java
deleted file mode 100644
index 99da65f03..000000000
--- a/ajde/testsrc/org/aspectj/ajde/ModelPerformanceTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-/**
- * @author Mik Kersten
- */
-public class ModelPerformanceTest extends AjdeTestCase {
-
- // TODO-path
- private final String CONFIG_FILE_PATH = "../examples/spacewar/spacewar/debug.lst";
-
- public ModelPerformanceTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(ModelPerformanceTest.class);
- }
- public void testNothingButKeepAntJUnitHappy() {}
- /**
- * Assert that a compile that includes building the structure model
- * adds an acceptable percentage of overhead.
- *
- * Does a few initial builds to minimize caching effects.
- */
- public void skip_testRelativeToNoModel() {
- timedBuild(true);
- timedBuild(false);
- timedBuild(true);
-
- long rawBuildTime = timedBuild(false);
- long modelBuildTime = timedBuild(true);
- float overhead = (float)modelBuildTime / (float)rawBuildTime;
-
- assertTrue("overhead is " + overhead + " > 1.3", overhead < 1.3);
-// System.err.println("> overhead: " + overhead);
- }
-
- public long timedBuild(boolean buildModel) {
- long startTime = System.currentTimeMillis();
- doSynchronousBuild(CONFIG_FILE_PATH);
- Ajde.getDefault().getBuildManager().setBuildModelMode(buildModel);
- long endTime = System.currentTimeMillis();
- return (endTime - startTime);
-
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java b/ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java
deleted file mode 100644
index b4bf2dd9b..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeEditorAdapter.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.aspectj.bridge.ISourceLocation;
-
-/**
- * @author beatmik
- */
-public class NullIdeEditorAdapter implements EditorAdapter {
-
- public void showSourceLine(
- String filePath,
- int lineNumber,
- boolean highlight) {
-
- }
-
- public void showSourceLine(
- ISourceLocation sourceLocation,
- boolean highlight) {
-
- }
-
- public void showSourceLine(int lineNumber, boolean highlight) {
-
- }
-
- public String getCurrFile() {
- return null;
- }
-
- public void saveContents() throws IOException {
- }
-
- public void pasteToCaretPos(String text) {
-
- }
-
-
- public void showSourcelineAnnotation(
- String filePath,
- int lineNumber,
- List items) {
-
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java b/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java
deleted file mode 100644
index f5337adbb..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeErrorHandler.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-/**
- * @author Mik Kersten
- */
-public class NullIdeErrorHandler implements ErrorHandler {
-
- public void handleWarning(String message) {
- System.out.println("NullIde> warning: " + message);
- }
-
- public void handleError(String message) {
- System.out.println("NullIde> error: " + message);
- }
-
- public void handleError(String message, Throwable t) {
- System.out.println("NullIde> error: " + message);
- t.printStackTrace(System.out);
- }
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
deleted file mode 100644
index 400e9f79c..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeManager.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * AMC 03.27.2003 changed to allow access to NullIdeManager
- * as a singleton - needed for verifying
- * compiler warning and error messages.
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import java.util.List;
-
-import javax.swing.JFrame;
-
-import org.aspectj.ajde.ui.IdeUIAdapter;
-import org.aspectj.ajde.ui.UserPreferencesAdapter;
-import org.aspectj.ajde.ui.internal.UserPreferencesStore;
-import org.aspectj.ajde.ui.swing.*;
-
-/**
- * @author Mik Kersten
- */
-public class NullIdeManager {
-
- private static NullIdeManager ideManager = null;
- private NullIdeTaskListManager taskListManager = null;
- private NullIdeProperties projectProperties = null;
- private boolean initialized = false;
-
- public static NullIdeManager getIdeManager() {
- if ( null == ideManager ) {
- ideManager = new NullIdeManager();
- }
- return ideManager;
- }
-
- public void init(String testProjectPath) {
- try {
- UserPreferencesAdapter preferencesAdapter = new UserPreferencesStore(false);
- projectProperties = new NullIdeProperties(testProjectPath);
- taskListManager = new NullIdeTaskListManager();
- EditorAdapter ajdeEditor = new NullIdeEditorAdapter();
- IdeUIAdapter uiAdapter = new NullIdeUIAdapter();
- JFrame nullFrame = new JFrame();
-
- AjdeUIManager.getDefault().init(
- ajdeEditor,
- taskListManager,
- projectProperties,
- preferencesAdapter,
- uiAdapter,
- new IconRegistry(),
- nullFrame,
- new NullIdeProgressMonitor(),
- new NullIdeErrorHandler(),
- true);
- initialized = true;
- } catch (Throwable t) {
- initialized = false;
- t.printStackTrace();
- Ajde.getDefault().getErrorHandler().handleError(
- "Null IDE failed to initialize.",
- t);
- }
- }
-
- public List getCompilationSourceLineTasks() {
- return taskListManager.getSourceLineTasks();
- }
-
- public NullIdeProperties getProjectProperties() {
- return projectProperties;
- }
-
- public void setProjectProperties(NullIdeProperties properties) {
- projectProperties = properties;
- }
-
- public boolean isInitialized() {
- return initialized && AjdeUIManager.getDefault().isInitialized();
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java
deleted file mode 100644
index ab451f04d..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeProgressMonitor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-/**
- * @author Mik Kersten
- */
-public class NullIdeProgressMonitor implements BuildProgressMonitor {
-
- public void start(String configFile) {
-
- }
-
- public void setProgressText(String text) {
-
- }
-
- public void setProgressBarVal(int newVal) {
-
- }
-
- public void incrementProgressBarVal() {
-
- }
-
- public void setProgressBarMax(int maxVal) {
-
- }
-
- public int getProgressBarMax() {
- return 0;
- }
-
- public void finish(boolean b) {
-
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java b/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
deleted file mode 100644
index 5a38d443d..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeProperties.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * AMC 01.20.2003 extended to support AspectJ 1.1 options
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import java.io.*;
-import java.util.*;
-
-import org.aspectj.tools.ajc.AjcTests;
-import org.aspectj.util.FileUtil;
-
-/**
- * @author Mik Kersten
- */
-public class NullIdeProperties implements ProjectPropertiesAdapter {
-
- private String testProjectPath = "";
- private List buildConfigFiles = new ArrayList();
-
- private Set inJars;
- private Set inpath;
- private Set sourceRoots;
- private Set aspectPath;
- private String outJar;
- private String outputPath = "bin";
-
- public NullIdeProperties(String testProjectPath) {
- this.testProjectPath = testProjectPath;
- }
-
- public List getBuildConfigFiles() {
- return buildConfigFiles;
- }
-
- public String getLastActiveBuildConfigFile() {
- return null;
- }
-
- public String getDefaultBuildConfigFile() {
- return null;
- }
-
- public String getProjectName() {
- return "test";
- }
-
- public String getRootProjectDir() {
- return testProjectPath;
- }
-
- public List getProjectSourceFiles() {
- return null;
- }
-
- public String getProjectSourcePath() {
- return testProjectPath + "/src";
- }
-
- public String getClasspath() {
- return testProjectPath
- + File.pathSeparator
- + System.getProperty("sun.boot.class.path")
- + File.pathSeparator
- + AjcTests.aspectjrtClasspath();
- }
-
- public String getOutputPath() {
- return testProjectPath + "/" + outputPath;
- }
-
- public void setOutputPath(String outputPath) {
- this.outputPath = outputPath;
- }
-
- public OutputLocationManager getOutputLocationManager() {
- return null;
- }
-
- public String getAjcWorkingDir() {
- return testProjectPath + "/ajworkingdir";
- }
-
- public String getBootClasspath() {
- return null;
- }
-
- public String getClassToExecute() {
- return "figures.Main";
- }
-
- public String getExecutionArgs() {
- return null;
- }
-
- public String getVmArgs() {
- return null;
- }
-
- public void setInJars( Set jars ) { this.inJars = jars; }
-
- public void setInpath( Set path) { this.inpath = path; }
-
- public Set getInJars( ) {
- return inJars;
- }
-
- public Set getInpath( ) {
- return inpath;
- }
-
- public Map getSourcePathResources() {
- Map map = new HashMap();
-
- /* Allow the user to override the testProjectPath by using sourceRoots */
- File[] srcBase;
- if (sourceRoots == null || sourceRoots.isEmpty()) {
- srcBase = new File[] { new File(getProjectSourcePath()) };
- }
- else {
- srcBase = new File[sourceRoots.size()];
- sourceRoots.toArray(srcBase);
- }
-
- for (int j = 0; j < srcBase.length; j++) {
- File[] fromResources = FileUtil.listFiles(srcBase[j], new FileFilter() {
- public boolean accept(File pathname) {
- String name = pathname.getName().toLowerCase();
- return !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj");
- }
- });
- for (int i = 0; i < fromResources.length; i++) {
- String normPath = FileUtil.normalizedPath(fromResources[i] ,srcBase[j]);
- map.put(normPath, fromResources[i]);
-
- }
- }
-
- return map;
- }
-
- public void setOutJar( String jar ){ this.outJar = jar; }
-
- public String getOutJar() {
- return outJar;
- }
-
- public void setSourceRoots( Set roots ) { this.sourceRoots = roots; }
-
- public Set getSourceRoots() {
- return sourceRoots;
- }
-
- public void setAspectPath( Set path ) { this.aspectPath = path; }
-
- public Set getAspectPath() {
- return aspectPath;
- }
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java b/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
deleted file mode 100644
index 33ed12342..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeTaskListManager.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.aspectj.bridge.*;
-
-/**
- * Used for displaying tasks, such as compiler messages, to the user.
- *
- * @author Mik Kersten
- */
-public class NullIdeTaskListManager implements TaskListManager {
-
- List sourceLineTasks = new ArrayList();
- boolean hasWarning = false;
- private static boolean debugTests = false;
-
- public void addSourcelineTask(
- String message,
- ISourceLocation sourceLocation,
- IMessage.Kind kind) {
- addSourcelineTask(new Message(message, kind, null, sourceLocation));
- if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
- hasWarning = true;
- }
- }
-
-
- public void addSourcelineTask(IMessage message) {
- sourceLineTasks.add(new SourceLineTask(message));
- if (!hasWarning && IMessage.WARNING.isSameOrLessThan(message.getKind())) {
- hasWarning = true;
- }
- /* Guard against null source locations e.g. JAR file messages */
- if (!debugTests) return;
- if (null != message.getSourceLocation()) {
- System.out.println("NullIde> task: " + message.getMessage() + ", file: " + message.getSourceLocation().getSourceFile().getAbsolutePath()
- + ": " + message.getSourceLocation().getLine());
- }
- else {
- System.out.println("NullIde> task: " + message);
- }
-
- }
-
- public void addProjectTask(String message, IMessage.Kind kind) {
- if (!hasWarning && IMessage.WARNING.isSameOrLessThan(kind)) {
- hasWarning = true;
- }
- System.out.println("NullIde> task: " + message + ", kind: " + kind);
- }
-
- public boolean hasWarning() {
- return hasWarning;
- }
-
- public void clearTasks() {
- sourceLineTasks = new ArrayList();
- hasWarning = false;
- }
-
- /**
- * Return the list of source line compiler messages resulting from a compile, so
- * that we can test them.
- * @return List
- */
- public List getSourceLineTasks() {
- return sourceLineTasks;
- }
-
-
- public static class SourceLineTask {
- IMessage message;
-
- public SourceLineTask(IMessage m) {
- message = m;
- }
-
- public IMessage getContainedMessage() {
- return message;
- }
-
- public String toString() {
- String loc = "<no location>";
- if (null != message.getSourceLocation()) {
- loc = message.getSourceLocation().getSourceFile() + ":" + message.getSourceLocation().getLine();
- }
- return "SourceLineTask [" + message.getMessage()
- + ", " + loc
- + ", " + message.getKind()
- + "]";
- }
- }
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java b/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java
deleted file mode 100644
index b0ba1457b..000000000
--- a/ajde/testsrc/org/aspectj/ajde/NullIdeUIAdapter.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import org.aspectj.ajde.ui.*;
-
-public class NullIdeUIAdapter implements IdeUIAdapter {
- private final static boolean debugTests = false;
- public void displayStatusInformation(String message) {
- if (debugTests) System.out.println("NullIde>" + message);
- }
-
- public void resetGUI() {
- // not implemented
- }
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java b/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java
deleted file mode 100644
index 2c018de1b..000000000
--- a/ajde/testsrc/org/aspectj/ajde/OutxmlTest.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Matthew Webster initial implementation
- * ******************************************************************/
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.aspectj.bridge.Constants;
-import org.aspectj.util.FileUtil;
-
-public class OutxmlTest extends AjdeTestCase {
-
- public static final String PROJECT_DIR = "OutxmlTest";
- public static final String BIN_DIR = "bin";
- public static final String OUTJAR_NAME = "/bin/test.jar";
- public static final String DEFAULT_AOPXML_NAME = Constants.AOP_AJC_XML;
- public static final String CUSTOM_AOPXML_NAME = "custom/aop.xml";
-
- /*
- * Ensure the output directory is clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(BIN_DIR));
- }
-
- /*
- * Clean up afterwards
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- FileUtil.deleteContents(openFile(BIN_DIR));
- openFile(BIN_DIR).delete();
- }
-
-
- /**
- * Aim: Test "-outxml" option produces the correct xml file
- *
- */
- public void testOutxmlToFile () {
-// System.out.println("OutxmlTest.testOutxmlToFile() outputpath='" + ideManager.getProjectProperties().getOutputPath() + "'");
- assertTrue("Build failed",doSynchronousBuild("outxml-to-file.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-
- File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
- assertTrue(DEFAULT_AOPXML_NAME + " missing",aopxml.exists());
- }
-
- /**
- * Aim: Test "-outxmlfile filename" option produces the correct
- * xml file
- *
- */
- public void testOutxmlfileToFile () {
- assertTrue("Build failed",doSynchronousBuild("outxmlfile-to-file.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-
- File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
- assertTrue(CUSTOM_AOPXML_NAME + " missing",aopxml.exists());
- }
-
- /**
- * Aim: Test "-outxml" option produces the correct
- * xml entry in outjar file
- *
- */
- public void testOutxmlToOutjar () {
- File outjar = openFile(OUTJAR_NAME);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("outxml-to-outjar.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-
- File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
- assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
- assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
- }
-
- /**
- * Aim: Test "-outxmlfile filename" option produces the correct
- * xml entry in outjar file
- *
- */
- public void testOutxmlfileToOutjar () {
-// System.out.println("OutxmlTest.testOutxmlToOutjar() outputpath='" + ideManager.getProjectProperties().getOutputPath() + "'");
- File outjar = openFile(OUTJAR_NAME);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("outxmlfile-to-outjar.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-
- File aopxml = openFile(BIN_DIR + "/" + CUSTOM_AOPXML_NAME);
- assertFalse(CUSTOM_AOPXML_NAME + " should not exisit",aopxml.exists());
- assertJarContainsEntry(outjar,CUSTOM_AOPXML_NAME);
- }
-
- /**
- * Aim: Test "-outxml" option produces a warning if "META-INF/aop.xml
- * already exists in source
- *
- */
- public void testOutxmlToOutjarWithAop_xml () {
- File f = new File( AjdeTests.testDataPath(PROJECT_DIR + "/src-resources"));
- Set roots = new HashSet();
- roots.add(f);
- ideManager.getProjectProperties().setSourceRoots(roots);
- File outjar = openFile(OUTJAR_NAME);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed: " + ideManager.getCompilationSourceLineTasks(),doSynchronousBuild("outxml-to-outjar-with-aop_xml.lst"));
-// assertTrue("Build warnings: " + ideManager.getCompilationSourceLineTasks(),ideManager.getCompilationSourceLineTasks().isEmpty());
- assertFalse("Build warnings for exisiting resource expected",ideManager.getCompilationSourceLineTasks().isEmpty());
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- String msg = ((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage();
- assertTrue("Wrong message: " + msg,msg.startsWith("-outxml/-outxmlfile option ignored because resource already exists:"));
-
- File aopxml = openFile(BIN_DIR + "/" + DEFAULT_AOPXML_NAME);
- assertFalse(DEFAULT_AOPXML_NAME + " should not exisit",aopxml.exists());
- assertJarContainsEntry(outjar,DEFAULT_AOPXML_NAME);
- }
-
- private void assertJarContainsEntry (File file, String entryName) {
-
- try {
- JarFile jarFile = new JarFile(file);
- JarEntry jarEntry = jarFile.getJarEntry(entryName);
- assertNotNull(entryName + " missing",jarEntry);
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java b/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
deleted file mode 100644
index dd92b59ea..000000000
--- a/ajde/testsrc/org/aspectj/ajde/ResourceCopyTestCase.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2003 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.*;
-import java.util.*;
-import java.util.jar.JarInputStream;
-import java.util.zip.*;
-
-import org.aspectj.util.FileUtil;
-
-/**
- * @author websterm
- */
-public class ResourceCopyTestCase extends AjdeTestCase {
-
- public static final String PROJECT_DIR = "bug-36071a";
- public static final String srcDir = PROJECT_DIR + "/src";
- public static final String binDir = "bin";
-
- public static final String injar1Name = "input1.jar";
- public static final String injar2Name = "input2.jar";
- public static final String outjarName = "/bin/output.jar";
-
- /**
- * Constructor for JarResourceCopyTestCase.
- * @param arg0
- */
- public ResourceCopyTestCase(String arg0) {
- super(arg0);
- }
-
- /*
- * Ensure the output directpry in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
- public void testSrcToBin () {
- assertTrue(!Ajde.getDefault().getTaskListManager().hasWarning());
- assertTrue("Build failed",doSynchronousBuild("config1.lst"));
- compareDirs("src","bin");
- }
-
- public void testInjarsToOutjar () {
- Set injars = new HashSet();
- File injar1 = openFile(injar1Name);
- injars.add(injar1);
- ideManager.getProjectProperties().setInJars(injars);
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("config2.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- compareJars(injar1,"src",outjar);
- }
-
- public void testDuplicateResources () {
- Set injars = new HashSet();
- File injar1 = openFile(injar1Name);
- File injar2 = openFile(injar2Name);
- injars.add(injar1);
- injars.add(injar2);
- ideManager.getProjectProperties().setInJars(injars);
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build should have suceeded",doSynchronousBuild("config2.lst"));
- assertFalse("Build warnings for duplicate resource expected",ideManager.getCompilationSourceLineTasks().isEmpty());
- List msgs = NullIdeManager.getIdeManager().getCompilationSourceLineTasks();
- assertTrue("Wrong message",((NullIdeTaskListManager.SourceLineTask)msgs.get(0)).message.getMessage().startsWith("duplicate resource: "));
- compareJars(injar1,"src",outjar);
- }
-
- public void testSrcToOutjar () {
- File outjar = openFile(outjarName);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("config1.lst"));
- compareSourceToOutjar("src",outjar);
- }
-
- public void testInjarsToBin () {
- Set injars = new HashSet();
- File injar1 = openFile(injar1Name);
- injars.add(injar1);
- ideManager.getProjectProperties().setInJars(injars);
- assertTrue("Build failed",doSynchronousBuild("config2.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- compareInjarsToBin(injar1,"src","bin");
- }
-
- // BAH! keeps whinging about CVS extraneous resources
-// public void testInjarsToOddBin () {
-// Set injars = new HashSet();
-// File injar1 = openFile(injar1Name);
-// injars.add(injar1);
-// ideManager.getProjectProperties().setOutputPath("crazy.jar");
-// ideManager.getProjectProperties().setInJars(injars);
-// assertTrue("Build failed",doSynchronousBuild("config2.lst"));
-// assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
-// compareInjarsToBin(injar1,"src","crazy.jar");
-// }
-
- public void testInjarsToOutjarOddNames () {
- Set injars = new HashSet();
- File injar1 = openFile("input1");
- File outjar = openFile(outjarName+".fozout");
- injars.add(injar1);
- ideManager.getProjectProperties().setInJars(injars);
- ideManager.getProjectProperties().setOutJar(outjar.getAbsolutePath());
- assertTrue("Build failed",doSynchronousBuild("config2.lst"));
- assertTrue("Build warnings",ideManager.getCompilationSourceLineTasks().isEmpty());
- compareJars(injar1,"src",outjar);
- }
-
- /*
- * Ensure bin contains all non-Java resouces from source and injars
- */
- public void compareDirs (String indirName, String outdirName) {
- File binBase = openFile(outdirName);
- File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter);
-
- HashSet resources = new HashSet();
- listSourceResources(indirName,resources);
-
- for (int i = 0; i < toResources.length; i++) {
- String fileName = FileUtil.normalizedPath(toResources[i],binBase);
- boolean b = resources.remove(fileName);
- assertTrue("Extraneous resources: " + fileName,b);
- }
-
- assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
- }
-
- /*
- * Ensure -outjar contains all non-Java resouces from injars
- */
- public void compareJars (File injarFile, String indirName, File outjarFile) {
-
- HashSet resources = new HashSet();
-
- try {
- assertTrue("outjar older than injar",(outjarFile.lastModified() > injarFile.lastModified()));
- byte[] inManifest = listJarResources(injarFile,resources);
- listSourceResources(indirName,resources);
-
- ZipInputStream outjar = new ZipInputStream(new java.io.FileInputStream(outjarFile));
- ZipEntry entry;
- while (null != (entry = outjar.getNextEntry())) {
- String fileName = entry.getName();
- if (!fileName.endsWith(".class")) {
-
- /* Ensure we copied right JAR manifest */
- if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
- byte[] outManifest = FileUtil.readAsByteArray(outjar);
- assertTrue("Wrong manifest has been copied",Arrays.equals(inManifest,outManifest));
- }
-
- boolean b = resources.remove(fileName);
- assertTrue(fileName,b);
- }
- outjar.closeEntry();
- }
- outjar.close();
-
- assertTrue(resources.toString(),resources.isEmpty());
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
- /*
- * Ensure -outjar conatins all non-Java resouces from source and injars
- */
- public void compareSourceToOutjar (String indirName, File outjarFile) {
- HashSet resources = new HashSet();
- listSourceResources(indirName,resources);
-
- try {
-
- ZipInputStream outjar = new JarInputStream(new java.io.FileInputStream(outjarFile));
- ZipEntry entry;
- while (null != (entry = outjar.getNextEntry())) {
- String fileName = entry.getName();
- if (!fileName.endsWith(".class")) {
- boolean b = resources.remove(fileName);
- assertTrue(fileName,b);
- }
- outjar.closeEntry();
- }
- outjar.close();
-
- assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
- /*
- * Ensure bin contains all non-Java resouces from source and injars
- */
- public void compareInjarsToBin(File injarFile, String indirName, String outdirName) {
-
- HashSet resources = new HashSet();
-
- try {
- byte[] inManifest = listJarResources(injarFile,resources);
- listSourceResources(indirName,resources);
-
- File binBase = openFile(outdirName);
- File[] toResources = FileUtil.listFiles(binBase,aspectjResourceFileFilter);
- for (int i = 0; i < toResources.length; i++) {
- String fileName = FileUtil.normalizedPath(toResources[i],binBase);
-
- /* Ensure we copied the right JAR manifest */
- if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
- byte[] outManifest = FileUtil.readAsByteArray(toResources[i]);
- assertTrue("Wrong manifest has been copied",Arrays.equals(inManifest,outManifest));
- }
- boolean b = resources.remove(fileName);
- assertTrue("Extraneous resources: " + fileName,b);
- }
-
- assertTrue("Missing resources: " + resources.toString(), resources.isEmpty());
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
- }
-
- private void listSourceResources (String indirName, Set resources) {
- File srcBase = openFile(indirName);
- File[] fromResources = FileUtil.listFiles(srcBase,aspectjResourceFileFilter);
- for (int i = 0; i < fromResources.length; i++) {
- String name = FileUtil.normalizedPath(fromResources[i],srcBase);
- if (!name.startsWith("CVS/") && (-1 == name.indexOf("/CVS/")) && !name.endsWith("/CVS")) {
- resources.add(name);
- }
- }
- }
-
- private byte[] listJarResources (File injarFile, Set resources) {
- byte[] manifest = null;
-
- try {
- ZipInputStream injar = new ZipInputStream(new java.io.FileInputStream(injarFile));
- ZipEntry entry;
- while (null != (entry = injar.getNextEntry())) {
- String fileName = entry.getName();
- if (!entry.isDirectory() && !fileName.endsWith(".class")) {
-
- /* JAR manifests shouldn't be copied */
- if (fileName.equalsIgnoreCase("meta-inf/Manifest.mf")) {
- manifest = FileUtil.readAsByteArray(injar);
- }
- resources.add(fileName);
- }
- injar.closeEntry();
- }
- injar.close();
- }
- catch (IOException ex) {
- fail(ex.toString());
- }
-
- return manifest;
- }
-
- public static final FileFilter aspectjResourceFileFilter = new FileFilter() {
- public boolean accept(File pathname) {
- String name = pathname.getName().toLowerCase();
- boolean isCVSRelated = name.indexOf("/cvs/")!=-1;
- return (!isCVSRelated && !name.endsWith(".class") && !name.endsWith(".java") && !name.endsWith(".aj"));
- }
- };
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java b/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java
deleted file mode 100644
index 0153630c2..000000000
--- a/ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement Initial version
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.aspectj.ajde.internal.CompilerAdapter;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.util.FileUtil;
-
-public class ReweavableTestCase extends AjdeTestCase {
-
- private CompilerAdapter compilerAdapter;
- public static final String PROJECT_DIR = "ReweavableTest";
-
- private static final boolean debugTests = false;
-
- public static final String binDir = "bin";
-
- public static final String indir1Name = "indir1";
- public static final String indir2Name = "indir2";
- public static final String injarName = "injar.jar";
- public static final String outjarName = "/bin/output.jar";
-
-
-// private static int nonreweavesize_CalculatePI;
-// private static int nonreweavesize_Logger;
-// private static int reweavablesize_CalculatePI;
-// private static int reweavablesize_Logger;
-
- /**
- * Constructor for JarResourceCopyTestCase.
- * @param arg0
- */
- public ReweavableTestCase(String arg0) {
- super(arg0);
- }
-
-
-
- /*
- * Ensure the output directpry in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
-
- /**
- * Aim: Check we haven't damaged 'normal compilation' when not supplying -Xreweavable. Also determines
- * baseline sizes for the compiled class files for later comparison.
- *
- * Inputs to the compiler:
- * NonReweavable1.lst
- * -> CalculatePI.java
- * -> Logger.aj
- * -> -verbose
- * -> -noExit
- *
- * Expected result = Compile successful, the types will not be reweavable and the weaver
- * should not report it is running in reweavable mode.
- */
- public void testNonReweavableCompile() {
- if (debugTests) System.out.println("testNonReweavableCompile: Building with NonReweavable1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("NonReweavable1.lst").getAbsolutePath(),new BPM(),false);
-
- assertFalse("Did not expect to find a message about the weaver operating in reweavable mode",
- checkFor("weaver operating in reweavable mode"));
-
- File fCalc = openFile("bin/CalculatePI.class");
- File fLog = openFile("bin/Logger.class");
- assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
- assertTrue("bin/Logger.class should exist?!?",fLog.exists());
- if (debugTests) System.out.println("CalculatePI.class is of size: "+fCalc.length());
- if (debugTests) System.out.println("Logger.class is of size: "+fLog.length());
- if (debugTests) System.out.println("\n\n\n");
- /*nonreweavesize_CalculatePI = (int)*/fCalc.length();
- /*nonreweavesize_Logger = (int)*/fLog.length();
- }
-
-
- /**
- * Aim: Basic call to -Xreweavable. Weaver should report it is in reweavable mode and the
- * classes produced should be much larger than normal classes (those produced in the first
- * test).
- *
- * Inputs to the compiler:
- * Reweavable1.lst
- * -> CalculatePI.java
- * -> Logger.aj
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- *
- * Expected result = Compile successful, the types will be reweavable and the weaver
- * should report it is running in reweavable mode. The files produced
- * should be larger than those created during the last test.
- */
- public void testReweavableCompile() {
- if (debugTests) System.out.println("testReweavableCompile: Building with Reweavable1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
- File fCalc = openFile("bin/CalculatePI.class");
- File fLog = openFile("bin/Logger.class");
- assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
- assertTrue("bin/Logger.class should exist?!?",fLog.exists());
- if (debugTests) System.out.println("CalculatePI.class is of size: "+fCalc.length());
- if (debugTests) System.out.println("Logger.class is of size: "+fLog.length());
- // Temporarily remove these tests - it seems the order in which the testXXX methods are run cannot be relied upon
- // so reweavablesize_XXX fields might not have been set yet.
-// assertTrue("Reweavable version should be larger than non-reweavable version of CalculatePI",
-// fCalc.length()>nonreweavesize_CalculatePI);
-// assertTrue("Reweavable version should be larger than non-reweavable version of Logger",
-// fLog.length()>nonreweavesize_Logger);
-
- /*reweavablesize_CalculatePI = (int)*/fCalc.length();
- /*reweavablesize_Logger = (int)*/fLog.length();
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
-
- /**
- * Aim: Use the optional ':compress' modifier on -Xreweavable. This causes some of the meta-data
- * for use in reweaving to be compressed. It should succeed and produce class files smaller
- * than straight -Xreweavable but larger than without specifying -Xreweavable.
- *
- * Inputs to the compiler:
- * ReweavableCompress1.lst
- * -> CalculatePI.java
- * -> Logger.aj
- * -> -Xreweavable:compress
- * -> -verbose
- * -> -noExit
- *
- * Expected result = Compile successful, the types will be reweavable and the weaver
- * should report it is running in reweavable mode. The files created should
- * have a size between the non-reweavable versions and the reweavable (without
- * compression) versions.
- */
- public void testReweavableCompressCompile() {
- if (debugTests) System.out.println("testReweavableCompressCompile: Building with ReweavableCompress1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("ReweavableCompress1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
- File fCalc = openFile("bin/CalculatePI.class");
- File fLog = openFile("bin/Logger.class");
- assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
- assertTrue("bin/Logger.class should exist?!?",fLog.exists());
- int calclen = (int)fCalc.length();
- int loglen = (int)fLog.length();
- if (debugTests) System.out.println("CalculatePI.class is of size: "+calclen);
- if (debugTests) System.out.println("Logger.class is of size: "+loglen);
- // Temporarily remove these tests - it seems the order in which the testXXX methods are run cannot be relied upon
- // so reweavablesize_XXX fields might not have been set yet.
-// assertTrue("Reweavable version should be larger than non-reweavable version of CalculatePI",
-// calclen>nonreweavesize_CalculatePI);
-// assertTrue("Reweavable version should be larger than non-reweavable version of Logger",
-// loglen>nonreweavesize_Logger);
-
- // Temporarily remove these tests - it seems the order in which the testXXX methods are run cannot be relied upon
- // so reweavablesize_XXX fields might not have been set yet.
-// assertTrue("Reweavable (with compression) version should be smaller than reweavable (without compression) version of CalculatePI:" + // " Compressed version:"+calclen+"bytes Non-compressed version:"+reweavablesize_CalculatePI+"bytes",
-// calclen<reweavablesize_CalculatePI);
-// assertTrue("Reweavable (with compression) version should be smaller than reweavable (without compression) version of Logger"+
-// " Compressed version:"+loglen+"bytes Non-compressed version:"+reweavablesize_Logger+"bytes",
-// loglen<reweavablesize_Logger);
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
-
- /**
- * Aim: The tests above have determined that reweaving appears to be behaving in terms of the .class
- * files it is creating. Now lets actually attempt a reweave. For this, we build two files
- * as reweavable and then build a single file whilst specifying an inpath that contains the
- * .class files from the first compile. This should succeed.
- *
- * Inputs to the first compile:
- * Reweavable1.lst
- * -> CalculatePI.java
- * -> Logger.aj
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- *
- * Input to the second compile:
- * Reweavable2.lst
- * -> SecondAspect.aj
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- * -inpath bin\.
- *
- * Expected result = Both compiles will succeed.
- */
- public void testReweavableSimpleCompile() {
- if (debugTests) System.out.println("testReweavableSimpleCompile: Building with Reweavable1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
-
- if (debugTests) System.out.println("\ntestReweavableSimpleCompile: Building with Reweavable2.lst");
- Set paths = new HashSet();
- paths.add(openFile(binDir));
- ideManager.getProjectProperties().setInpath(paths);
- compilerAdapter.compile((String) openFile("Reweavable2.lst").getAbsolutePath(),new BPM(),false);
-
-
- String expMessage ="successfully verified type Logger exists";
- assertTrue("Expected message '"+expMessage+"' but did not find it",
- checkFor(expMessage));
-
- File fCalc = openFile("bin/CalculatePI.class");
- File fLog = openFile("bin/Logger.class");
- File fSec = openFile("bin/SecondAspect.class");
- assertTrue("bin/CalculatePI.class should exist?!?",fCalc.exists());
- assertTrue("bin/Logger.class should exist?!?",fLog.exists());
- assertTrue("bin/SecondAspect.class should exist?!?",fSec.exists());
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
-
- /**
- * Aim: Based on the test above, if we delete Logger.class between the first and second compiles
- * the second compile should fail because there is not enough information to reweave CalculatePI
- *
- * Inputs to the first compile:
- * Reweavable1.lst
- * -> CalculatePI.java
- * -> Logger.aj
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- *
- * Input to the second compile:
- * Reweavable2.lst
- * -> SecondAspect.aj
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- * -inpath bin\.
- *
- * Expected result = Second compile will fail - reporting that Logger is missing (it 'touched' in the first compile CalculatePI)
- */
- public void testForReweavableSimpleErrorCompile() {
- if (debugTests) System.out.println("testForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("Reweavable1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
-
- assertTrue("Could not delete bin/Logger.class??",openFile("bin/Logger.class").delete());
-
-
- if (debugTests) System.out.println("\ntestForReweavableSimpleErrorCompile: Building with Reweavable2.lst");
- Set paths = new HashSet();
- paths.add(openFile(binDir));
- ideManager.getProjectProperties().setInpath(paths);
- compilerAdapter.compile((String) openFile("Reweavable2.lst").getAbsolutePath(),new BPM(),false);
-
-
- String expMessage ="type Logger is needed by reweavable type CalculatePI";
- assertTrue("Expected message '"+expMessage+"' but did not find it",
- checkFor(expMessage));
-
- File fCalc = openFile("bin/CalculatePI.class");
- File fLog = openFile("bin/Logger.class");
- File fSec = openFile("bin/SecondAspect.class");
- assertTrue("bin/CalculatePI.class should exist!",fCalc.exists());
- assertTrue("bin/Logger.class should not exist!",!fLog.exists());
- assertTrue("bin/SecondAspect.class should not exist!",fSec.exists());
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
-
- /**
- * Aim: Based on the test above, if we delete Logger.class between the first and second compiles
- * the second compile should fail because there is not enough information to reweave CalculatePI
- *
- * Inputs to the first compile:
- * TJP1.lst
- * -> tjp/Demo.java
- * -> tjp/GetInfo.java
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- *
- * Now, delete bin\tjp\GetInfo.class and do a compile with:
- * TJP2.lst
- * -> -Xreweavable
- * -> -verbose
- * -> -noExit
- * -inpath bin\.
- *
- * Expected result = Second compile will fail - reporting that tjp.GetInfo is missing (it 'touched' in the first compile tjp.Demo)
- */
- public void testErrorScenario2Compile() {
- if (debugTests) System.out.println("testErrorScenario2: Building with TJP1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("TJP1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
-
- assertTrue("Could not delete bin/tjp/GetInfo.class??",openFile("bin/tjp/GetInfo.class").delete());
-
-
- if (debugTests) System.out.println("\ntestErrorScenario2: Building with TJP2.lst");
- Set paths = new HashSet();
- paths.add(openFile(binDir));
- ideManager.getProjectProperties().setInpath(paths);
- compilerAdapter.compile((String) openFile("TJP2.lst").getAbsolutePath(),new BPM(),false);
-
-
- String expMessage ="type tjp.GetInfo is needed by reweavable type tjp.Demo";
- assertTrue("Expected message '"+expMessage+"' but did not find it",
- checkFor(expMessage));
-
- File fDemo = openFile("bin/tjp/Demo.class");
- File fGetInfo = openFile("bin/tjp/GetInfo.class");
- assertTrue("bin/tjp/Demo.class should exist!",fDemo.exists());
- assertTrue("bin/tjp/GetInfo.class should not exist!",!fGetInfo.exists());
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
- public void testWorkingScenario2Compile() {
- if (debugTests) System.out.println("testWorkingScenario2: Building with TJP1.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.getMessageHandler().dontIgnore(IMessage.INFO);
- compilerAdapter.compile((String) openFile("TJP1.lst").getAbsolutePath(),new BPM(),false);
-
- assertTrue("Expected a message about operating in reweavable mode, but didn't get one",
- checkFor("weaver operating in reweavable mode"));
-
-
- if (debugTests) System.out.println("\ntestWorkingScenario2: Building with TJP2.lst");
- Set paths = new HashSet();
- paths.add(openFile(binDir));
- ideManager.getProjectProperties().setInpath(paths);
- compilerAdapter.compile((String) openFile("TJP2.lst").getAbsolutePath(),new BPM(),false);
-
-
- String expMessage ="successfully verified type tjp.GetInfo exists";
- assertTrue("Expected message '"+expMessage+"' but did not find it",
- checkFor(expMessage));
-
- File fGetInfo = openFile("bin/tjp/GetInfo.class");
- File fDemo = openFile("bin/tjp/Demo.class");
- assertTrue("bin/tjp/GetInfo.class should exist!",fGetInfo.exists());
- assertTrue("bin/tjp/Demo.class should not exist!",fDemo.exists());
-
- if (debugTests) System.out.println("\n\n\n");
- }
-
-
- private class BPM implements BuildProgressMonitor {
- public void start(String configFile) {}
-
- public void setProgressText(String text) {}
-
- public void setProgressBarVal(int newVal) { }
-
- public void incrementProgressBarVal() {}
-
- public void setProgressBarMax(int maxVal) { }
-
- public int getProgressBarMax() {
- return 0;
- }
-
- public void finish(boolean b) {}
-
- }
-
-
-
-
- private boolean checkFor(String what) {
- List ll = ideManager.getCompilationSourceLineTasks();
- for (Iterator iter = ll.iterator(); iter.hasNext();) {
- Object element = (Object) iter.next();
- if (element.toString().indexOf(what)!=-1) return true;
- }
- return false;
- }
-
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java b/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
deleted file mode 100644
index 49453fafe..000000000
--- a/ajde/testsrc/org/aspectj/ajde/SavedModelConsistencyTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-
-
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mik Kersten initial implementation
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.aspectj.asm.AsmManager;
-import org.aspectj.asm.HierarchyWalker;
-import org.aspectj.asm.IHierarchy;
-import org.aspectj.asm.IProgramElement;
-
-/**
- * @author Mik Kersten
- */
-public class SavedModelConsistencyTest extends AjdeTestCase {
-
- // TODO-path
- private final String CONFIG_FILE_PATH = "../examples/coverage/coverage.lst";
-
- public SavedModelConsistencyTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(SavedModelConsistencyTest.class);
- }
-
- public void testInterfaceIsSameInBoth() {
- File configFile = openFile(CONFIG_FILE_PATH);
- Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
-
- IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
- assertTrue("model exists", model != null);
-
- assertTrue("root exists", model.getRoot() != null);
- // TODO-path
- File testFile = openFile("../examples/coverage/ModelCoverage.java");
- assertTrue(testFile.exists());
-
- IProgramElement nodePreBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);
-
- doSynchronousBuild(CONFIG_FILE_PATH);
-
- IProgramElement nodePostBuild = model.findElementForSourceLine(testFile.getAbsolutePath(), 5);
-
- assertTrue("Nodes should be identical: Prebuild kind = "+nodePreBuild.getKind()+
- " Postbuild kind = "+nodePostBuild.getKind(),nodePreBuild.getKind().equals(nodePostBuild.getKind()));
-
- }
-
- public void testModelIsSamePreAndPostBuild() {
- File configFile = openFile(CONFIG_FILE_PATH);
- Ajde.getDefault().getStructureModelManager().readStructureModel(configFile.getAbsolutePath());
-
- IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
- assertTrue("model exists", model != null);
-
- final List preBuildKinds = new ArrayList();
- HierarchyWalker walker = new HierarchyWalker() {
- public void preProcess(IProgramElement node) {
- preBuildKinds.add(node.getKind());
- }
- };
- Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
-
- doSynchronousBuild(CONFIG_FILE_PATH);
-
- final List postBuildKinds = new ArrayList();
- HierarchyWalker walker2 = new HierarchyWalker() {
- public void preProcess(IProgramElement node) {
- postBuildKinds.add(node.getKind());
- }
- };
- Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker2);
-
-// System.err.println(preBuildKinds);
-// System.err.println(postBuildKinds);
-
- assertTrue("Lists should be the same: PRE"+preBuildKinds.toString()+" POST"+postBuildKinds.toString(),preBuildKinds.equals(postBuildKinds));
-
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- // In order to get a model on the disk to read in, do a build with the right flag set !
- try {
- AsmManager.dumpModelPostBuild=true;
- doSynchronousBuild(CONFIG_FILE_PATH);
- } finally {
- AsmManager.dumpModelPostBuild=false;
- }
-
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java b/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java
deleted file mode 100644
index 57a5fcaaf..000000000
--- a/ajde/testsrc/org/aspectj/ajde/ShowWeaveMessagesTestCase.java
+++ /dev/null
@@ -1,424 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2004 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Andy Clement Initial version
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.aspectj.ajde.internal.CompilerAdapter;
-import org.aspectj.bridge.IMessage;
-import org.aspectj.util.FileUtil;
-import org.aspectj.util.LangUtil;
-
-/**
- * Weaving messages are complicated things. There are multiple places where weaving
- * takes place and the places vary depending on whether we are doing a binary weave or
- * going from source. All places that output weaving messages are tagged:
- * // TAG: WeavingMessage
- * so you can easily find them!
- *
- * Advice is the simplest to deal with as that is advice weaving is always done in the weaver.
- *
- * Next is intertype declarations. These are also always done in the weaver but in the case
- * of a binary weave we don't know the originating source line for the ITD.
- *
- * Finally, declares.
- * Declare Parents: extends Can only be done when going from source, if attempted by a
- * binary weave then an error message (compiler limitation) is
- * produced.
- * Declare Parents: implements Is (currently!) done at both compile time and weave time.
- * If going from source then the message is produced by the
- * code in the compiler. if going from binary then the message
- * is produced by the weaver.
- * Declare Soft: Comes out with 'advice' as a special kind of advice: softener advice
- *
- *
- * Q: Where are the messages turned on/off?
- * A: It is a bit messy. See BuildArgParser.genBuildConfig(). Basically that method is the first time
- * we parse the option set. Whether weaving messages are on or off is stored in the build config.
- * As soon as we have parser the options and determined that weave messages are on, we grab the
- * top level message handler and tell it not to ignore WeaveInfo messages.
- *
- *
- * TODO - Other forms of declare? Do they need messages? e.g. declare precedence *
- */
-public class ShowWeaveMessagesTestCase extends AjdeTestCase {
-
- private static boolean regenerate;
- private static boolean debugTests = false;
-
- static {
- // Switch this to true for a single iteration if you want to reconstruct the
- // 'expected weaving messages' files.
- regenerate = false;
- }
-
-
- private CompilerAdapter compilerAdapter;
- public static final String PROJECT_DIR = "WeaveInfoMessagesTest";
-
- public static final String binDir = "bin";
- public static final String expectedResultsDir = "expected";
-
-
- public ShowWeaveMessagesTestCase(String arg0) {
- super(arg0);
- }
-
- /*
- * Ensure the output directory in clean
- */
- protected void setUp() throws Exception {
- super.setUp(PROJECT_DIR);
- FileUtil.deleteContents(openFile(binDir));
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- FileUtil.deleteContents(openFile(binDir));
- openFile(binDir).delete();
- File rogueSymFile = new File(currTestDataPath + File.separatorChar + "Empty.ajsym");
- if (rogueSymFile.exists()) rogueSymFile.delete();
- }
-
-
-
- /**
- * Weave all the possible kinds of advice and verify the messages that come out.
- */
- public void testWeaveMessagesAdvice() {
- if (debugTests) System.out.println("testWeaveMessagesAdvice: Building with One.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("One.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("advice",true);
- }
-
-
-
-
- /**
- * Weave field and method ITDs and check the weave messages that come out.
- */
- public void testWeaveMessagesITD() {
- if (debugTests) System.out.println("\ntestWeaveMessagesITD: Building with Two.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Two.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("itd",true);
- }
-
-
- /**
- * Weave "declare parents: implements" and check the weave messages that come out.
- */
- public void testWeaveMessagesDeclare() {
- if (debugTests) System.out.println("\ntestWeaveMessagesDeclare: Building with Three.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Three.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("declare1",true);
- }
-
- /**
- * Weave "declare parents: extends" and check the weave messages that come out.
- * Can't do equivalent binary test - as can't do extends in binary.
- */
- public void testWeaveMessagesDeclareExtends() {
- if (debugTests) System.out.println("\ntestWeaveMessagesDeclareExtends: Building with Four.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Four.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("declare.extends",true);
- }
-
- /**
- * Weave "declare soft: type: pointcut" and check the weave messages that come out.
- */
- public void testWeaveMessagesDeclareSoft() {
- if (debugTests) System.out.println("\ntestWeaveMessagesDeclareSoft: Building with Five.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Five.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("declare.soft",true);
- }
-
- /**
- * Weave 'declare @type, @constructor, @method and @field' and check the weave messages that come out.
- */
- public void testWeaveMessagesDeclareAnnotation() {
- if (!LangUtil.is15VMOrGreater()) return; // annotation classes won't be about pre 15
- if (debugTests) System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Six.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Six.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("declare.annotation",true);
- }
-
- /**
- * Weave 'declare @type, @constructor, @method and @field' and check the weave messages don't come out without the -showWeaveInfo arg.
- */
- public void testWeaveMessagesDeclareAnnotationWeaveInfoOff() {
- if (debugTests) System.out.println("\ntestWeaveMessagesDeclareAnnotation: Building with Seven.lst");
- compilerAdapter = new CompilerAdapter();
- compilerAdapter.compile((String) openFile("Seven.lst").getAbsolutePath(),new BPM(),false);
- verifyWeavingMessages("declare.annotationNoWeaveInfo",true);
- }
-
-
- // BINARY WEAVING TESTS
-
- /**
- * Binary weave variant of the advice weaving test above - to check messages are ok for
- * binary weave. Unlike the source level weave, in this test we are using an aspect on
- * the aspectpath - which means it has already had its necessary parts woven - so the list
- * of weaving messages we expect is less.
- */
- public void testWeaveMessagesBinaryAdvice() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectAdvice.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("advice.binary",true);
- }
-
- public void testWeaveMessagesBinaryITD() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectITD.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("itd",false);
- }
-
-
- public void testWeaveMessagesBinaryDeclare() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryDeclare: Simple.jar + AspectDeclare.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectDeclare.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- verifyWeavingMessages("declare1",false);
- }
-
- /**
- * Weave "declare soft: type: pointcut" and check the weave messages that come out.
- */
- public void testWeaveMessagesBinaryDeclareSoft() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryDeclareSoft: Simple.jar + AspectDeclareSoft.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectDeclareSoft.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- verifyWeavingMessages("declare.soft.binary",true);
- }
-
- public void testWeaveMessagesBinaryAdviceInPackageFromJar() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryAdviceInPackageFromJar: Simple.jar + AspectInPackage.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectInPackage.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("advice.binary.package.jar",true);
- }
-
- public void testWeaveMessagesBinaryAdviceInPackage() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryAdviceInPackage: Simple.jar + AspectInPackage.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("pkg"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("advice.binary.package",true);
- }
-
- // BINARY WEAVING WHEN WE'VE LOST THE SOURCE POINTERS
-
- public void testWeaveMessagesBinaryAdviceNoDebugInfo() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryAdvice: Simple.jar + AspectAdvice.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple_nodebug.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectAdvice_nodebug.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("advice.binary.nodebug",true);
- }
-
- public void testWeaveMessagesBinaryITDNoDebugInfo() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryITD: Simple.jar + AspectITD.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple_nodebug.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectITD_nodebug.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- /*List l = */ideManager.getCompilationSourceLineTasks();
- verifyWeavingMessages("itd.nodebug",true);
- }
-
- public void testWeaveMessagesBinaryDeclareNoDebugInfo() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryDeclareNoDebugInfo: Simple.jar + AspectDeclare.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple_nodebug.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectDeclare_nodebug.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- verifyWeavingMessages("declare1.nodebug",true);
- }
-
- /**
- * Weave "declare soft: type: pointcut" and check the weave messages that come out.
- */
- public void testWeaveMessagesBinaryDeclareSoftNoDebugInfo() {
- if (debugTests) System.out.println("\ntestWeaveMessagesBinaryDeclareSoftNoDebugInfo: Simple.jar + AspectDeclareSoft.jar");
- Set inpath = new HashSet();
- inpath.add(openFile("Simple_nodebug.jar"));
- ideManager.getProjectProperties().setInpath(inpath);
- Set aspectpath = new HashSet();
- aspectpath.add(openFile("AspectDeclareSoft_nodebug.jar"));
- ideManager.getProjectProperties().setAspectPath(aspectpath);
- assertTrue("Build failed", doSynchronousBuild("Empty.lst"));
- verifyWeavingMessages("declare.soft.binary.nodebug",true);
- }
-
-
- private class BPM implements BuildProgressMonitor {
- public void start(String configFile) {}
-
- public void setProgressText(String text) {}
-
- public void setProgressBarVal(int newVal) { }
-
- public void incrementProgressBarVal() {}
-
- public void setProgressBarMax(int maxVal) { }
-
- public int getProgressBarMax() {
- return 0;
- }
-
- public void finish(boolean b) {}
-
- }
-
-
- public void verifyWeavingMessages(String testid,boolean source) {
- File expectedF = openFile(expectedResultsDir+File.separator+testid+".txt");
- if (regenerate && source) {
- // Create the file
- saveWeaveMessages(expectedF);
- } else {
- // Verify the file matches what we have
- compareWeaveMessages(expectedF);
- }
- }
-
- /**
- * Compare weaving messages with what is in the file
- */
- private void compareWeaveMessages(File f) {
- List fileContents = new ArrayList();
- BufferedReader fr;
- try {
- // Load the file in
- fr = new BufferedReader(new FileReader(f));
- String line = null;
- while ((line=fr.readLine())!=null) fileContents.add(line);
- List originalFileContents = new ArrayList();
- originalFileContents.addAll(fileContents);
-
- // See if the messages match
- int msgCount = 0;
- List l = ideManager.getCompilationSourceLineTasks();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- IMessage msg = ((NullIdeTaskListManager.SourceLineTask) iter.next()).message;
- if (debugTests) System.out.println("Looking at ["+msg+"]");
- if (msg.getKind().equals(IMessage.WEAVEINFO)) {
- if (!fileContents.contains(msg.getMessage())) {
- fail("Could not find message '"+msg.getMessage()+"' in the expected results. Expected results are:\n"+
- stringify(originalFileContents));
- } else {
- fileContents.remove(msg.getMessage());
- }
- msgCount++;
- }
- }
- assertTrue("Didn't get these expected messages: "+fileContents,fileContents.size()==0);
- if (debugTests) System.out.println("Successfully verified "+msgCount+" weaving messages");
- } catch (Exception e) {
- fail("Unexpected exception saving weaving messages:"+e);
- }
- }
-
- private String stringify(List l) {
- StringBuffer result = new StringBuffer();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- String str = (String) iter.next();
- result.append(str);result.append("\n");
- }
- return result.toString();
- }
-
- /**
- * Store the weaving messages in the specified file.
- */
- private void saveWeaveMessages(File f) {
- System.out.println("Saving weave messages into "+f.getName());
- FileWriter fw;
- try {
- fw = new FileWriter(f);
- List l = ideManager.getCompilationSourceLineTasks();
- for (Iterator iter = l.iterator(); iter.hasNext();) {
- IMessage msg = ((NullIdeTaskListManager.SourceLineTask) iter.next()).message;
- if (msg.getKind().equals(IMessage.WEAVEINFO)) {
- fw.write(msg.getMessage()+"\n");
- }
- }
- fw.close();
- } catch (Exception e) {
- fail("Unexpected exception saving weaving messages:"+e);
- }
- }
-
-
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java
deleted file mode 100644
index c6b5ee400..000000000
--- a/ajde/testsrc/org/aspectj/ajde/SimpleStructureModelTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-public class SimpleStructureModelTest extends AjdeTestCase {
-
- private String CONFIG_FILE_PATH = "test.lst";
-
- public SimpleStructureModelTest(String name) {
- super(name);
- }
-
- public void testModel() {
-
- }
-
- protected void setUp() throws Exception {
- super.setUp("SimpleStructureModelTest");
- doSynchronousBuild(CONFIG_FILE_PATH);
- }
-
-}
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
deleted file mode 100644
index 95a8a3ba0..000000000
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelRegressionTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import java.io.File;
-import java.util.List;
-
-import junit.framework.TestSuite;
-
-import org.aspectj.asm.*;
-
-public class StructureModelRegressionTest extends AjdeTestCase {
-
- public StructureModelRegressionTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(StructureModelRegressionTest.class);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(StructureModelRegressionTest.class);
- return result;
- }
-
- public void test() {
- String testLstFile = AjdeTests.testDataPath("StructureModelRegressionTest/example.lst");
- File f = new File(testLstFile);
- assertTrue(testLstFile, f.canRead());
- // TODO: enable when model is verified.
-// assertTrue("saved model: " + testLstFile, verifyAgainstSavedModel(testLstFile));
- }
-
- public boolean verifyAgainstSavedModel(String lstFile) {
- File modelFile = new File(genStructureModelExternFilePath(lstFile));
- IHierarchy model = getModelForFile(lstFile);
-
- if (modelFile.exists()) {
- Ajde.getDefault().getStructureModelManager().readStructureModel(lstFile);
- IHierarchy savedModel = Ajde.getDefault().getStructureModelManager().getHierarchy();
- // AMC This test will not pass as written until IProgramElement defines
- // equals. The equals loic is commented out in the IProgramElement
- // class - adding it back in could have unforeseen system-wide
- // consequences, so I've defined a IProgramElementsEqual( ) helper
- // method here instead.
- IProgramElement rootNode = model.getRoot();
- IProgramElement savedRootNode = savedModel.getRoot();
- return IProgramElementsEqual( rootNode, savedRootNode );
- } else {
- Ajde.getDefault().getStructureModelManager().writeStructureModel(lstFile);
- return true;
- }
- //return true;
- }
-
- private boolean IProgramElementsEqual( IProgramElement s1, IProgramElement s2 ) {
- final boolean equal = true;
- if ( s1 == s2 ) return equal;
- if ( null == s1 || null == s2 ) return !equal;
-
- if (!s1.getName( ).equals(s2.getName())) return !equal;
- if (!s1.getKind( ).equals(s2.getKind())) return !equal;
-
- // check child nodes
- List s1Kids = s1.getChildren();
- List s2Kids = s2.getChildren();
-
- if ( s1Kids != null && s2Kids != null ) {
- if (s1Kids == null || s2Kids == null) return !equal;
- if (s1Kids.size() != s2Kids.size() ) return !equal;
- for ( int k=0; k<s1Kids.size(); k++ ) {
- IProgramElement k1 = (IProgramElement) s1Kids.get(k);
- IProgramElement k2 = (IProgramElement) s2Kids.get(k);
- if (!IProgramElementsEqual( k1, k2 )) return !equal;
- }
- }
- return equal;
- }
-
- private IHierarchy getModelForFile(String lstFile) {
- Ajde.getDefault().getConfigurationManager().setActiveConfigFile(lstFile);
- Ajde.getDefault().getBuildManager().build(); // was buildStructure...
- while(!testerBuildListener.getBuildFinished()) {
- try {
- Thread.sleep(300);
- } catch (InterruptedException ie) { }
- }
- return Ajde.getDefault().getStructureModelManager().getHierarchy();
- }
-
- protected void setUp() throws Exception {
- super.setUp("StructureModelRegressionTest");
-// Ajde.getDefault().getStructureModelManager().setShouldSaveModel(false);
- }
-
- public void testModelExists() {
- assertTrue(Ajde.getDefault().getStructureModelManager().getHierarchy() != null);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
deleted file mode 100644
index 94c897158..000000000
--- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * AMC 21.01.2003 fixed for new source location in eclipse.org
- * ******************************************************************/
-
-package org.aspectj.ajde;
-
-import java.io.*;
-import java.util.Iterator;
-
-import junit.framework.TestSuite;
-
-import org.aspectj.asm.*;
-
-/**
- * @author Mik Kersten
- */
-public class StructureModelTest extends AjdeTestCase {
-
- // TODO-path
- private final String CONFIG_FILE_PATH = "../examples/figures-coverage/all.lst";
-
- public StructureModelTest(String name) {
- super(name);
- }
-
- public static void main(String[] args) {
- junit.swingui.TestRunner.run(StructureModelTest.class);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(StructureModelTest.class);
- return result;
- }
-
-// XXX this should work
-// public void testFieldInitializerCorrespondence() throws IOException {
-// File testFile = createFile("testdata/examples/figures-coverage/figures/Figure.java");
-// IProgramElement node = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
-// testFile.getCanonicalPath(), 28);
-// assertTrue("find result", node != null) ;
-// ProgramElementNode pNode = (ProgramElementNode)node;
-// ProgramElementNode foundNode = null;
-// final List list = pNode.getRelations();
-// assertNotNull("pNode.getRelations()", list);
-// for (Iterator it = list.iterator(); it.hasNext(); ) {
-// RelationNode relation = (RelationNode)it.next();
-//
-// if (relation.getRelation().equals(AdviceAssociation.FIELD_ACCESS_RELATION)) {
-// for (Iterator it2 = relation.getChildren().iterator(); it2.hasNext(); ) {
-// LinkNode linkNode = (LinkNode)it2.next();
-// if (linkNode.getProgramElementNode().getName().equals("this.currVal = 0")) {
-// foundNode = linkNode.getProgramElementNode();
-// }
-// }
-// }
-// }
-//
-// assertTrue("find associated node", foundNode != null) ;
-//
-// File pointFile = createFile("testdata/examples/figures-coverage/figures/primitives/planar/Point.java");
-// IProgramElement fieldNode = Ajde.getDefault().getStructureModelManager().getStructureModel().findNodeForSourceLine(
-// pointFile.getCanonicalPath(), 12);
-// assertTrue("find result", fieldNode != null);
-//
-// assertTrue("matches", foundNode.getParent() == fieldNode.getParent());
-// }
-
-
- public void testRootForSourceFile() throws IOException {
- File testFile = openFile("figures-coverage/figures/Figure.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
- testFile.getAbsolutePath());
- assertTrue("find result", node != null) ;
- IProgramElement pNode = (IProgramElement)node;
- String child = ((IProgramElement)pNode.getChildren().get(1)).getName();
- assertTrue("expected Figure got child " + child, child.equals("Figure"));
- }
-
- public void testPointcutName() throws IOException {
- File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceFile(
- testFile.getAbsolutePath());
- assertTrue("find result", node != null) ;
- IProgramElement pNode = (IProgramElement)((IProgramElement)node).getChildren().get(2);
- IProgramElement pointcut = (IProgramElement)pNode.getChildren().get(0);
- assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT));
- assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()"));
- }
-
- public void testFileNodeFind() throws IOException {
- File testFile = openFile("figures-coverage/figures/Main.java");
-
-// System.err.println(((IProgramElement)((IProgramElement)Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().getChildren().get(0)).getChildren().get(3)).getSourceLocation().getSourceFile().getAbsolutePath());
-// System.err.println(testFile.getAbsolutePath());
-
- IProgramElement node = Ajde.getDefault().getStructureModelManager().getHierarchy().findElementForSourceLine(
- testFile.getAbsolutePath(), 1);
- assertTrue("find result", node != null) ;
- assertEquals("find result has children", 3, node.getChildren().size()) ;
- IProgramElement pNode = (IProgramElement)node;
- assertTrue("found node: " + pNode.getName(), pNode.getKind().equals(IProgramElement.Kind.FILE_JAVA));
- }
-
- /**
- * @todo add negative test to make sure things that aren't runnable aren't annotated
- */
- public void testMainClassNodeInfo() throws IOException {
- IHierarchy model = Ajde.getDefault().getStructureModelManager().getHierarchy();
- assertTrue("model exists", model != null);
- assertTrue("root exists", model.getRoot() != null);
- File testFile = openFile("figures-coverage/figures/Main.java");
- IProgramElement node = model.findElementForSourceLine(testFile.getAbsolutePath(), 11);
- assertTrue("find result", node != null);
- IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
- if (null == pNode) {
- assertTrue("null parent of " + node, false);
- }
- assertTrue("found node: " + pNode.getName(), pNode.isRunnable());
- }
-
- /**
- * Integrity could be checked somewhere in the API.
- */
- public void testModelIntegrity() {
- IProgramElement modelRoot = Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot();
- assertTrue("root exists", modelRoot != null);
-
- try {
- testModelIntegrityHelper(modelRoot);
- } catch (Exception e) {
- assertTrue(e.toString(), false);
- }
- }
-
- private void testModelIntegrityHelper(IProgramElement node) throws Exception {
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- IProgramElement child = (IProgramElement)it.next();
- if (node == child.getParent()) {
- testModelIntegrityHelper(child);
- } else {
- throw new Exception("parent-child check failed for child: " + child.toString());
- }
- }
- }
-
- public void testNoChildIsNull() {
- HierarchyWalker walker = new HierarchyWalker() {
- public void preProcess(IProgramElement node) {
- if (node.getChildren() == null) return;
- for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
- if (it.next() == null) throw new NullPointerException("null child on node: " + node.getName());
- }
- }
- };
- Ajde.getDefault().getStructureModelManager().getHierarchy().getRoot().walk(walker);
- }
-
- protected void setUp() throws Exception {
- super.setUp("examples");
- doSynchronousBuild(CONFIG_FILE_PATH);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}
-
diff --git a/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java b/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java
deleted file mode 100644
index 57d1a92b9..000000000
--- a/ajde/testsrc/org/aspectj/ajde/TestBuildListener.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-
-public class TestBuildListener implements BuildListener {
-
- public boolean buildFinished = false;
- public boolean buildSucceeded = false;
-
- public void reset() {
- buildFinished = false;
- }
-
- public void compileStarted(String buildConfigFile) { }
-
- public void compileFinished(String buildConfigFile, int buildTime, boolean succeeded, boolean warnings) {
-// int timeInSeconds = buildTime/1000;
- buildSucceeded = succeeded;
- buildFinished = true;
- }
-
- public void compileAborted(String buildConfigFile, String message) { }
-
- public boolean getBuildFinished() {
- return buildFinished;
- }
-
- public boolean getBuildSucceeded() {
- return buildSucceeded;
- }
-}
-
-
diff --git a/ajde/testsrc/org/aspectj/ajde/VersionTest.java b/ajde/testsrc/org/aspectj/ajde/VersionTest.java
deleted file mode 100644
index b23f01c5d..000000000
--- a/ajde/testsrc/org/aspectj/ajde/VersionTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/* *******************************************************************
- * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
- * 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://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
-package org.aspectj.ajde;
-
-import junit.framework.TestSuite;
-
-import org.aspectj.bridge.Version;
-
-/**
- * @author Mik Kersten
- */
-public class VersionTest extends AjdeTestCase {
-
- public VersionTest(String name) {
- super(name);
- }
-
- public static TestSuite suite() {
- TestSuite result = new TestSuite();
- result.addTestSuite(VersionTest.class);
- return result;
- }
-
- public void testVersionMatch() {
- String ajdeVersion = Ajde.getDefault().getVersion();
- String compilerVersion = Version.text;
- assertTrue("version check", ajdeVersion.equals(compilerVersion));
- }
-
- protected void setUp() throws Exception {
- super.setUp("");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-}