aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java55
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/Main.java39
-rw-r--r--ajdoc/testdata/coverage/foo/PlainJava.java2
-rw-r--r--ajdoc/testdata/declareForms/AnnotationTest.aj14
-rw-r--r--ajdoc/testdata/declareForms/DeclareCoverage2.aj46
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java208
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java276
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java1
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java298
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java92
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java71
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java18
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java111
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java289
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java3
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java11
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java91
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java47
18 files changed, 1088 insertions, 584 deletions
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
index 4b8b679cf..db148e599 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
@@ -207,24 +207,36 @@ class HtmlDecorator {
else {
decorateMemberDocumentation(decl, fileContents, index);
}
- }
-
- // Change "Class" to "Aspect"
- // HACK: depends on matching presence of advice or pointcut summary
- int classStartIndex = fileContents.toString().indexOf("<BR>\nClass ");
- int pointcutSummaryIndex = fileContents.toString().indexOf(POINTCUT_SUMMARY);
- int adviceSummaryIndex = fileContents.toString().indexOf(ADVICE_SUMMARY);
- if (classStartIndex != -1 &&
- (adviceSummaryIndex != -1 || pointcutSummaryIndex != -1)) {
- int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
- if (classStartIndex != -1 && classEndIndex != -1) {
- String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
- String aspectLine = "<BR>\n" + "Aspect " + classLine.substring(11, classLine.length());
- fileContents.delete(classStartIndex, classEndIndex);
- fileContents.insert(classStartIndex, aspectLine);
+ // Change "Class" to "Aspect"
+ // moved this here because then can use the IProgramElement.Kind
+ // rather than checking to see if there's advice - this fixes
+ // the case with an inner aspect not having the title "Aspect"
+ if(decl.getKind().equals(IProgramElement.Kind.ASPECT)
+ && file.getName().indexOf(decl.toSignatureString()) != -1) {
+ int classStartIndex = fileContents.toString().indexOf("<BR>\nClass ");
+ if (classStartIndex != -1) {
+ int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
+ if (classStartIndex != -1 && classEndIndex != -1) {
+ String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
+ String aspectLine = "<BR>\n" + "Aspect " + classLine.substring(11, classLine.length());
+ fileContents.delete(classStartIndex, classEndIndex);
+ fileContents.insert(classStartIndex, aspectLine);
+ }
+ }
+ int secondClassStartIndex = fileContents.toString().indexOf("class <B>");
+ if (secondClassStartIndex != -1) {
+ String name = decl.toSignatureString();
+ int classEndIndex = fileContents.indexOf(name + "</B><DT>");
+ if (secondClassStartIndex != -1 && classEndIndex != -1) {
+ StringBuffer sb = new StringBuffer(fileContents.toString().
+ substring(secondClassStartIndex,classEndIndex));
+ sb.replace(0,5,"aspect");
+ fileContents.delete(secondClassStartIndex, classEndIndex);
+ fileContents.insert(secondClassStartIndex, sb.toString());
+ }
+ }
}
- }
-
+ }
file.delete();
FileOutputStream fos = new FileOutputStream( file );
fos.write( fileContents.toString().getBytes() );
@@ -460,9 +472,12 @@ class HtmlDecorator {
if (!decl.getKind().equals(IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR)) {
entry += "&nbsp;&nbsp;";
}
- entry += generateSignatures(decl) +
- "<P>" +
- generateAffects(decl, true) +
+ // if we're not a declare statement then we need to generate the signature.
+ // If we did this for declare statements we get two repeated lines
+ if (!decl.getKind().isDeclare()) {
+ entry += generateSignatures(decl) + "<P>";
+ }
+ entry += generateAffects(decl, true) +
generateDetailsComment(decl);
}
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
index 6f7226966..e0000cb25 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/Main.java
@@ -66,6 +66,10 @@ public class Main implements Config {
private static boolean deleteTempFilesOnExit = true;
private static boolean aborted = false;
+
+ // creating a local variable to enable us to create the ajdocworkingdir
+ // in a local sandbox during testing
+ private static String outputWorkingDir = Config.WORKING_DIR;
public static void clearState() {
symbolManager = null;
@@ -102,8 +106,8 @@ public class Main implements Config {
File[] signatureFiles = new File[filenames.size()];
try {
// create the workingdir if it doesn't exist
- if ( !(new File( Config.WORKING_DIR ).isDirectory()) ) {
- File dir = new File( Config.WORKING_DIR );
+ if ( !(new File( outputWorkingDir ).isDirectory()) ) {
+ File dir = new File( outputWorkingDir );
dir.mkdir();
if (deleteTempFilesOnExit) dir.deleteOnExit();
}
@@ -171,7 +175,7 @@ public class Main implements Config {
javadocargs = new String[numExtraArgs + options.size() + packageList.size() +
fileList.size() ];
javadocargs[0] = "-sourcepath";
- javadocargs[1] = Config.WORKING_DIR;
+ javadocargs[1] = outputWorkingDir;
int argIndex = 2;
if (authorStandardDocletSwitch) {
javadocargs[argIndex] = "-author";
@@ -321,7 +325,7 @@ public class Main implements Config {
String filename = "";
if ( packageName != null ) {
- String pathName = Config.WORKING_DIR + '/' + packageName.replace('.', '/');
+ String pathName = outputWorkingDir + '/' + packageName.replace('.', '/');
File packageDir = new File(pathName);
if ( !packageDir.exists() ) {
packageDir.mkdirs();
@@ -329,11 +333,11 @@ public class Main implements Config {
}
//verifyPackageDirExists(packageName, null);
packageName = packageName.replace( '.','/' ); // !!!
- filename = Config.WORKING_DIR + Config.DIR_SEP_CHAR + packageName +
+ filename = outputWorkingDir + Config.DIR_SEP_CHAR + packageName +
Config.DIR_SEP_CHAR + inputFile.getName();
}
else {
- filename = Config.WORKING_DIR + Config.DIR_SEP_CHAR + inputFile.getName();
+ filename = outputWorkingDir + Config.DIR_SEP_CHAR + inputFile.getName();
}
File signatureFile = new File( filename );
if (deleteTempFilesOnExit) signatureFile.deleteOnExit();
@@ -436,7 +440,7 @@ public class Main implements Config {
static String getSourcepathAsString() {
String cPath = "";
for (int i = 0; i < sourcepath.size(); i++) {
- cPath += (String)sourcepath.elementAt(i) + Config.DIR_SEP_CHAR + Config.WORKING_DIR;
+ cPath += (String)sourcepath.elementAt(i) + Config.DIR_SEP_CHAR + outputWorkingDir;
if (i != sourcepath.size()-1) {
cPath += File.pathSeparator;
}
@@ -731,6 +735,27 @@ public class Main implements Config {
public static boolean hasAborted() {
return aborted;
}
+
+ /**
+ * Sets the output working dir to be <fullyQualifiedOutputDir>\ajdocworkingdir
+ * Useful in testing to redirect the ajdocworkingdir to the sandbox
+ */
+ public static void setOutputWorkingDir(String fullyQulifiedOutputDir) {
+ if (fullyQulifiedOutputDir == null) {
+ resetOutputWorkingDir();
+ } else {
+ outputWorkingDir = fullyQulifiedOutputDir + File.separatorChar +
+ Config.WORKING_DIR;
+ }
+ }
+
+ /**
+ * Resets the output working dir to be the default which is
+ * <the current directory>\ajdocworkingdir
+ */
+ public static void resetOutputWorkingDir() {
+ outputWorkingDir = Config.WORKING_DIR;
+ }
}
diff --git a/ajdoc/testdata/coverage/foo/PlainJava.java b/ajdoc/testdata/coverage/foo/PlainJava.java
index 3c1314cb5..00ebfc12f 100644
--- a/ajdoc/testdata/coverage/foo/PlainJava.java
+++ b/ajdoc/testdata/coverage/foo/PlainJava.java
@@ -23,7 +23,7 @@ public class PlainJava {
return i;
}
- static private class Bar {
+ static private class ClassBar {
static private class Baz {
diff --git a/ajdoc/testdata/declareForms/AnnotationTest.aj b/ajdoc/testdata/declareForms/AnnotationTest.aj
new file mode 100644
index 000000000..28a72736a
--- /dev/null
+++ b/ajdoc/testdata/declareForms/AnnotationTest.aj
@@ -0,0 +1,14 @@
+package foo;
+
+@interface MyAnnotation {
+}
+
+public aspect AnnotationTest {
+
+ declare @type : C : @MyAnnotation;
+
+}
+
+class C {
+
+}
diff --git a/ajdoc/testdata/declareForms/DeclareCoverage2.aj b/ajdoc/testdata/declareForms/DeclareCoverage2.aj
new file mode 100644
index 000000000..6300298e9
--- /dev/null
+++ b/ajdoc/testdata/declareForms/DeclareCoverage2.aj
@@ -0,0 +1,46 @@
+package foo;
+
+public aspect DeclareCoverage2 {
+
+ pointcut illegalNewFigElt(): call(Point.new(..)) && !withincode(* *.doIt(..));
+
+ declare error: illegalNewFigElt(): "Illegal constructor call.";
+ declare warning: call(* Point.setX(..)): "Illegal call.";
+
+ declare parents: Point extends java.io.Serializable;
+ declare parents: Line implements java.util.Observable;
+ declare soft: SizeException : call(* Point.getX());
+ declare precedence: DeclareCoverage2, InterTypeDecCoverage, *;
+}
+
+aspect InterTypeDecCoverage {}
+
+class Point {
+
+ int x = 2;
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public int getX() {
+ return x;
+ }
+}
+
+class Line {
+}
+
+class SizeException extends Throwable { }
+
+class Main {
+
+ public static void main(String[] args) {
+ }
+
+ public void doIt() {
+ Point p = new Point();
+ p.setX(3);
+ p.getX();
+ }
+
+}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
new file mode 100644
index 000000000..0022265e1
--- /dev/null
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
@@ -0,0 +1,208 @@
+/********************************************************************
+ * Copyright (c) 2005 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Helper class to check whether the ajdoc contains the expected
+ * information.
+ */
+public class AjdocOutputChecker {
+
+ /**
+ * Checks whether the given html file contains the required String.
+ *
+ * @param htmlFile
+ * @param requiredString
+ * @return true if the file contains the given string or
+ * false otherwise (or if the file is null or not an html file)
+ * @throws Exception
+ */
+ public static boolean containsString(File htmlFile,
+ String requiredString) throws Exception {
+ if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(requiredString) != -1) {
+ reader.close();
+ return true;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns those strings from the given array which aren't in the
+ * html file
+ *
+ * @param htmlFile
+ * @param an array of requiredStrings
+ * @return a List of those strings not found
+ * @throws Exception
+ */
+ public static List /*String*/ getMissingStringsInFile(File htmlFile,
+ String[] requiredStrings) throws Exception {
+ List missingStrings = new ArrayList();
+ for (int i = 0; i < requiredStrings.length; i++) {
+ String string = requiredStrings[i];
+ if (!containsString(htmlFile,string)) {
+ missingStrings.add(string);
+ }
+ }
+ return missingStrings;
+ }
+
+ /**
+ * Checks whether the section of the html file contains the
+ * required String
+ *
+ * @param htmlFile
+ * @param requiredString
+ * @param sectionHeader
+ * @return true if the file contains the given string within the
+ * required section or false otherwise (or if the file is null or
+ * not an html file)
+ * @throws Exception
+ */
+ public static boolean containsStringWithinSection(File htmlFile,
+ String requiredString, String sectionHeader) throws Exception {
+ if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(sectionHeader) != -1) {
+ String nextLine = reader.readLine();
+ while (nextLine != null &&
+ (nextLine.indexOf("========") == -1)) {
+ if (nextLine.indexOf(requiredString) != -1) {
+ reader.close();
+ return true;
+ }
+ nextLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Returns those strings from the given array which aren't in the
+ * ajdoc html file
+ *
+ * @param htmlFile
+ * @param an array of requiredStrings
+ * @param sectionHeader
+ * @return List of those requiredStrings not found
+ * @throws Exception
+ */
+ public static List /*String*/ getMissingStringsInSection(File htmlFile,
+ String[] requiredStrings, String sectionHeader) throws Exception {
+ List missingStrings = new ArrayList();
+ for (int i = 0; i < requiredStrings.length; i++) {
+ String string = requiredStrings[i];
+ if (!containsStringWithinSection(htmlFile,string,sectionHeader)) {
+ missingStrings.add(string);
+ }
+ }
+ return missingStrings;
+ }
+
+ /**
+ * Checks whether the given strings appear one after the other in the
+ * ajdoc html file
+ *
+ * @param htmlFile
+ * @param firstString
+ * @param secondString expected to follow the firstString
+ * @return true if secondString appears after firstString, false otherwise
+ * @throws Exception
+ */
+ public static boolean fileContainsConsecutiveStrings(File htmlFile,
+ String firstString, String secondString ) throws Exception {
+ if ((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html")) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(firstString) != -1) {
+ if ( (line.indexOf(secondString) != -1
+ && line.indexOf(secondString) > line.indexOf(firstString))
+ || reader.readLine().indexOf(secondString) != -1) {
+ reader.close();
+ return true;
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+
+ /**
+ * Checks whether the given strings appear one after the other in the
+ * given section of the ajdoc html file
+ *
+ * @param htmlFile
+ * @param firstString
+ * @param secondString expected to follow the firstString
+ * @param sectionHeader
+ * @return true if secondString appears after firstString, false otherwise
+ * @throws Exception
+ */
+ public static boolean sectionContainsConsecutiveStrings(File htmlFile,
+ String firstString, String secondString, String sectionHeader) throws Exception {
+ if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
+ return false;
+ }
+ BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
+ String line = reader.readLine();
+ while (line != null) {
+ if (line.indexOf(sectionHeader) != -1) {
+ String nextLine = reader.readLine();
+ while (nextLine != null && (nextLine.indexOf("========") == -1)) {
+ if (nextLine.indexOf(firstString) != -1) {
+ if ( (nextLine.indexOf(secondString) != -1
+ && nextLine.indexOf(secondString) > nextLine.indexOf(firstString))
+ || reader.readLine().indexOf(secondString) != -1) {
+ reader.close();
+ return true;
+ }
+ }
+ nextLine = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+ line = reader.readLine();
+ }
+ reader.close();
+ return false;
+ }
+}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
new file mode 100644
index 000000000..372c9c637
--- /dev/null
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java
@@ -0,0 +1,276 @@
+/********************************************************************
+ * Copyright (c) 2005 Contributors. All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: IBM Corporation - initial API and implementation
+ * Helen Hawkins - iniital version
+ *******************************************************************/
+package org.aspectj.tools.ajdoc;
+
+import java.io.File;
+import java.io.IOException;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+
+/**
+ * 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 final static String testdataSrcDir = "../ajdoc/testdata";
+ protected static File sandboxDir;
+ private static final String SANDBOX_NAME = "ajcSandbox";
+ private String docOutdir, projectDir;
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ docOutdir = null;
+ projectDir = null;
+ // Create a sandbox in which to work
+ createEmptySandbox();
+ // create the ajdocworkdingdir in the sandbox
+ Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath());
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ // reset where ajdocworkingdir is created
+ Main.resetOutputWorkingDir();
+ }
+
+ // Taken from AjdeInteractionTestbed
+ private void createEmptySandbox() {
+ String os = System.getProperty("os.name");
+ File tempDir = null;
+ // AMC - I did this rather than use the JDK default as I hate having to go look
+ // in c:\documents and settings\......... for the results of a failed test.
+ if (os.startsWith("Windows")) {
+ //Alex: try D first since NTFS on mine while FAT leads to failure..
+ tempDir = new File("D:\\temp");
+ if (!tempDir.exists()) {
+ tempDir = new File("C:\\temp");
+ if (!tempDir.exists()) {
+ tempDir.mkdir();
+ }
+ }
+ } else {
+ tempDir = new File("/tmp");
+ }
+ File sandboxRoot = new File(tempDir,SANDBOX_NAME);
+ if (!sandboxRoot.exists()) {
+ sandboxRoot.mkdir();
+ }
+
+ org.aspectj.util.FileUtil.deleteContents(sandboxRoot);
+
+ try {
+ sandboxDir = File.createTempFile("ajcTest",".tmp",sandboxRoot);
+ sandboxDir.delete();
+ sandboxDir.mkdir();
+ } catch (IOException ioEx) {
+ throw new AssertionFailedError("Unable to create sandbox directory for test");
+ }
+ }
+
+ /**
+ * Fill in the working directory with the project files and
+ * create a doc top level directory in which to generate
+ * the ajdoc output.
+ */
+ public void initialiseProject(String projectName) {
+ 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();
+
+ File docDestination = new File(getWorkingDir().toString() + File.separatorChar + projectName,"doc");
+ if (!docDestination.exists()) {docDestination.mkdir();}
+ docOutdir = docDestination.getAbsolutePath();
+ }
+
+ /**
+ * @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;
+ }
+
+ /**
+ * @return the absolute path of the doc output directory
+ * for example c:\temp\ajcSandbox\ajcTest15200.tmp\myProject\doc
+ */
+ protected String getAbsolutePathOutdir() {
+ return docOutdir;
+ }
+
+ /**
+ * 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);
+ }
+ }
+ }
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument,
+ * the default source level and the given input files.
+ */
+ public void runAjdoc(String visibility, File[] inputFiles) {
+ if (!visibility.equals("public")
+ && !visibility.equals("protected")
+ && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ String[] args = new String[5 + inputFiles.length];
+ args[0] = "-" + visibility;
+ args[1] = "-classpath";
+ args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[3] = "-d";
+ args[4] = getAbsolutePathOutdir();
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[5+i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the default visibility
+ * and source level and the given input files.
+ */
+ public void runAjdoc(File[] inputFiles) {
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ String[] args = new String[4 + inputFiles.length];
+ args[0] = "-classpath";
+ args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[2] = "-d";
+ args[3] = getAbsolutePathOutdir();
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[4+i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument,
+ * the given source level argument and the given input files.
+ */
+ public void runAjdoc(String visibility, String sourceLevel, File[] inputFiles) {
+ if (!visibility.equals("public")
+ && !visibility.equals("protected")
+ && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (!sourceLevel.equals("1.3")
+ && !sourceLevel.equals("1.4")
+ && !sourceLevel.equals("1.5")) {
+ fail("need to pass ajdoc '1.3', '1.4', or '1.5' as the source level");
+ }
+ if (inputFiles.length == 0) {
+ fail("need to pass some files into ajdoc");
+ }
+ for (int i = 0; i < inputFiles.length; i++) {
+ if (!inputFiles[i].exists()) {
+ fail(inputFiles[i].getAbsolutePath() + " does not exist");
+ }
+ }
+
+ String[] args = new String[7 + inputFiles.length];
+ args[0] = "-" + visibility;
+ args[1] = "-source";
+ args[2] = sourceLevel;
+ args[3] = "-classpath";
+ args[4] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[5] = "-d";
+ args[6] = getAbsolutePathOutdir();
+ for (int i = 0; i < inputFiles.length; i++) {
+ args[7+i] = inputFiles[i].getAbsolutePath();
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the given visibility argument,
+ * the default source level and the given input directories.
+ */
+ public void runAjdoc(String visibility, String[] directoryNames) {
+ if (!visibility.equals("public")
+ && !visibility.equals("protected")
+ && !visibility.equals("private")) {
+ fail("need to pass 'public','protected' or 'private' visibility to ajdoc");
+ }
+ if (directoryNames.length == 0) {
+ fail("need to pass some directories into ajdoc");
+ }
+ String[] args = new String[7 + directoryNames.length];
+ args[0] = "-" + visibility;
+ args[1] = "-classpath";
+ args[2] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[3] = "-d";
+ args[4] = getAbsolutePathOutdir();
+ args[5] = "-sourcepath";
+ args[6] = getAbsoluteProjectDir();
+ for (int i = 0; i < directoryNames.length; i++) {
+ args[7+i] = directoryNames[i];
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+
+ /**
+ * Run the ajdoc command with the default visibility and
+ * source level and the given input directories.
+ */
+ public void runAjdoc(String[] directoryNames) {
+ if (directoryNames.length == 0) {
+ fail("need to pass some directories into ajdoc");
+ }
+ String[] args = new String[6 + directoryNames.length];
+ args[0] = "-classpath";
+ args[1] = AjdocTests.ASPECTJRT_PATH.getPath();
+ args[2] = "-d";
+ args[3] = getAbsolutePathOutdir();
+ args[4] = "-sourcepath";
+ args[5] = getAbsoluteProjectDir();
+ for (int i = 0; i < directoryNames.length; i++) {
+ args[6+i] = directoryNames[i];
+ }
+ org.aspectj.tools.ajdoc.Main.main(args);
+ }
+}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java
index 129f18a78..f9d50e56f 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java
@@ -43,6 +43,7 @@ public class AjdocTests extends TestCase {
suite.addTestSuite(ITDTest.class);
suite.addTestSuite(FullyQualifiedArgumentTest.class);
suite.addTestSuite(EnumTest.class);
+ suite.addTestSuite(PointcutVisibilityTest.class);
suite.addTestSuite(ExecutionTestCase.class);// !!! must be last because it exists
//$JUnit-END$
return suite;
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
index b6f03d3c7..4b57d4978 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
@@ -12,35 +12,25 @@
package org.aspectj.tools.ajdoc;
import java.io.File;
+import java.util.List;
-import junit.framework.TestCase;
-
-import org.aspectj.util.FileUtil;
/**
* A long way to go until full coverage, but this is the place to add more.
*
* @author Mik Kersten
*/
-public class CoverageTestCase extends TestCase {
-
- protected File file0 = new File("../ajdoc/testdata/coverage/InDefaultPackage.java");
- protected File file1 = new File("../ajdoc/testdata/coverage/foo/ClassA.java");
- protected File aspect1 = new File("../ajdoc/testdata/coverage/foo/UseThisAspectForLinkCheck.aj");
- protected File file2 = new File("../ajdoc/testdata/coverage/foo/InterfaceI.java");
- protected File file3 = new File("../ajdoc/testdata/coverage/foo/PlainJava.java");
- protected File file4 = new File("../ajdoc/testdata/coverage/foo/ModelCoverage.java");
- protected File file5 = new File("../ajdoc/testdata/coverage/fluffy/Fluffy.java");
- protected File file6 = new File("../ajdoc/testdata/coverage/fluffy/bunny/Bunny.java");
- protected File file7 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/Rocks.java");
- protected File file8 = new File("../ajdoc/testdata/coverage/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
- protected File file9 = new File("../ajdoc/testdata/coverage/foo/PkgVisibleClass.java");
- protected File file10 = new File("../ajdoc/testdata/coverage/foo/NoMembers.java");
+public class CoverageTestCase extends AjdocTestCase {
- protected File outdir;
+ protected File file0,file1,aspect1,file2,file3,file4,file5,file6,file7,file8,file9,file10;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ initialiseProject("coverage");
+ createFiles();
+ }
public void testOptions() {
- outdir.delete();
String[] args = {
"-private",
"-encoding",
@@ -52,77 +42,235 @@ public class CoverageTestCase extends TestCase {
"-classpath",
AjdocTests.ASPECTJRT_PATH.getPath(),
"-d",
- outdir.getAbsolutePath(),
+ getAbsolutePathOutdir(),
file0.getAbsolutePath(),
};
org.aspectj.tools.ajdoc.Main.main(args);
assertTrue(true);
}
- public void testCoveragePublicMode() {
- outdir.delete();
- String[] args = {
- "-public",
- "-source",
- "1.4",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- file3.getAbsolutePath(),
- file9.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ /**
+ * Test the "-public" argument
+ */
+ public void testCoveragePublicMode() throws Exception {
+ File[] files = {file3,file9};
+ runAjdoc("public","1.4",files);
+
+ // have passed the "public" modifier as well as
+ // one public and one package visible class. There
+ // should only be ajdoc for the public class
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/PkgVisibleClass.html");
+ assertFalse("ajdoc for PkgVisibleClass shouldn't exist because passed" +
+ " the 'public' flag to ajdoc",htmlFile.exists());
+
+ htmlFile = new File(getAbsolutePathOutdir() + "/foo/PlainJava.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // check there's no private fields within the file, that
+ // 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);
+ 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"));
+ assertTrue(htmlFile.getName() + " should not contain the private Bazz class",missing.contains("Bazz"));
+ assertTrue(htmlFile.getName() + " should not contain the private Jazz class",missing.contains("Jazz"));
+ }
+
+ /**
+ * Test that the ajdoc for an inner aspect is entitled "Aspect" rather
+ * than "Class", but that the enclosing class is still "Class"
+ */
+ public void testInnerAspect() throws Exception {
+ File[] files = {file1, file2};
+ runAjdoc("private","1.4",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Aspect ClassA.InnerAspect" rather
+ // than "Class ClassA.InnerAspect"
+ String[] strings = { "Aspect ClassA.InnerAspect",
+ "<PRE>static aspect <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>",
+ "Class ClassA.InnerAspect",
+ "<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"};
+ List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ assertEquals("There should be 2 missing strings",2,missing.size());
+ assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class ClassA.InnerAspect"));
+ assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"));
+
+ // get the html file for the enclosing class
+ File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
+ if (htmlFileClass == null || !htmlFileClass.exists()) {
+ fail("couldn't find " + htmlFileClass.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ // ensure that the file is entitled "Class ClassA" and
+ // has not been changed to "Aspect ClassA"
+ String[] classStrings = { "Class ClassA</H2>",
+ "public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>",
+ "Aspect ClassA</H2>",
+ "public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"};
+ List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ assertEquals("There should be 2 missing strings",2,classMissing.size());
+ assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>"));
+ assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",classMissing.contains("public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"));
+ }
+
+ /**
+ * Test that all the different types of advice appear
+ * with the named pointcut in it's description
+ */
+ public void testAdviceNamingCoverage() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.4",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ "after(): named..",
+ "afterReturning(int, int): namedWithArgs..",
+ "afterThrowing(): named..",
+ "before(): named..",
+ "around(int): namedWithOneArg..",
+ "before(int):",
+ "before(int): named()..",
+ "before():"};
+ List 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(
+ htmlFile,strings,"ADVICE SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all advice in the Advice Summary section",missing.isEmpty());
+ }
+
+ /**
+ * Test that all the advises relationships appear in the
+ * Advice Detail and Advice Summary sections and that
+ * the links are correct
+ */
+ public void testAdvisesRelationshipCoverage() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.4",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] strings = {
+ "<B>before(): methodExecutionP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#setX(int)\"",
+ "<B>before(): constructorExecutionP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#Point()\"",
+ "<B>before(): callConstructorP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#doIt()\"",
+ "<B>before(): getP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#getX()\"",
+ "<B>before(): setP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html\"><tt>foo.Point</tt></A>, <A HREF=\"../foo/Point.html#Point()\"><tt>foo.Point.Point()</tt></A>, <A HREF=\"../foo/Point.html#setX(int)\"><tt>foo.Point.setX</tt></A>, <A HREF=\"../foo/Point.html#changeX(int)\"",
+ "<B>before(): initializationP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#Point()\"",
+ "<B>before(): staticinitializationP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html\"",
+ "<B>before(): handlerP..</B>",
+ "Advises:</b></font></td><td><A HREF=\"../foo/Point.html#doIt()\""};
+
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.sectionContainsConsecutiveStrings(htmlFile,strings[i],
+ strings[i+1],"ADVICE DETAIL SUMMARY");
+ assertTrue(strings[i] + " should have relationship " + strings[i+1] +
+ " in the Advice Detail section", b);
+ }
+
+ for (int i = 0; i < strings.length - 1; i = i+2) {
+ boolean b = AjdocOutputChecker.sectionContainsConsecutiveStrings(htmlFile,strings[i],
+ strings[i+1],"ADVICE SUMMARY");
+ assertTrue(strings[i] + " should have relationship " + strings[i+1] +
+ " in the Advice Summary section", b);
+ }
+ }
+
+ /**
+ * Test that all the advised by relationships appear in the
+ * various detail and summary sections in the ajdoc for the
+ * affected class and that the links are correct
+ */
+ public void testAdvisedByRelationshipCoverage() throws Exception {
+ File[] files = {file4};
+ runAjdoc("private","1.4",files);
+
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+
+ String[] constructorStrings = {
+ "Advised&nbsp;by:",
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""};
+ String[] methodStrings = {
+ "Advised&nbsp;by:",
+ "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): methodExecutionP..\""};
+
+ boolean b = AjdocOutputChecker.sectionContainsConsecutiveStrings(
+ htmlFile,constructorStrings[0],
+ constructorStrings[1],"CONSTRUCTOR SUMMARY");
+ assertTrue("the Constructor Summary should have the advised by relationship",b);
+ b = AjdocOutputChecker.sectionContainsConsecutiveStrings(
+ htmlFile,constructorStrings[0],
+ constructorStrings[1],"CONSTRUCTOR DETAIL");
+ assertTrue("the Constructor Detail should have the advised by relationship",b);
+
+ b = AjdocOutputChecker.sectionContainsConsecutiveStrings(
+ htmlFile,methodStrings[0],
+ methodStrings[1],"=== METHOD SUMMARY");
+ assertTrue("the Method Summary should have the advised by relationship",b);
+
+ b = AjdocOutputChecker.sectionContainsConsecutiveStrings(
+ htmlFile,methodStrings[0],
+ methodStrings[1],"=== METHOD DETAIL");
+ assertTrue("the Method Detail should have the advised by relationship",b);
}
+
public void testCoverage() {
- outdir.delete();
- String[] args = {
-// "-XajdocDebug",
- "-source",
- "1.4",
- "-private",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- aspect1.getAbsolutePath(),
- file0.getAbsolutePath(),
- file1.getAbsolutePath(),
- file2.getAbsolutePath(),
- file3.getAbsolutePath(),
- file4.getAbsolutePath(),
- file5.getAbsolutePath(),
- file6.getAbsolutePath(),
- file7.getAbsolutePath(),
- file8.getAbsolutePath(),
- file9.getAbsolutePath(),
- file10.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ File[] files = {aspect1,file0,file1,file2,file3,file4,file5,file6,
+ file7,file8,file9,file10};
+ runAjdoc("private","1.4",files);
+ }
+
+ private void createFiles() {
+ file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java");
+ file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java");
+ aspect1 = new File(getAbsoluteProjectDir() + "/foo/UseThisAspectForLinkCheck.aj");
+ file2 = new File(getAbsoluteProjectDir() + "/foo/InterfaceI.java");
+ file3 = new File(getAbsoluteProjectDir() + "/foo/PlainJava.java");
+ file4 = new File(getAbsoluteProjectDir() + "/foo/ModelCoverage.java");
+ file5 = new File(getAbsoluteProjectDir() + "/fluffy/Fluffy.java");
+ file6 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/Bunny.java");
+ file7 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/Rocks.java");
+ file8 = new File(getAbsoluteProjectDir() + "/fluffy/bunny/rocks/UseThisAspectForLinkCheckToo.java");
+ file9 = new File(getAbsoluteProjectDir() + "/foo/PkgVisibleClass.java");
+ file10 = new File(getAbsoluteProjectDir() + "/foo/NoMembers.java");
}
// public void testPlainJava() {
-// outdir.delete();
// String[] args = { "-d",
-// outdir.getAbsolutePath(),
+// getAbsolutePathOutdir(),
// file3.getAbsolutePath() };
// org.aspectj.tools.ajdoc.Main.main(args);
// }
- protected void setUp() throws Exception {
- super.setUp();
- outdir = new File("testdata/coverage/doc");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- FileUtil.deleteContents(new File("ajdocworkingdir"));
- (new File("ajdocworkingdir")).delete();
-
- FileUtil.deleteContents(new File("testdata"));
- (new File("testdata")).delete();
-
- }
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java
index f8c09e34b..35a7ed298 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java
@@ -13,39 +13,83 @@
package org.aspectj.tools.ajdoc;
import java.io.File;
-
-import junit.framework.TestCase;
+import java.util.List;
/**
* @author Mik Kersten
*/
-public class DeclareFormsTest extends TestCase {
+public class DeclareFormsTest extends AjdocTestCase {
- protected File file0 = new File("../ajdoc/testdata/declareForms/DeclareCoverage.java");
- protected File outdir = new File("../ajdoc/testdata/declareForms/doc");
-
public void testCoverage() {
- assertTrue(file0.exists());
- outdir.delete();
- String[] args = {
-// "-XajdocDebug",
- "-source",
- "1.4",
- "-private",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- file0.getAbsolutePath(),
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage.java")};
+ runAjdoc("private","1.4",files);
}
+
+ public void testDeclareStatments() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")};
+ runAjdoc("private","1.4",files);
+
+ // Aspect DeclareCoverage2 should contain within it's declare
+ // detail and summary the 6 different declare statements.
+ // Check for this....
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ // check the contents of the declare detail summary
+ String[] strings = { "declare error: quot;Illegal construct..quot",
+ "declare warning: quot;Illegal call.quot;",
+ "declare parents: implements Serializable",
+ "declare parents: extends Observable",
+ "declare soft: foo.SizeException",
+ "declare precedence: foo.DeclareCoverage2, foo.InterTypeDecCoverage"};
- protected void setUp() throws Exception {
- super.setUp();
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"DECLARE DETAIL SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all declare statements in " +
+ "the Declare Detail section",missing.isEmpty());
+
+ // check the contents of the declare summary - should contain
+ // the same strings
+ missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"DECLARE SUMMARY");
+ assertTrue(htmlFile.getName() + " should contain all declare statements in " +
+ "the Declare Summary section",missing.isEmpty());
}
- protected void tearDown() throws Exception {
- super.tearDown();
+ public void testDeclareAnnotation() throws Exception {
+ initialiseProject("declareForms");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "AnnotationTest.aj")};
+ runAjdoc("private","1.5",files);
+
+ // Aspect AnnotationTest should contain within it's declare
+ // detail and summary the declare annotation statement.
+ // Check for this....
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AnnotationTest.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath()
+ + " - were there compilation errors?");
+ }
+ // check the contents of the declare detail summary
+ String[] strings = { "declare @type: foo.C : @MyAnnotation",
+ "declare declare @type: foo.C : @MyAnnotation"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,strings,"DECLARE DETAIL SUMMARY");
+ assertEquals("there should be one missing string ",1,missing.size());
+ assertEquals("The declare statement shouldn't contain two 'declare's ",
+ "declare declare @type: foo.C : @MyAnnotation",missing.get(0));
+
+ // check the contents of the declare summary - should contain
+ // the declare @type statement without a return type
+ String[] summaryStrings = { "declare @type: foo.C : @MyAnnotation","[]"};
+ missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlFile,summaryStrings,"DECLARE SUMMARY");
+ assertEquals("there should be one missing string ",1,missing.size());
+ assertEquals("The declare statement shouldn't have '[]' as it's return type",
+ "[]",missing.get(0));
}
+
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java
index 39e9d0773..65ef3b3c9 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java
@@ -12,48 +12,17 @@ package org.aspectj.tools.ajdoc;
import java.io.File;
-import org.aspectj.util.FileUtil;
-import junit.framework.TestCase;
-
-
-public class EnumTest extends TestCase {
-
- private File outdir;
-
- protected void setUp() throws Exception {
- super.setUp();
- outdir = new File("../ajdoc/testdata/pr119453/doc");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- FileUtil.deleteContents(new File("ajdocworkingdir"));
- (new File("ajdocworkingdir")).delete();
-
- FileUtil.deleteContents(new File("testdata/pr119453/doc"));
- (new File("testdata/pr119453/doc")).delete();
- }
+public class EnumTest extends AjdocTestCase {
/**
* Test for pr122728 - no StringOutOfBoundsException
* when processing an Enum
*/
public void testEnum() throws Exception {
- outdir.delete();
- File f = new File("../ajdoc/testdata/pr122728/src/pack/MyEnum.java");
-
- String[] args = {
- "-XajdocDebug",
- "-private",
- "-source",
- "1.5",
- "-d",
- outdir.getAbsolutePath(),
- f.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/MyEnum.java")};
+ runAjdoc("private","1.5",files);
}
/**
@@ -61,19 +30,9 @@ public class EnumTest extends TestCase {
* when processing an Enum
*/
public void testInlinedEnum() throws Exception {
- outdir.delete();
- File f = new File("../ajdoc/testdata/pr122728/src/pack/ClassWithInnerEnum.java");
-
- String[] args = {
- "-XajdocDebug",
- "-private",
- "-source",
- "1.5",
- "-d",
- outdir.getAbsolutePath(),
- f.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/ClassWithInnerEnum.java")};
+ runAjdoc("private","1.5",files);
}
/**
@@ -81,18 +40,8 @@ public class EnumTest extends TestCase {
* when processing an Enum
*/
public void testEnumWithMethods() throws Exception {
- outdir.delete();
- File f = new File("../ajdoc/testdata/pr122728/src/pack/EnumWithMethods.java");
-
- String[] args = {
- "-XajdocDebug",
- "-private",
- "-source",
- "1.5",
- "-d",
- outdir.getAbsolutePath(),
- f.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ initialiseProject("pr122728");
+ File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/EnumWithMethods.java")};
+ runAjdoc("private","1.5",files);
}
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java
index c7ca99cf1..0d1a1a908 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java
@@ -14,14 +14,12 @@ package org.aspectj.tools.ajdoc;
import java.io.File;
-import junit.framework.TestCase;
-
import org.aspectj.bridge.Version;
/**
* @author Mik Kersten
*/
-public class ExecutionTestCase extends TestCase {
+public class ExecutionTestCase extends AjdocTestCase {
public void testVersionMatch() {
String ajdocVersion = Main.getVersion();
@@ -30,18 +28,10 @@ public class ExecutionTestCase extends TestCase {
}
public void testFailingBuild() {
- File file1 = new File("../ajdoc/testdata/failing-build/Fail.java");
- String[] args = { file1.getAbsolutePath() };
-
+ initialiseProject("failing-build");
+ File file1 = new File(getAbsoluteProjectDir() + File.separatorChar + "Fail.java");
+ String[] args = { file1.getAbsolutePath() };
org.aspectj.tools.ajdoc.Main.main(args);
assertTrue(Main.hasAborted());
}
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java
index a003aedf3..875ba367c 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java
@@ -10,103 +10,36 @@
*******************************************************************/
package org.aspectj.tools.ajdoc;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
+import java.util.List;
-import junit.framework.TestCase;
-
-import org.aspectj.util.FileUtil;
-
-public class FullyQualifiedArgumentTest extends TestCase {
-
- private File outdir;
- private File c, a;
-
- protected void setUp() throws Exception {
- super.setUp();
- outdir = new File("../ajdoc/testdata/pr119453/doc");
- c = new File("../ajdoc/testdata/pr119453/src/pack/C.java");
- a = new File("../ajdoc/testdata/pr119453/src/pack/A.aj");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- FileUtil.deleteContents(new File("ajdocworkingdir"));
- (new File("ajdocworkingdir")).delete();
-
- FileUtil.deleteContents(new File("testdata/pr119453/doc"));
- (new File("testdata/pr119453/doc")).delete();
- }
+public class FullyQualifiedArgumentTest extends AjdocTestCase {
/**
- * Test for pr119453
+ * Test for pr58520
*/
public void testPr58520() throws Exception {
- outdir.delete();
- String[] args = {
- "-XajdocDebug",
- "-private",
- "-d",
- outdir.getAbsolutePath(),
- c.getAbsolutePath(),
- a.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + File.separatorChar +"src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + File.separatorChar + "src/pack/A.aj")};
+ runAjdoc("private",files);
- checkContentsOfA();
+ // check the contents of A.html
+ File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
+ if (htmlA == null || !htmlA.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir()
+ + "/pack/A.html - were there compilation errors?");
+ }
+ // check the contents of the declare detail summary
+ String[] stringsA = { "C.html#method3(java.lang.String)",
+ "C.html#method3(String)"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(
+ htmlA,stringsA,"ADVICE SUMMARY");
+ assertEquals("There should be one missing string",1,missing.size());
+ assertEquals("The fully qualified name should appear in the argument",
+ "C.html#method3(String)",missing.get(0));
}
- // check whether the "advises" section of the "Advice Summary" contains
- // the fully qualified argument, so for example, it says it has href
- // .../ajdoc/testdata/pr119453/doc/pack/C.html#method3(java.lang.String)
- // rather than .../ajdoc/testdata/pr119453/doc/pack/C.html#method3(String)
- private void checkContentsOfA() throws Exception {
- File htmlA = new File("../ajdoc/testdata/pr119453/doc/pack/A.html");
- if (htmlA == null) {
- fail("couldn't find ../ajdoc/testdata/pr119453/doc/pack/A.html - were there compilation errors?");
- }
- BufferedReader readerA = new BufferedReader(new FileReader(htmlA));
- boolean containsAdviceSummary = false;
- String lineA = readerA.readLine();
- while( lineA != null && (!containsAdviceSummary)) {
- if (lineA.indexOf("ADVICE SUMMARY") != -1) {
- containsAdviceSummary = true;
- boolean containsFullyQualifiedArgument = false;
- boolean containsUnqualifiedArgument = false;
- // walk through the information in this section
- String nextLine = readerA.readLine();
- while(nextLine != null
- && (nextLine.indexOf("========") == -1)
- && (!containsFullyQualifiedArgument ||
- !containsUnqualifiedArgument)) {
- if (nextLine.indexOf("C.html#method3(java.lang.String)") != -1) {
- containsFullyQualifiedArgument = true;
- }
- if (nextLine.indexOf("C.html#method3(String)") != -1) {
- containsUnqualifiedArgument = true;
- }
- nextLine = readerA.readLine();
- }
- assertTrue("Advice summary should have link to " +
- "'C.html#method3(java.lang.String)'",
- containsFullyQualifiedArgument);
- assertFalse("Advice summary should not have link to " +
- "'C.html#method3(String)'",
- containsUnqualifiedArgument);
-
- lineA = nextLine;
- } else {
- lineA = readerA.readLine();
- }
- }
- readerA.close();
-
- assertTrue("should have Advice Summary information in " +
- "../ajdoc/testdata/pr119453/doc/pack/A.html", containsAdviceSummary);
-
- }
-
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java
index 58da282a0..edc1b51a6 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java
@@ -10,240 +10,79 @@
*******************************************************************/
package org.aspectj.tools.ajdoc;
-import java.io.BufferedReader;
import java.io.File;
-import java.io.FileReader;
+import java.util.List;
-import junit.framework.TestCase;
+public class ITDTest extends AjdocTestCase {
-import org.aspectj.util.FileUtil;
-
-public class ITDTest extends TestCase {
-
- private File outdir;
- private File c, a;
-
- protected void setUp() throws Exception {
- super.setUp();
- outdir = new File("../ajdoc/testdata/pr119453/doc");
- c = new File("../ajdoc/testdata/pr119453/src/pack/C.java");
- a = new File("../ajdoc/testdata/pr119453/src/pack/A.aj");
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
-
- FileUtil.deleteContents(new File("ajdocworkingdir"));
- (new File("ajdocworkingdir")).delete();
-
- FileUtil.deleteContents(new File("testdata/pr119453/doc"));
- (new File("testdata/pr119453/doc")).delete();
- }
-
/**
* Test for pr119453
*/
- public void testITDShownInDoc() throws Exception {
- outdir.delete();
- String[] args = {
- "-XajdocDebug",
- "-private",
- "-d",
- outdir.getAbsolutePath(),
- c.getAbsolutePath(),
- a.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
-
- checkContentsOfC();
- checkContentsOfA();
+ public void testITDShownInDoc() throws Exception {
+ initialiseProject("pr119453");
+ File[] files = {
+ new File(getAbsoluteProjectDir() + "/src/pack/C.java"),
+ new File(getAbsoluteProjectDir() + "/src/pack/A.aj")
+ };
+ runAjdoc("private",files);
- }
-
- // check whether the "INTER-TYPE METHOD SUMMARY" AND
- // "INTER-TYPE FIELD SUMMARY" have been added to the generated
- // html file for the class which is affected by these itds.
- // Also check that the correct mofifiers are showing ie. public
- // isn't there, but all others are (this mirrors javadoc behaviour)
- private void checkContentsOfC() throws Exception {
- File htmlC = new File("../ajdoc/testdata/pr119453/doc/pack/C.html");
- if (htmlC == null) {
- fail("couldn't find ../ajdoc/testdata/pr119453/doc/pack/C.html - were there compilation errors?");
+ // Check the contents of C.html
+ File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html");
+ if (htmlC == null || !htmlC.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir()
+ + "/pack/C.html - were there compilation errors?");
}
- BufferedReader readerC = new BufferedReader(new FileReader(htmlC));
- boolean containsITDF = false;
- boolean containsITDM = false;
- boolean containsITDC = false;
- String lineC = readerC.readLine();
- while( lineC != null && (!containsITDF || !containsITDM || !containsITDC)) {
- if (lineC.indexOf("INTER-TYPE METHOD SUMMARY") != -1) {
- containsITDM = true;
- boolean containsPublic = false;
- boolean containsString = false;
- boolean containsPackA = false;
- // walk through the information in this section
- String nextLine = readerC.readLine();
- while(nextLine != null && (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf("public") != -1) {
- containsPublic = true;
- }
- if (nextLine.indexOf("String") != -1) {
- containsString = true;
- }
- if (nextLine.indexOf("pack.A") != -1) {
- containsPackA = true;
- }
- nextLine = readerC.readLine();
- }
- assertFalse("inter-type method summary should not contain the 'public' modifier", containsPublic);
- assertTrue("inter-type method summary should contain the 'String' return type",containsString);
- assertTrue("inter-type method summary should contain declared by 'pack.A'", containsPackA);
-
- // we may have hit the "inter-type field summary" so set this to
- // be the next line we look at.
- lineC = nextLine;
- } else if (lineC.indexOf("INTER-TYPE FIELD SUMMARY") != -1) {
- containsITDF = true;
- boolean containsPrivate = false;
- // walk through the information in this section
- String nextLine = readerC.readLine();
- while(nextLine != null
- && (nextLine.indexOf("========") == -1)
- && !containsPrivate) {
- if (nextLine.indexOf("private") != -1) {
- containsPrivate = true;
- }
- nextLine = readerC.readLine();
- }
- assertTrue("inter-type field summary should contain the 'private' modifier",containsPrivate);
-
- // we may have hit the "inter-type field summary" so set this to
- // be the next line we look at.
- lineC = nextLine;
- } else if (lineC.indexOf("NTER-TYPE CONSTRUCTOR SUMMARY") != -1) {
- // don't do any more checking here because have
- // checked in the itd method summary
- containsITDC = true;
- } else {
- lineC = readerC.readLine();
- }
- }
- readerC.close();
-
- assertTrue("should have put ITD Method information into " +
- "../ajdoc/testdata/pr119453/doc/pack/C.html", containsITDM);
- assertTrue("should have put ITD Field information into " +
- "../ajdoc/testdata/pr119453/doc/pack/C.html", containsITDF);
- assertTrue("should have put ITD Constructor information into " +
- "../ajdoc/testdata/pr119453/doc/pack/C.html", containsITDC);
+ // check that C is a class
+ assertTrue(htmlC.getAbsolutePath() + " should have Class C as it's title",
+ AjdocOutputChecker.containsString(htmlC,"Class C"));
+ // check that the required sections exist
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE METHOD SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC, "INTER-TYPE METHOD SUMMARY"));
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE FIELD SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC, "INTER-TYPE FIELD SUMMARY"));
+ assertTrue(htmlC.getAbsolutePath() + " should contain an "
+ + "'INTER-TYPE CONSTRUCTOR SUMMARY' section",
+ AjdocOutputChecker.containsString(htmlC,"INTER-TYPE CONSTRUCTOR SUMMARY"));
+
+ // check the contents of the sections is correct
+ String[] stringsC = { "public", "String", "pack.A" };
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC,"INTER-TYPE METHOD SUMMARY");
+ assertEquals("There should be one missing string",1,missing.size());
+ assertEquals("public itd methods should not have the 'public' modifier in the ajdoc",
+ "public",missing.get(0));
- }
-
-
- // check whether the correct modifiers have been added to the
- // declare summary and declare detail in the doc for the aspect
- private void checkContentsOfA() throws Exception {
- File htmlA = new File("../ajdoc/testdata/pr119453/doc/pack/A.html");
- if (htmlA == null) {
- fail("couldn't find ../ajdoc/testdata/pr119453/doc/pack/A.html - were there compilation errors?");
+ String[] stringsC2 = { "private" };
+ missing = AjdocOutputChecker.getMissingStringsInSection(htmlC,stringsC2,"INTER-TYPE FIELD SUMMARY");
+ assertTrue("the private modifier for itd methods should appear in the ajdoc ",missing.size() == 0);
+
+ // check the contents of A.html
+ File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html");
+ if (htmlA == null || !htmlA.exists()) {
+ fail("couldn't find " + getAbsolutePathOutdir() + "/pack/A.html - were there compilation errors?");
}
- BufferedReader readerA = new BufferedReader(new FileReader(htmlA));
- boolean containsDeclareDetail = false;
- boolean containsDeclareSummary = false;
- String lineA = readerA.readLine();
- while( lineA != null && (!containsDeclareDetail || !containsDeclareSummary )) {
- if (lineA.indexOf("DECLARE DETAIL SUMMARY") != -1) {
- containsDeclareDetail = true;
- boolean containsPrivateInt = false;
- boolean containsPublicString = false;
- boolean containsITDFAsHeader = false;
- boolean containsCorrectConstInfo = false;
- boolean containsPackageVoid = false;
- // walk through the information in this section
- String nextLine = readerA.readLine();
- while(nextLine != null
- && (nextLine.indexOf("========") == -1)
- && (!containsPrivateInt || !containsPublicString
- || !containsITDFAsHeader || !containsCorrectConstInfo)) {
- if (nextLine.indexOf("private&nbsp;int") != -1) {
- containsPrivateInt = true;
- }
- if (nextLine.indexOf("public&nbsp;java.lang.String") != -1) {
- containsPublicString = true;
- }
- if (nextLine.indexOf("<H3>C.y</H3>") != -1) {
- containsITDFAsHeader = true;
- }
- if (nextLine.indexOf("public&nbsp;</TT><B>C.C") != -1 ) {
- containsCorrectConstInfo = true;
- }
- if (nextLine.indexOf("package&nbsp;void") != -1 ) {
- containsPackageVoid = true;
- }
- nextLine = readerA.readLine();
- }
- assertTrue("Declare detail summary should contain the 'private int' " +
- "modifiers", containsPrivateInt);
- assertTrue("Declare detail summary should contain the 'public java." +
- "lang.String' return type",containsPublicString);
- assertTrue("Declare detail summary should have 'C.y' as one header",
- containsITDFAsHeader);
- assertTrue("Declare detail summary should have 'public C.C' for the " +
- "ITD constructor", containsCorrectConstInfo);
- assertFalse("Declare detail summary should not have 'package void' in it",
- containsPackageVoid);
-
- // we may have hit the "inter-type field summary" so set this to
- // be the next line we look at.
- lineA = nextLine;
- } else if (lineA.indexOf("DECLARE SUMMARY") != -1) {
- containsDeclareSummary = true;
- boolean containsPrivate = false;
- boolean containsInt = false;
- boolean containsString = false;
- boolean containsPublic = false;
- boolean containsPackageVoid = false;
- // walk through the information in this section
- String nextLine = readerA.readLine();
- while(nextLine != null && (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf("private") != -1) {
- containsPrivate = true;
- }
- if (nextLine.indexOf("int") != -1) {
- containsInt = true;
- }
- if (nextLine.indexOf("public") != -1) {
- containsPublic = true;
- }
- if (nextLine.indexOf("String") != -1) {
- containsString = true;
- }
- if (nextLine.indexOf("package&nbsp;void") != -1) {
- containsPackageVoid = true;
- }
- nextLine = readerA.readLine();
- }
- assertTrue("Declare summary should contain the 'private' modifier",containsPrivate);
- assertTrue("Declare summary should contain the 'int' return type",containsInt);
- assertFalse("Declare summary should not contain the 'public' modifier",containsPublic);
- assertTrue("Declare summary should contain the 'String' return type",containsString);
- assertFalse("Declare summary should not have 'package void' in it",
- containsPackageVoid);
-
- // we may have hit the "Declare Details" so set this to
- // be the next line we look at.
- lineA = nextLine;
- } else {
- lineA = readerA.readLine();
- }
- }
- readerA.close();
+ // check that A is an Aspect
+ assertTrue(htmlA.getAbsolutePath() + " should have Aspect A as it's title",
+ AjdocOutputChecker.containsString(htmlA,"Aspect A"));
+
+ // check the contents of the declare detail summary
+ String[] stringsA = { "private&nbsp;int",
+ "public&nbsp;java.lang.String",
+ "<H3>C.y</H3>",
+ "public&nbsp;</TT><B>C.C",
+ "package&nbsp;void"};
+ missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA,"DECLARE DETAIL SUMMARY");
+ assertEquals("There should be one missing string ",1,missing.size());
+ assertEquals("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Detail' section of the ajdoc",
+ "package&nbsp;void", missing.get(0));
- assertTrue("should have put Declare Detail information into " +
- "../ajdoc/testdata/pr119453/doc/pack/A.html", containsDeclareDetail);
- assertTrue("should have put Declare Summary information into " +
- "../ajdoc/testdata/pr119453/doc/pack/A.html", containsDeclareSummary);
-
- }
-
+ // check the contents of the declare summary
+ String[] stringsA2 = {"private", "int", "public", "String", "package&nbsp;void"};
+ missing = AjdocOutputChecker.getMissingStringsInSection(htmlA,stringsA2,"DECLARE SUMMARY");
+ assertEquals("There should be two missing strings ",2,missing.size());
+ assertTrue("the public modifier shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("public"));
+ assertTrue("the 'package' and 'void' modifiers shouldn't appear in the 'Declare Summary' section of the ajdoc", missing.contains("package&nbsp;void"));
+ }
+
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java
index e4ac675cd..7a48b2c37 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java
@@ -3,12 +3,11 @@
*/
package org.aspectj.tools.ajdoc;
-import junit.framework.TestCase;
/**
* @author Mik Kersten
*/
-public class JDKVersionTest extends TestCase {
+public class JDKVersionTest extends AjdocTestCase {
// public void testIsUsing1point4() {
// String v = System.getProperty("java.class.version","44.0");
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java
index d0dd93a16..552ffa533 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java
@@ -14,14 +14,12 @@ package org.aspectj.tools.ajdoc;
import java.io.File;
-import junit.framework.TestCase;
-
/**
* A long way to go until full coverage, but this is the place to add more.
*
* @author Mik Kersten
*/
-public class PatternsTestCase extends TestCase {
+public class PatternsTestCase extends AjdocTestCase {
public void testSimpleExample() {
@@ -90,11 +88,4 @@ public class PatternsTestCase extends TestCase {
org.aspectj.tools.ajdoc.Main.main(args);
}
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
- }
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java
index 7a5d34a33..38789e4d2 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java
@@ -4,26 +4,85 @@
package org.aspectj.tools.ajdoc;
import java.io.File;
-
-import junit.framework.TestCase;
+import java.util.List;
/**
* @author Mik Kersten
*/
-public class PointcutVisibilityTest extends TestCase {
-
- protected File file1 = new File("../ajdoc/testdata/bug82340/Pointcuts.java");
- protected File outdir = new File("../ajdoc/testdata/bug82340/doc");
+public class PointcutVisibilityTest extends AjdocTestCase {
+
+ /**
+ * Test that passing the "public" argument only shows
+ * public pointcuts in the ajdoc
+ */
+ public void testCoveragePublicMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("public",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public pointcuts but not the protected and
+ // private one (since "public" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertEquals("There should be two missing strings",2,missing.size());
+ assertTrue("passing the 'public' argument means the private pointcut shouldn't appear in the ajdoc", missing.contains("privatePointcut"));
+ assertTrue("passing the 'public' argument means the protected pointcut shouldn't appear in the ajdoc", missing.contains("protectedPointcut"));
+ }
- public void testCoveragePublicMode() {
- outdir.delete();
- String[] args = {
- "-XajdocDebug",
- "-protected",
- "-d",
- outdir.getAbsolutePath(),
- file1.getAbsolutePath()
- };
- org.aspectj.tools.ajdoc.Main.main(args);
+ /**
+ * Test that passing the "protected" argument only shows
+ * public and protected pointcuts in the ajdoc
+ */
+ public void testCoverageProtectedMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("protected",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public and protected pointcuts but not the
+ // private one (since "protected" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertEquals("There should be one missing strings",1,missing.size());
+ assertEquals("passing the 'protected' argument means the private pointcut shouldn't appear in the ajdoc",
+ "privatePointcut", missing.get(0));
}
+
+ /**
+ * Test that passing the "private" argument shows all
+ * pointcuts (public, protected and private) in the ajdoc
+ */
+ public void testCoveragePrivateMode() throws Exception {
+ initialiseProject("bug82340");
+ File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "Pointcuts.java")};
+ runAjdoc("private",files);
+
+ // ajdoc for Pointcut.java should contain info about
+ // the public, protected and private pointcuts
+ // (since "private" was an argument)
+ // Check that this is the case......
+ File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Pointcuts.html");
+ if (htmlFile == null || !htmlFile.exists()) {
+ fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?");
+ }
+ // check the contents of the pointcut summary
+ String[] strings = { "privatePointcut","protectedPointcut","publicPointcut"};
+ List missing = AjdocOutputChecker.getMissingStringsInSection(htmlFile,strings,"POINTCUT SUMMARY");
+ assertTrue("passing the 'private' modifier means that private, protected and public " +
+ "pointcuts should appear in the ajdoc",missing.isEmpty());
+ }
+
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java
index 0825ade26..b6aa0c4b8 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java
@@ -11,58 +11,25 @@
* ******************************************************************/
package org.aspectj.tools.ajdoc;
-import java.io.File;
-
-import junit.framework.TestCase;
/**
* @author Mik Kersten
*/
-public class SpacewarTestCase extends TestCase {
+public class SpacewarTestCase extends AjdocTestCase {
+
+ private String[] dirs = {"spacewar","coordination"};
protected void setUp() throws Exception {
super.setUp();
- new File("../ajdoc/testdata/spacewar/docdir").delete();
+ initialiseProject("spacewar");
}
public void testSimpleExample() {
- File outdir = new File("testdata/spacewar/docdir");
- File sourcepath = new File("testdata/spacewar");
-
- String[] args = {
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- "-sourcepath",
- sourcepath.getAbsolutePath(),
- "spacewar",
- "coordination" };
-
- org.aspectj.tools.ajdoc.Main.main(args);
- assertTrue(true);
+ runAjdoc(dirs);
}
public void testPublicModeExample() {
- File outdir = new File("../ajdoc/testdata/spacewar/docdir");
- File sourcepath = new File("../ajdoc/testdata/spacewar");
-
- String[] args = {
- "-public",
- "-classpath",
- AjdocTests.ASPECTJRT_PATH.getPath(),
- "-d",
- outdir.getAbsolutePath(),
- "-sourcepath",
- sourcepath.getAbsolutePath(),
- "spacewar",
- "coordination" };
-
- org.aspectj.tools.ajdoc.Main.main(args);
- assertTrue(true);
- }
-
- protected void tearDown() throws Exception {
- super.tearDown();
+ runAjdoc("public",dirs);
}
+
}