From: Andy Clement Date: Wed, 30 Jan 2019 00:59:46 +0000 (-0800) Subject: mavenizing ajde - done X-Git-Tag: V1_9_3RC1~76 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e8436048b1667bc2d1d7c9a48070fb73a281daf9;p=aspectj.git mavenizing ajde - done --- diff --git a/ajde/pom.xml b/ajde/pom.xml index aecd6318f..8f34c729d 100644 --- a/ajde/pom.xml +++ b/ajde/pom.xml @@ -35,6 +35,13 @@ org.aspectj.ajdt.core ${project.version} + + org.aspectj + org.aspectj.ajdt.core + ${project.version} + test-jar + test + org.aspectj org.eclipse.jdt.core diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTest.java b/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTest.java new file mode 100644 index 000000000..1e3605db2 --- /dev/null +++ b/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTest.java @@ -0,0 +1,76 @@ +/******************************************************************** + * Copyright (c) 2007 Contributors. All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: IBM Corporation - initial API and implementation + * Helen Hawkins - initial version (bug 148190) + *******************************************************************/ +package org.aspectj.ajde; + +import org.aspectj.ajde.core.AjCompiler; + +/** + * Tests ajde's management of the AjCompiler instances. Expect + * there to be a different one for each .lst file and for ajde + * to only remember the compiler for the last .lst file. + */ +public class AjdeCompilerTest extends AjdeTestCase { + + protected void setUp() throws Exception { + super.setUp(); + initialiseProject("LstBuildConfigManagerTest"); + } + + // Expect to get a different compiler instance for each + // different config file + public void testGetSameAjCompilerForSameConfigFiles() { + AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); + AjCompiler c2 = getCompilerForConfigFileWithName("bad-injar.lst"); + assertEquals("expected the same AjCompiler instance to be returned" + + " for the same configFile but found different ones", c1, c2); + } + + // Expect to get a different compiler instance for each + // different config file + public void testGetDifferentAjCompilerForDifferentConfigFiles() { + AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); + AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); + assertNotSame("expected different AjCompiler instances to be returned" + + " for different configFiles but found the smae", c1, c2); + } + + // want to keep the same setting regardless of the configFile + // being built - therefore the same instance should be passed + // from one AjCompiler instance to the next + public void testSameCompilerConfigForDifferentConfigFiles() { + AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); + AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); + assertEquals("expected the same compilerConfig instance to be associated" + + " with the different AjCompiler's however found different ones", + c1.getCompilerConfiguration(), c2.getCompilerConfiguration()); + } + + // want to have a different messageHandler instance for the different + // config files - or we can just reset?!?! Resetting would be easier + public void testSameMessageHandlerForDifferentConfigFiles() { + AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); + AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); + assertEquals("expected the same messageHandler instance to be associated" + + " with the different AjCompiler's however found different ones", + c1.getMessageHandler(), c2.getMessageHandler()); + } + + // can have the same buildProgressMonitor for the different configFiles + // because it holds no state + public void testSameBuildProgressMonitorForDifferentConfigFiles() { + AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); + AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); + assertEquals("expected the same buildProgressMonitor instance to be associated" + + " with the different AjCompiler's however found different ones", + c1.getBuildProgressMonitor(), c2.getBuildProgressMonitor()); + } + +} diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTests.java b/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTests.java deleted file mode 100644 index 0d9d6d68d..000000000 --- a/ajde/src/test/java/org/aspectj/ajde/AjdeCompilerTests.java +++ /dev/null @@ -1,76 +0,0 @@ -/******************************************************************** - * Copyright (c) 2007 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: IBM Corporation - initial API and implementation - * Helen Hawkins - initial version (bug 148190) - *******************************************************************/ -package org.aspectj.ajde; - -import org.aspectj.ajde.core.AjCompiler; - -/** - * Tests ajde's management of the AjCompiler instances. Expect - * there to be a different one for each .lst file and for ajde - * to only remember the compiler for the last .lst file. - */ -public class AjdeCompilerTests extends AjdeTestCase { - - protected void setUp() throws Exception { - super.setUp(); - initialiseProject("LstBuildConfigManagerTest"); - } - - // Expect to get a different compiler instance for each - // different config file - public void testGetSameAjCompilerForSameConfigFiles() { - AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); - AjCompiler c2 = getCompilerForConfigFileWithName("bad-injar.lst"); - assertEquals("expected the same AjCompiler instance to be returned" + - " for the same configFile but found different ones", c1, c2); - } - - // Expect to get a different compiler instance for each - // different config file - public void testGetDifferentAjCompilerForDifferentConfigFiles() { - AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); - AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); - assertNotSame("expected different AjCompiler instances to be returned" + - " for different configFiles but found the smae", c1, c2); - } - - // want to keep the same setting regardless of the configFile - // being built - therefore the same instance should be passed - // from one AjCompiler instance to the next - public void testSameCompilerConfigForDifferentConfigFiles() { - AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); - AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); - assertEquals("expected the same compilerConfig instance to be associated" + - " with the different AjCompiler's however found different ones", - c1.getCompilerConfiguration(), c2.getCompilerConfiguration()); - } - - // want to have a different messageHandler instance for the different - // config files - or we can just reset?!?! Resetting would be easier - public void testSameMessageHandlerForDifferentConfigFiles() { - AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); - AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); - assertEquals("expected the same messageHandler instance to be associated" + - " with the different AjCompiler's however found different ones", - c1.getMessageHandler(), c2.getMessageHandler()); - } - - // can have the same buildProgressMonitor for the different configFiles - // because it holds no state - public void testSameBuildProgressMonitorForDifferentConfigFiles() { - AjCompiler c1 = getCompilerForConfigFileWithName("bad-injar.lst"); - AjCompiler c2 = getCompilerForConfigFileWithName("dir-entry.lst"); - assertEquals("expected the same buildProgressMonitor instance to be associated" + - " with the different AjCompiler's however found different ones", - c1.getBuildProgressMonitor(), c2.getBuildProgressMonitor()); - } - -} diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeModuleTests.java b/ajde/src/test/java/org/aspectj/ajde/AjdeModuleTests.java deleted file mode 100644 index b6a1daa55..000000000 --- a/ajde/src/test/java/org/aspectj/ajde/AjdeModuleTests.java +++ /dev/null @@ -1,27 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 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.*; - -public class AjdeModuleTests extends TestCase { - - public static TestSuite suite() { - TestSuite suite = new TestSuite(AjdeModuleTests.class.getName()); - suite.addTest(org.aspectj.ajde.AjdeTests.suite()); - return suite; - } - - public AjdeModuleTests(String name) { super(name); } - -} diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java b/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java index 5f2b2f2f7..3ff7712eb 100644 --- a/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java +++ b/ajde/src/test/java/org/aspectj/ajde/AjdeTestCase.java @@ -27,9 +27,10 @@ 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.testing.util.TestUtil; import org.aspectj.tools.ajc.Ajc; -public class AjdeTestCase extends TestCase { +public abstract class AjdeTestCase extends TestCase { public final static String testdataSrcDir = "../ajde/testdata"; protected static File sandboxDir; @@ -39,7 +40,7 @@ public class AjdeTestCase extends TestCase { protected void setUp() throws Exception { super.setUp(); // Create a sandbox in which to work - sandboxDir = Ajc.createEmptySandbox(); + sandboxDir = TestUtil.createEmptySandbox(); // AMC - added this next line as a temporary workaround for // listener leakage in AsmManager induced by the Ajde test suite. // Ajde.getDefault().getModel().removeAllListeners(); diff --git a/ajde/src/test/java/org/aspectj/ajde/AjdeTests.java b/ajde/src/test/java/org/aspectj/ajde/AjdeTests.java deleted file mode 100644 index c48b9d2fe..000000000 --- a/ajde/src/test/java/org/aspectj/ajde/AjdeTests.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 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 - * Helen Hawkins updated for bug 148190 - * ******************************************************************/ -package org.aspectj.ajde; - -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.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class AjdeTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(AjdeTests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(SymbolFileGenerationTest.class); - suite.addTestSuite(ExtensionTests.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; - } - - public AjdeTests(String name) { super(name); } - -} diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java new file mode 100644 index 000000000..43d75f8d4 --- /dev/null +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -0,0 +1,140 @@ +/******************************************************************************* + * 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: + * Andy Clement - initial implementation + *******************************************************************************/ +package org.aspectj.ajde; + +import java.io.File; +import java.util.Iterator; +import java.util.List; + +import org.aspectj.asm.AsmManager; +import org.aspectj.asm.IProgramElement; +import org.aspectj.bridge.IMessage; +import org.aspectj.org.eclipse.jdt.core.compiler.IProblem; +import org.aspectj.tools.ajc.AjcTestCase; +import org.aspectj.tools.ajc.CompilationResult; + +/** + * Tests the 'extensions' to AJDE: 1) ID is now available on messages to allow you to see what 'kind' of message it is - this + * activates quick fixes/etc in Eclipse. + */ +public class ExtensionTest extends AjcTestCase { + + public static final String PROJECT_DIR = "extensions"; + private static final boolean debugTests = false; + private File baseDir; + + protected void setUp() throws Exception { + super.setUp(); + // TODO-path + baseDir = new File("../ajde/testdata", PROJECT_DIR); + } + + /** + * Aim: Check that the ID of certain message kinds are correct + * + * ajc -warn:unusedImport UnusedImport.java + * + * Expected result is that id matches IProblem.UnusedImport + */ + public void testMessageID() { + String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" }; + CompilationResult result = ajc(baseDir, args); + List l = result.getWarningMessages(); + IMessage m = ((IMessage) l.get(0)); + assertTrue("Expected ID of message to be " + IProblem.UnusedImport + " (UnusedImport) but found an ID of " + m.getID(), + m.getID() == IProblem.UnusedImport); + } + + public void testInnerClassesInASM() { + String[] args = new String[] { "InnerClasses.java", "-emacssym", "-Xset:minimalModel=false" }; + CompilationResult result = ajc(baseDir, args); + /* List l = */result.getWarningMessages(); + /* Properties p = */AsmManager.lastActiveStructureModel.summarizeModel().getProperties(); + if (debugTests) + System.out.println("Structure Model for InnerClasses.java:"); + walkit(AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); + foundNode = null; + findChild("main", AsmManager.lastActiveStructureModel.getHierarchy().getRoot()); + assertTrue("Should have found node 'main' in the model", foundNode != null); + IProgramElement runnableChild = getChild(foundNode, "new Runnable() {..}"); + assertTrue("'main' should have a child 'new Runnable() {..}'", runnableChild != null); + assertTrue("'new Runnable() {..}' should have a 'run' child", getChild(runnableChild, "run") != null); + + /* + * Left hand side is before the fix, right hand side is after: InnerClasses.java import declarations InnerClasses A A + * method method 1 new Runnable() {..} run run main main 2 new Runnable() {..} run run 3 new Object() {..} toString toString + * 4 new Runnable run run + */ + + } + + private IProgramElement getChild(IProgramElement parent, String s) { + List kids = parent.getChildren(); + for (Iterator iter = kids.iterator(); iter.hasNext();) { + IProgramElement element = (IProgramElement) iter.next(); + if (element.getName().indexOf(s) != -1) + return element; + } + return null; + } + + private IProgramElement foundNode = null; + + private void findChild(String s, IProgramElement ipe) { + if (ipe == null) + return; + if (ipe.getName().indexOf(s) != -1) { + foundNode = ipe; + return; + } + if (ipe.getChildren() != null) { + List kids = ipe.getChildren(); + for (Iterator iter = kids.iterator(); iter.hasNext();) { + IProgramElement element = (IProgramElement) iter.next(); + findChild(s, element); + } + } + } + + public void walkit(IProgramElement ipe, int indent) { + if (ipe != null) { + if (debugTests) + for (int i = 0; i < indent; i++) + System.out.print(" "); + if (debugTests) + System.out.println(ipe.toLabelString());// getName()); + if (ipe.getChildren() != null) { + List kids = ipe.getChildren(); + for (Iterator iter = kids.iterator(); iter.hasNext();) { + IProgramElement element = (IProgramElement) iter.next(); + walkit(element, indent + 2); + } + } + } + } + + /** + * Aim: Check that the start/end of certain warnings are correct + * + * ajc -warn:unusedImport UnusedImport.java + * + * Expected result is first warning message has start=7 end=20 + */ + public void testMessageSourceStartEnd() { + String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" }; + CompilationResult result = ajc(baseDir, args); + List l = result.getWarningMessages(); + IMessage m = ((IMessage) l.get(0)); + assertTrue("Expected source start to be 7 but was " + m.getSourceStart(), m.getSourceStart() == 7); + assertTrue("Expected source end to be 20 but was " + m.getSourceEnd(), m.getSourceEnd() == 20); + } + +} diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTests.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTests.java deleted file mode 100644 index 0a445ba8b..000000000 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTests.java +++ /dev/null @@ -1,140 +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: - * Andy Clement - initial implementation - *******************************************************************************/ -package org.aspectj.ajde; - -import java.io.File; -import java.util.Iterator; -import java.util.List; - -import org.aspectj.asm.AsmManager; -import org.aspectj.asm.IProgramElement; -import org.aspectj.bridge.IMessage; -import org.aspectj.org.eclipse.jdt.core.compiler.IProblem; -import org.aspectj.tools.ajc.AjcTestCase; -import org.aspectj.tools.ajc.CompilationResult; - -/** - * Tests the 'extensions' to AJDE: 1) ID is now available on messages to allow you to see what 'kind' of message it is - this - * activates quick fixes/etc in Eclipse. - */ -public class ExtensionTests extends AjcTestCase { - - public static final String PROJECT_DIR = "extensions"; - private static final boolean debugTests = false; - private File baseDir; - - protected void setUp() throws Exception { - super.setUp(); - // TODO-path - baseDir = new File("../ajde/testdata", PROJECT_DIR); - } - - /** - * Aim: Check that the ID of certain message kinds are correct - * - * ajc -warn:unusedImport UnusedImport.java - * - * Expected result is that id matches IProblem.UnusedImport - */ - public void testMessageID() { - String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" }; - CompilationResult result = ajc(baseDir, args); - List l = result.getWarningMessages(); - IMessage m = ((IMessage) l.get(0)); - assertTrue("Expected ID of message to be " + IProblem.UnusedImport + " (UnusedImport) but found an ID of " + m.getID(), - m.getID() == IProblem.UnusedImport); - } - - public void testInnerClassesInASM() { - String[] args = new String[] { "InnerClasses.java", "-emacssym", "-Xset:minimalModel=false" }; - CompilationResult result = ajc(baseDir, args); - /* List l = */result.getWarningMessages(); - /* Properties p = */AsmManager.lastActiveStructureModel.summarizeModel().getProperties(); - if (debugTests) - System.out.println("Structure Model for InnerClasses.java:"); - walkit(AsmManager.lastActiveStructureModel.getHierarchy().getRoot(), 0); - foundNode = null; - findChild("main", AsmManager.lastActiveStructureModel.getHierarchy().getRoot()); - assertTrue("Should have found node 'main' in the model", foundNode != null); - IProgramElement runnableChild = getChild(foundNode, "new Runnable() {..}"); - assertTrue("'main' should have a child 'new Runnable() {..}'", runnableChild != null); - assertTrue("'new Runnable() {..}' should have a 'run' child", getChild(runnableChild, "run") != null); - - /* - * Left hand side is before the fix, right hand side is after: InnerClasses.java import declarations InnerClasses A A - * method method 1 new Runnable() {..} run run main main 2 new Runnable() {..} run run 3 new Object() {..} toString toString - * 4 new Runnable run run - */ - - } - - private IProgramElement getChild(IProgramElement parent, String s) { - List kids = parent.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); - if (element.getName().indexOf(s) != -1) - return element; - } - return null; - } - - private IProgramElement foundNode = null; - - private void findChild(String s, IProgramElement ipe) { - if (ipe == null) - return; - if (ipe.getName().indexOf(s) != -1) { - foundNode = ipe; - return; - } - if (ipe.getChildren() != null) { - List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); - findChild(s, element); - } - } - } - - public void walkit(IProgramElement ipe, int indent) { - if (ipe != null) { - if (debugTests) - for (int i = 0; i < indent; i++) - System.out.print(" "); - if (debugTests) - System.out.println(ipe.toLabelString());// getName()); - if (ipe.getChildren() != null) { - List kids = ipe.getChildren(); - for (Iterator iter = kids.iterator(); iter.hasNext();) { - IProgramElement element = (IProgramElement) iter.next(); - walkit(element, indent + 2); - } - } - } - } - - /** - * Aim: Check that the start/end of certain warnings are correct - * - * ajc -warn:unusedImport UnusedImport.java - * - * Expected result is first warning message has start=7 end=20 - */ - public void testMessageSourceStartEnd() { - String[] args = new String[] { "UnusedImport.java", "-warn:unusedImport" }; - CompilationResult result = ajc(baseDir, args); - List l = result.getWarningMessages(); - IMessage m = ((IMessage) l.get(0)); - assertTrue("Expected source start to be 7 but was " + m.getSourceStart(), m.getSourceStart() == 7); - assertTrue("Expected source end to be 20 but was " + m.getSourceEnd(), m.getSourceEnd() == 20); - } - -} diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java index 69e5ea9d9..04a73d2f4 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestCompilerConfiguration.java @@ -23,7 +23,7 @@ import java.util.Set; import org.aspectj.ajde.core.ICompilerConfiguration; import org.aspectj.ajde.core.IOutputLocationManager; import org.aspectj.ajde.core.JavaOptions; -import org.aspectj.tools.ajc.AjcTests; +import org.aspectj.testing.util.TestUtil; import org.aspectj.util.FileUtil; import org.aspectj.util.LangUtil; @@ -66,7 +66,7 @@ public class TestCompilerConfiguration implements ICompilerConfiguration { public String getClasspath() { String cp = projectPath + File.pathSeparator + System.getProperty("sun.boot.class.path") + File.pathSeparator - + AjcTests.aspectjrtClasspath(); + + TestUtil.aspectjrtClasspath(); if (LangUtil.is19VMOrGreater()) { cp = LangUtil.getJrtFsFilePath()+File.pathSeparator+cp; }