<artifactId>org.aspectj.ajdt.core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+
+ <!-- enables easy dependency on tools.jar -->
+ <groupId>com.github.olivergondza</groupId>
+ <artifactId>maven-jdk-tools-wrapper</artifactId>
+ <version>0.1</version>
+</dependency>
+
+ <dependency>
+ <groupId>asm</groupId>
+ <artifactId>asm</artifactId>
+ <version>1.0</version>
+ <scope>system</scope>
+ <systemPath>${project.basedir}/../lib/asm/asm-7.0-beta.renamed.jar</systemPath>
+ </dependency>
</dependencies>
</project>
+++ /dev/null
-package org.aspectj.tools.ajdoc;
-/* *******************************************************************
- * 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
- * ******************************************************************/
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-
-/**
- * @author Mik Kersten
- */
-public class AjdocModuleTests {
- public static Test suite() {
- TestSuite suite = new TestSuite(AjdocModuleTests.class.getName());
- suite.addTest(AjdocTests.suite());
- return suite;
- }
-}
* @return List of those requiredStrings not found
* @throws Exception
*/
- public static List /*String*/ getMissingStringsInSection(File htmlFile,
+ public static List<String> getMissingStringsInSection(File htmlFile,
String[] requiredStrings, String sectionHeader) throws Exception {
- List missingStrings = new ArrayList();
+ List<String> missingStrings = new ArrayList<String>();
for (int i = 0; i < requiredStrings.length; i++) {
String string = requiredStrings[i];
if (!containsStringWithinSection(htmlFile,string,sectionHeader)) {
import java.util.Iterator;
import java.util.List;
-import org.aspectj.tools.ajc.Ajc;
+import org.aspectj.testing.util.TestUtil;
import org.aspectj.util.LangUtil;
import junit.framework.AssertionFailedError;
* This class is the super class of all Ajdoc tests. It creates a sandbox directory and provides utility methods for copying over
* the test projects and running the ajdoc command
*/
-public class AjdocTestCase extends TestCase {
+public abstract class AjdocTestCase extends TestCase {
public final static String testdataSrcDir = "../ajdoc/testdata";
protected static File sandboxDir;
docOutdir = null;
projectDir = null;
// Create a sandbox in which to work
- sandboxDir = Ajc.createEmptySandbox();
+ sandboxDir = TestUtil.createEmptySandbox();
// create the ajdocworkdingdir in the sandbox
Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
}
import junit.framework.TestCase;
import junit.framework.TestSuite;
-public class AjdocTests extends TestCase {
+public class AjdocTests {//extends TestCase {
public static File ASPECTJRT_PATH;
"../runtime/bin"};
ASPECTJRT_PATH = FileUtil.getBestFile(paths);
}
-
- public static Test suite() {
- TestSuite suite = new TestSuite(AjdocTests.class.getName());
- //$JUnit-BEGIN$
- suite.addTestSuite(DeclareFormsTest.class);
- suite.addTestSuite(SpacewarTestCase.class);
- suite.addTestSuite(PatternsTestCase.class);
- suite.addTestSuite(CoverageTestCase.class);
- suite.addTestSuite(ITDTest.class);
- suite.addTestSuite(FullyQualifiedArgumentTest.class);
- suite.addTestSuite(EnumTest.class);
- suite.addTestSuite(PointcutVisibilityTest.class);
- suite.addTestSuite(ExecutionTestCase.class);
- suite.addTestSuite(BugTests.class);
- //$JUnit-END$
- return suite;
- }
+//
+// public static Test suite() {
+// TestSuite suite = new TestSuite(AjdocTests.class.getName());
+// //$JUnit-BEGIN$
+// suite.addTestSuite(DeclareFormsTest.class);
+// suite.addTestSuite(SpacewarTestCase.class);
+// suite.addTestSuite(PatternsTestCase.class);
+// suite.addTestSuite(CoverageTestCase.class);
+// suite.addTestSuite(ITDTest.class);
+// suite.addTestSuite(FullyQualifiedArgumentTest.class);
+// suite.addTestSuite(EnumTest.class);
+// suite.addTestSuite(PointcutVisibilityTest.class);
+// suite.addTestSuite(ExecutionTestCase.class);
+// suite.addTestSuite(BugTest.class);
+// //$JUnit-END$
+// return suite;
+// }
}
--- /dev/null
+/********************************************************************
+ * Copyright (c) 2006 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - initial version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BugTest extends AjdocTestCase {
+
+ public void testPr160302() throws Exception {
+ initialiseProject("pr160302");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertFalse("expected all decorating tags to be removed but found that they" +
+ " weren't",AjdocOutputChecker.containsString(html, Config.DECL_ID_STRING));
+ }
+
+ /**
+ * Passing the "-Xlint:error" option through to the compiler should
+ * cause the ajc build to fail because the advice did not match
+ */
+ public void testPr148906_1() {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
+ String[] ajOptions = {new String("-Xlint:error")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected ajc to fail but it did not", Main.hasAborted());
+ assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
+ " failed instead with " + Main.getErrors()[0].getMessage(),
+ "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
+ Main.getErrors()[0].getMessage());
+ }
+
+ /**
+ * Passing the "-Xlintfile" option through to the compiler should
+ * cause the ajc build to fail because the advice did not match
+ */
+ public void testPr148906_2() {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
+ String[] ajOptions = {new String("-Xlintfile"), new String(getAbsoluteProjectDir() + File.separator + "Xlint.properties")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected ajc to fail but it did not", Main.hasAborted());
+ assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
+ " failed instead with " + Main.getErrors()[0].getMessage(),
+ "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
+ Main.getErrors()[0].getMessage());
+ }
+
+ /**
+ * Passing the -aspectpath option though to the compiler should
+ * result in relationships being displayed
+ */
+ public void testPr148906_3() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
+ runAjdoc(files,"1.6",ajOptions);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertTrue("expected to find 'Advised by' in the html output but did " +
+ " not",AjdocOutputChecker.containsString(html,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
+ }
+
+ /**
+ * Passing an option starting with "-" that doesn't require a second entry
+ * should mean everything is correctly given to the compiler. For example:
+ * '-outxml -aspectpath <file>" should mean both '-outxml' and the aspectpath
+ * options are given correctly.
+ */
+ public void testPr148906_4() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-outxml"),new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
+ runAjdoc(files,"1.6",ajOptions);
+ assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
+ File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
+ if (!html.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
+ }
+ assertTrue("expected to find 'Advised by' in the html output but did " +
+ " not",AjdocOutputChecker.containsString(html,
+ HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
+ File aopFile = new File(getAbsolutePathOutdir() + File.separator
+ + "META-INF" + File.separator + "aop-ajc.xml");
+ assertTrue("couldn't find " + getAbsolutePathOutdir() + File.separator
+ + "META-INF" + File.separator + "aop-ajc.xml" ,
+ aopFile.exists());
+ }
+
+ /**
+ * Passing bogus option to ajc
+ */
+ public void testPr148906_5() throws Exception {
+ initialiseProject("pr148906");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ String[] ajOptions = {new String("-bogus")};
+ runAjdoc(files,"1.5",ajOptions);
+ assertTrue("expected build of project to abort",Main.hasAborted());
+ }
+
+ /**
+ * Not passing any files to ajdoc should result in both the ajdoc
+ * and ajc usage messages
+ */
+ public void testPr148906_6() throws Exception {
+ initialiseProject("pr148906");
+ List options = new ArrayList();
+ options.add("-verbose");
+ runAjdoc(options);
+ assertTrue("expected the ajdoc usage message to be reported",Main.hasShownAjdocUsageMessage());
+ assertTrue("expected build of project to abort",Main.hasAborted());
+ }
+
+ /**
+ * javadoc comments should still appear even if preceded by
+ * 'normal' comments
+ */
+ public void testPr164356() throws Exception {
+ initialiseProject("pr164356");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() +
+ " (ajc aborted: " + Main.hasAborted() + ")");
+ }
+ String foo = "description of foo";
+ String bar = "description of bar";
+ String goo = "description of goo";
+ String bas = "description of bas";
+ assertTrue("expected method description 'description of foo' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, foo));
+ assertTrue("expected method description 'description of bar' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, bar));
+ assertFalse("didn't expect method description 'description of goo' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, goo));
+ assertTrue("expected method description 'description of bas' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, bas));
+ }
+
+ /**
+ * Comments for a constructor should be included in the ajdoc output
+ */
+ public void testPr164340() throws Exception {
+ initialiseProject("pr164340");
+ File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
+ runAjdoc(files);
+ File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
+ if (!htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() +
+ " (ajc aborted: " + Main.hasAborted() + ")");
+ }
+ String methodDesc = "This is method foo";
+ String constDesc = "This is a constructor";
+ assertTrue("expected method description 'This is method foo' to appear" +
+ " in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, methodDesc));
+ assertTrue("expected constructor description 'This is a constructor' to " +
+ "appear in ajdoc output but it did not",
+ AjdocOutputChecker.containsString(htmlFile, constDesc));
+ }
+}
+++ /dev/null
-/********************************************************************
- * Copyright (c) 2006 Contributors. All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- * Helen Hawkins - initial version
- *******************************************************************/
-package org.aspectj.tools.ajdoc;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-public class BugTests extends AjdocTestCase {
-
- public void testPr160302() throws Exception {
- initialiseProject("pr160302");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertFalse("expected all decorating tags to be removed but found that they" +
- " weren't",AjdocOutputChecker.containsString(html, Config.DECL_ID_STRING));
- }
-
- /**
- * Passing the "-Xlint:error" option through to the compiler should
- * cause the ajc build to fail because the advice did not match
- */
- public void testPr148906_1() {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
- String[] ajOptions = {new String("-Xlint:error")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected ajc to fail but it did not", Main.hasAborted());
- assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
- " failed instead with " + Main.getErrors()[0].getMessage(),
- "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
- Main.getErrors()[0].getMessage());
- }
-
- /**
- * Passing the "-Xlintfile" option through to the compiler should
- * cause the ajc build to fail because the advice did not match
- */
- public void testPr148906_2() {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/AdviceDidNotMatch.aj")};
- String[] ajOptions = {new String("-Xlintfile"), new String(getAbsoluteProjectDir() + File.separator + "Xlint.properties")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected ajc to fail but it did not", Main.hasAborted());
- assertEquals("expected ajc to fail with an adviceDidNotMatch error but it" +
- " failed instead with " + Main.getErrors()[0].getMessage(),
- "advice defined in AdviceDidNotMatch has not been applied [Xlint:adviceDidNotMatch]",
- Main.getErrors()[0].getMessage());
- }
-
- /**
- * Passing the -aspectpath option though to the compiler should
- * result in relationships being displayed
- */
- public void testPr148906_3() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertTrue("expected to find 'Advised by' in the html output but did " +
- " not",AjdocOutputChecker.containsString(html,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
- }
-
- /**
- * Passing an option starting with "-" that doesn't require a second entry
- * should mean everything is correctly given to the compiler. For example:
- * '-outxml -aspectpath <file>" should mean both '-outxml' and the aspectpath
- * options are given correctly.
- */
- public void testPr148906_4() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-outxml"),new String("-aspectpath"), new String(getAbsoluteProjectDir() + File.separator + "simple.jar")};
- runAjdoc(files,"1.6",ajOptions);
- assertFalse("expected clean build of project but found that build aborted",Main.hasAborted());
- File html = new File(getAbsolutePathOutdir() + File.separator + "C.html");
- if (!html.exists()) {
- fail("couldn't find " + getAbsolutePathOutdir() + File.separator + "C.html - were there javadoc/compilation errors?");
- }
- assertTrue("expected to find 'Advised by' in the html output but did " +
- " not",AjdocOutputChecker.containsString(html,
- HtmlDecorator.HtmlRelationshipKind.ADVISED_BY.getName()));
- File aopFile = new File(getAbsolutePathOutdir() + File.separator
- + "META-INF" + File.separator + "aop-ajc.xml");
- assertTrue("couldn't find " + getAbsolutePathOutdir() + File.separator
- + "META-INF" + File.separator + "aop-ajc.xml" ,
- aopFile.exists());
- }
-
- /**
- * Passing bogus option to ajc
- */
- public void testPr148906_5() throws Exception {
- initialiseProject("pr148906");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- String[] ajOptions = {new String("-bogus")};
- runAjdoc(files,"1.5",ajOptions);
- assertTrue("expected build of project to abort",Main.hasAborted());
- }
-
- /**
- * Not passing any files to ajdoc should result in both the ajdoc
- * and ajc usage messages
- */
- public void testPr148906_6() throws Exception {
- initialiseProject("pr148906");
- List options = new ArrayList();
- options.add("-verbose");
- runAjdoc(options);
- assertTrue("expected the ajdoc usage message to be reported",Main.hasShownAjdocUsageMessage());
- assertTrue("expected build of project to abort",Main.hasAborted());
- }
-
- /**
- * javadoc comments should still appear even if preceded by
- * 'normal' comments
- */
- public void testPr164356() throws Exception {
- initialiseProject("pr164356");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() +
- " (ajc aborted: " + Main.hasAborted() + ")");
- }
- String foo = "description of foo";
- String bar = "description of bar";
- String goo = "description of goo";
- String bas = "description of bas";
- assertTrue("expected method description 'description of foo' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, foo));
- assertTrue("expected method description 'description of bar' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, bar));
- assertFalse("didn't expect method description 'description of goo' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, goo));
- assertTrue("expected method description 'description of bas' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, bas));
- }
-
- /**
- * Comments for a constructor should be included in the ajdoc output
- */
- public void testPr164340() throws Exception {
- initialiseProject("pr164340");
- File[] files = {new File(getAbsoluteProjectDir() + "/C.java")};
- runAjdoc(files);
- File htmlFile = new File(getAbsolutePathOutdir() + "/C.html");
- if (!htmlFile.exists()) {
- fail("couldn't find " + htmlFile.getAbsolutePath() +
- " (ajc aborted: " + Main.hasAborted() + ")");
- }
- String methodDesc = "This is method foo";
- String constDesc = "This is a constructor";
- assertTrue("expected method description 'This is method foo' to appear" +
- " in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, methodDesc));
- assertTrue("expected constructor description 'This is a constructor' to " +
- "appear in ajdoc output but it did not",
- AjdocOutputChecker.containsString(htmlFile, constDesc));
- }
-}
// the file contains the getI() method but doesn't contain
// the private ClassBar, Bazz and Jazz classes.
String[] strings = { "private", "getI()","ClassBar", "Bazz", "Jazz"};
- List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ List<String> missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
assertEquals("There should be 4 missing strings",4,missing.size());
assertTrue(htmlFile.getName() + " should not contain the private modifier",missing.contains("private"));
assertTrue(htmlFile.getName() + " should not contain the private ClassBar class",missing.contains("ClassBar"));
"Aspect ClassA</H2>",
"public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"};
}
- List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size());
assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
if (LangUtil.is18VMOrGreater()) {
"before(int):",
"before(int): named()..",
"before():"};
- List missing = AjdocOutputChecker.getMissingStringsInSection(
+ List<String> missing = AjdocOutputChecker.getMissingStringsInSection(
htmlFile, strings,"ADVICE DETAIL SUMMARY");
assertTrue(htmlFile.getName() + " should contain all advice in the Advice Detail section",missing.isEmpty());
missing = AjdocOutputChecker.getMissingStringsInSection(
<version>${project.version}</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.2</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>