diff options
author | Andy Clement <aclement@pivotal.io> | 2019-01-29 17:07:22 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-01-29 17:07:22 -0800 |
commit | 89739bc1ff28a18fadcb27dba7fd26d27ea7b343 (patch) | |
tree | 165bc12fa79f098634d888b4068b8d203e377546 /ajdoc/testsrc/org/aspectj | |
parent | e8436048b1667bc2d1d7c9a48070fb73a281daf9 (diff) | |
download | aspectj-89739bc1ff28a18fadcb27dba7fd26d27ea7b343.tar.gz aspectj-89739bc1ff28a18fadcb27dba7fd26d27ea7b343.zip |
mavenizing ajdoc - wip
Diffstat (limited to 'ajdoc/testsrc/org/aspectj')
15 files changed, 0 insertions, 2919 deletions
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java deleted file mode 100644 index 19202e9e3..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocModuleTests.java +++ /dev/null @@ -1,27 +0,0 @@ -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; - } -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java deleted file mode 100644 index 485b5d80b..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java +++ /dev/null @@ -1,305 +0,0 @@ -/******************************************************************** - * Copyright (c) 2005 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://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; - -import org.aspectj.util.LangUtil; - -/** - * 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<String> missingStrings = new ArrayList<String>(); - 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; - } - - /** - * Returns whether the class data section has the expected - * relationship and target i.e. have the relationships been - * applied to the type. - * - * @param the ajdoc html file - * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY" - * @param the source of the relationship, for example "Point()" - * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY - * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\"" - * @return true if the section contains the expected source/relationship/target, - * false otherwise - */ - public static boolean classDataSectionContainsRel(File htmlFile, - HtmlDecorator.HtmlRelationshipKind relationship, - String target) 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("START OF CLASS DATA") != -1) { - // found the required class data section - String subLine = reader.readLine(); - while(subLine != null - && (subLine.indexOf("========") == -1)){ - int relIndex = subLine.indexOf(relationship.toString()); - int targetIndex = subLine.indexOf(target); - if ((relIndex != -1) && (targetIndex != -1)) { - reader.close(); - if (relIndex < targetIndex) { - return true; - } - return false; - } - subLine = reader.readLine(); - } - reader.close(); - return false; - } - line = reader.readLine(); - } - reader.close(); - return false; - } - - /** - * Returns whether the supplied source has the expected - * relationship and target within the given detail section - * - * @param the ajdoc html file - * @param the detail sectionHeader, for example "DECLARE DETAIL SUMMARY" - * @param the source of the relationship, for example "Point()" - * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY - * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\"" - * @return true if the section contains the expected source/relationship/target, - * false otherwise - */ - public static boolean detailSectionContainsRel(File htmlFile, - String sectionHeader, String source, - HtmlDecorator.HtmlRelationshipKind relationship, - String target) throws Exception { - if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { - return false; - } - if (sectionHeader.indexOf("DETAIL") == -1) { - return false; - } - BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); - String line = reader.readLine(); - while (line != null) { - if (line.indexOf(sectionHeader) != -1) { - // found the required main section - String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { - // On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit"> - if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) || - nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) { - // found the required subsection - String subLine = reader.readLine(); - while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) { - int relIndex = subLine.indexOf(relationship.toString()); - int targetIndex = subLine.indexOf(target); - if ((relIndex != -1) && (targetIndex != -1)) { - reader.close(); - if (relIndex < targetIndex) { - return true; - } - return false; - } - subLine = reader.readLine(); - } - reader.close(); - return false; - } - nextLine = reader.readLine(); - } - reader.close(); - return false; - } - line = reader.readLine(); - } - reader.close(); - return false; - } - - /** - * Returns whether the supplied source has the expected - * relationship and target within the given summary section - * - * @param the ajdoc html file - * @param the detail sectionHeader, for example "DECLARE SUMMARY" - * @param the source of the relationship, for example "Point()" - * @param the relationship, for example HtmlDecorator.HtmlRelationshipKind.MATCHED_BY - * @param the expected target, for example "HREF=\"../foo/Main.html#doIt()\"" - * @return true if the section contains the expected source/relationship/target, - * false otherwise - */ - public static boolean summarySectionContainsRel( - File htmlFile, - String sectionHeader, - String source, - HtmlDecorator.HtmlRelationshipKind relationship, - String target) throws Exception { - if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) { - return false; - } - if (sectionHeader.indexOf("SUMMARY") == -1) { - return false; - } - BufferedReader reader = new BufferedReader(new FileReader(htmlFile)); - String line = reader.readLine(); - while (line != null) { - if (line.indexOf(sectionHeader) != -1) { - // found the required main section - String nextLine = reader.readLine(); - while (nextLine != null && (nextLine.indexOf("========") == -1)) { - if (nextLine.indexOf(source) != -1) { - // found the required subsection - String subLine = nextLine; - while(subLine != null - && (subLine.indexOf("========") == -1) - && (subLine.indexOf("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">") == -1)) { - int relIndex = subLine.indexOf(relationship.toString()); - int targetIndex = subLine.indexOf(target); - if ((relIndex != -1) && (targetIndex != -1)) { - reader.close(); - if (relIndex < targetIndex) { - return true; - } - return false; - } - subLine = reader.readLine(); - } - reader.close(); - return false; - } - 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 deleted file mode 100644 index e3674086e..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTestCase.java +++ /dev/null @@ -1,315 +0,0 @@ -/******************************************************************** - * Copyright (c) 2005 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://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 java.util.Iterator; -import java.util.List; - -import org.aspectj.tools.ajc.Ajc; -import org.aspectj.util.LangUtil; - -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 String docOutdir, projectDir; - - @Override - protected void setUp() throws Exception { - super.setUp(); - docOutdir = null; - projectDir = null; - // Create a sandbox in which to work - sandboxDir = Ajc.createEmptySandbox(); - // create the ajdocworkdingdir in the sandbox - Main.setOutputWorkingDir(getWorkingDir().getAbsolutePath()); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - // reset where ajdocworkingdir is created - Main.resetOutputWorkingDir(); - } - - /** - * 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 default visibility and source level, the given input files and the given aspectj options - */ - public void runAjdoc(File[] inputFiles, String sourceLevel, String[] ajOptions) { - if (inputFiles.length == 0) { - fail("need to pass some files into ajdoc"); - } - if (!sourceLevel.equals("1.3") && - !sourceLevel.equals("1.4") && - !sourceLevel.equals("1.5") && - !sourceLevel.equals("1.6") && - !sourceLevel.equals("1.7") && - !sourceLevel.equals("1.8") && - !sourceLevel.equals("1.9") && - !sourceLevel.equals("10")) { - fail("need to pass ajdoc '1.3' > '1.9' as the source level"); - } - String[] args = new String[6 + inputFiles.length + ajOptions.length]; - args[0] = "-source"; - args[1] = sourceLevel; - args[2] = "-classpath"; - args[3] = AjdocTests.ASPECTJRT_PATH.getPath(); - args[4] = "-d"; - args[5] = getAbsolutePathOutdir(); - for (int i = 0; i < ajOptions.length; i++) { - args[6 + i] = ajOptions[i]; - } - for (int i = 0; i < inputFiles.length; i++) { - args[6 + i + ajOptions.length] = 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") && - !sourceLevel.equals("1.6") && - !sourceLevel.equals("1.7") && - !sourceLevel.equals("1.8") && - !sourceLevel.equals("1.9") && - !sourceLevel.startsWith("9") && - !sourceLevel.startsWith("10")) { - fail("need to pass suitable version to ajdoc 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"; - StringBuilder classpath = new StringBuilder(); - if (LangUtil.is19VMOrGreater()) { - classpath.append(LangUtil.getJrtFsFilePath()).append(File.pathSeparator); - } - classpath.append(AjdocTests.ASPECTJRT_PATH.getPath()); - args[4] = classpath.toString(); - args[5] = "-d"; - args[6] = getAbsolutePathOutdir(); - // args[7] = "-Xset:minimalModel=false"; - 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); - } - - /** - * Run the ajdoc command with the given visibility argument, the default source level and the given input directories. - */ - public void runAjdoc(String visibility, String lstFile) { - if (!visibility.equals("public") && !visibility.equals("protected") && !visibility.equals("private")) { - fail("need to pass 'public','protected' or 'private' visibility to ajdoc"); - } - - String[] args = new String[8]; - args[0] = "-" + visibility; - args[1] = "-classpath"; - args[2] = AjdocTests.ASPECTJRT_PATH.getPath(); - args[3] = "-d"; - args[4] = getAbsolutePathOutdir(); - args[5] = "-sourcepath"; - args[6] = getAbsoluteProjectDir(); - args[7] = "@" + getAbsoluteProjectDir() + File.separatorChar + lstFile; - org.aspectj.tools.ajdoc.Main.main(args); - } - - /** - * Run the ajdoc command with the given options - */ - public void runAjdoc(List options) { - String[] args = new String[options.size()]; - int i = 0; - for (Iterator iter = options.iterator(); iter.hasNext();) { - String element = (String) iter.next(); - args[i] = element; - 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 deleted file mode 100644 index 6debbe13b..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocTests.java +++ /dev/null @@ -1,53 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * ******************************************************************/ - - -package org.aspectj.tools.ajdoc; - -import java.io.File; - -import org.aspectj.util.FileUtil; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class AjdocTests extends TestCase { - - public static File ASPECTJRT_PATH; - - static { - String[] paths = { "sp:aspectjrt.path", "sp:aspectjrt.jar", - "../lib/test/aspectjrt.jar", "../aj-build/jars/aspectj5rt-all.jar", - "../aj-build/jars/runtime.jar", - "../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; - } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/BugTests.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/BugTests.java deleted file mode 100644 index 163774864..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/BugTests.java +++ /dev/null @@ -1,185 +0,0 @@ -/******************************************************************** - * 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)); - } -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java deleted file mode 100644 index e73b94dae..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ /dev/null @@ -1,940 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ - package org.aspectj.tools.ajdoc; - -import java.io.File; -import java.util.List; - -import org.aspectj.util.LangUtil; - -/** - * A long way to go until full coverage, but this is the place to add more. - * - * @author Mik Kersten - */ -public class CoverageTestCase extends AjdocTestCase { - - 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() { - String[] args = { - "-private", - "-encoding", - "EUCJIS", - "-docencoding", - "EUCJIS", - "-charset", - "UTF-8", - "-classpath", - AjdocTests.ASPECTJRT_PATH.getPath(), - "-d", - getAbsolutePathOutdir(), - file0.getAbsolutePath(), - }; - org.aspectj.tools.ajdoc.Main.main(args); - assertTrue(true); - } - - /** - * Test the "-public" argument - */ - public void testCoveragePublicMode() throws Exception { - File[] files = {file3,file9}; - runAjdoc("public","9",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.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 aspect has the title "Aspect" - */ - public void testAJdocHasAspectTitle() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A.aj")}; - runAjdoc("private","1.6",files); - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/A.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?"); - } - assertTrue(htmlFile.getAbsolutePath() + " should have Aspect A as it's title", - AjdocOutputChecker.containsString(htmlFile,"Aspect A")); - } - - /** - * Test that the ajdoc for a class has the title "Class" - */ - public void testAJdocHasClassTitle() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")}; - runAjdoc("private","1.6",files); - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath()+ " - were there compilation errors?"); - } - assertTrue(htmlFile.getAbsolutePath() + " should have Class C as it's title", - AjdocOutputChecker.containsString(htmlFile,"Class C")); - - } - - /** - * 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.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/ClassA.InnerAspect.html"); - if (!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 = null; - if (LangUtil.is18VMOrGreater()) { - strings = new String[] { - "Aspect ClassA.InnerAspect", - "<pre>static aspect <span class=\"typeNameLabel\">ClassA.InnerAspect</span>", - "Class ClassA.InnerAspect", - "<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>"}; - } - else { - strings = new String[] { - "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<String> missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings); - StringBuilder buf = new StringBuilder(); - for (String str:missingStrings) { - buf.append(str).append("\n"); - } - buf.append("HTMLFILE=\n").append(htmlFile).append("\n"); - assertEquals("There should be 2 missing strings:\n"+buf.toString(), 2, missingStrings.size()); - assertTrue(htmlFile.getName() + " should not have Class as it's title", - missingStrings.contains("Class ClassA.InnerAspect")); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFile.getName() + " should not have class in its subtitle", - missingStrings.contains("<pre>static class <span class=\"typeNameLabel\">ClassA.InnerAspect</span>")); - } - else { - assertTrue(htmlFile.getName() + " should not have class in its subtitle", - missingStrings.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.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 = null; - - if (LangUtil.is18VMOrGreater()) { - classStrings = new String[] { - "Class ClassA</h2>", - "public abstract class <span class=\"typeNameLabel\">ClassA</span>", - "Aspect ClassA</H2>", - "public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"}; - } - else { - classStrings = new String[] { - "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:\n"+classMissing,2,classMissing.size()); - assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA</H2>")); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle", - classMissing.contains("public abstract aspect <span class=\"typeNameLabel\">ClassA</span>")); - } - else { - 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.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html"); - if (!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.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - "before(): methodExecutionP..", - "HREF=\"../foo/Point.html#setX(int)\"", - "before(): constructorExecutionP..", - "HREF=\"../foo/Point.html#Point()\"", - "before(): callMethodP..", - "HREF=\"../foo/Point.html#changeX(int)\"", - "before(): callConstructorP..", - "HREF=\"../foo/Point.html#doIt()\"", - "before(): getP..", - "HREF=\"../foo/Point.html#getX()\"", - "before(): setP..", - "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)\"", - "before(): initializationP..", - "HREF=\"../foo/Point.html#Point()\"", - "before(): staticinitializationP..", - "HREF=\"../foo/Point.html\"", - "before(): handlerP..", - "HREF=\"../foo/Point.html#doIt()\"" - }; - - for (int i = 0; i < strings.length - 1; i = i+2) { - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"ADVICE DETAIL SUMMARY",strings[i], - HtmlDecorator.HtmlRelationshipKind.ADVISES, - strings[i+1]); - assertTrue(strings[i] + " should advise " + strings[i+1] + - " in the Advice Detail section", b); - } - - for (int i = 0; i < strings.length - 1; i = i+2) { - boolean b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"ADVICE SUMMARY",strings[i], - HtmlDecorator.HtmlRelationshipKind.ADVISES, - strings[i+1]); - assertTrue(strings[i] + " should advise " + strings[i+1] + - " in the Advice Summary section", b); - } - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a method execution pointcut - */ - public void testAdvisedByMethodExecution() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("setX(int)"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): methodExecutionP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a constructor execution pointcut - */ - public void testAdvisedByConstructorExecution() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): constructorExecutionP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== CONSTRUCTOR DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Constructor Detail should have " + strings[0]+" advised by " + strings[1],b); - - // Pre-JDK 11: - // This precedes the line containing strings[1] - // <td class="colOne"><code><span class="memberNameLink"><a href="../foo/Point.html#Point--">Point</a></span>()</code> - // On JDK 11: - // This precedes the line containing strings[1] - // <th class="colConstructorName" scope="row"><code><span class="memberNameLink"><a href="#%3Cinit%3E()">Point</a></span>()</code></th> - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== CONSTRUCTOR SUMMARY", - LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Constructor Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a method call pointcut - */ - public void testAdvisedByMethodCall() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("changeX(int)"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callMethodP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a constructor call pointcut - */ - public void testAdvisedByConstructorCall() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("doIt()"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): callConstructorP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a get pointcut - */ - public void testAdvisedByGet() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("getX()"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): getP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a set pointcut - */ - public void testAdvisedBySet() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): setP..\""; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("setX(int)"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("the Method Detail should have setX(int) advised by " + href,b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("setX(int)"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("the Method Summary should have setX(int) advised by " + href,b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== CONSTRUCTOR DETAIL", - LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("the Constructor Detail should have advised by " + href,b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== CONSTRUCTOR SUMMARY", - LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":toName("Point()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("the Constructor Summary should have advised by " + href,b); - - b = AjdocOutputChecker.classDataSectionContainsRel( - htmlFile, - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("The class data section should have 'advised by " + href + "'",b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with an initialization pointcut - */ - public void testAdvisedByInitialization() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - LangUtil.is11VMOrGreater()?"<init>()":toName("Point()"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): initializationP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile, - "=== CONSTRUCTOR DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have 'setX(int) advised by ... before()'",b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile, - "=== CONSTRUCTOR SUMMARY", - LangUtil.is11VMOrGreater()?"#%3Cinit%3E()":strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have 'setX(int) advised by ... before()'",b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a staticinitialization pointcut - */ - public void testAdvisedByStaticInitialization() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String href = "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): staticinitializationP..\""; - boolean b = AjdocOutputChecker.classDataSectionContainsRel( - htmlFile, - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertTrue("The class data section should have 'advised by " + href + "'",b); - } - - /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a handler pointcut - */ - public void testAdvisedByHandler() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("doIt()"), - "HREF=\"../foo/AdvisesRelationshipCoverage.html#before(): handlerP..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - } - - private String toName(String name) { - if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) { - name = name.replace('(','-'); - name = name.replace(')','-'); - } - return name; - } - /** - * Test that if have two before advice blocks from the same - * aspect affect the same method, then both appear in the ajdoc - */ - public void testTwoBeforeAdvice() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/A2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/C2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String[] strings = { - toName("amethod()"), - "HREF=\"../pkg/A2.html#before(): p..\"", - "HREF=\"../pkg/A2.html#before(): p2..\""}; - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[1]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[1],b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[2]); - assertTrue("the Method Detail should have " + strings[0]+" advised by " + strings[2],b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - strings[0], - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - strings[2]); - assertTrue("the Method Summary should have " + strings[0]+" advised by " + strings[2],b); - } - - /** - * Test that there are no spurious "advised by" entries - * against the aspect in the ajdoc - */ - public void testNoSpuriousAdvisedByRels() throws Exception { - File[] files = {file4}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdvisesRelationshipCoverage.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - String href = "foo.Point.setX(int)"; - boolean b = AjdocOutputChecker.classDataSectionContainsRel( - htmlFile, - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - href); - assertFalse("The class data section should not have 'advised by " + href + "'",b); - - } - - public void testCoverage() { - File[] files = {aspect1,file0,file1,file2,file3,file4,file5,file6, - file7,file8,file9,file10}; - runAjdoc("private","1.6",files); - } - - /** - * Test that nested aspects appear with "aspect" in their title - * when the ajdoc file is written slightly differently (when it's - * written for this apsect, it's different than for testInnerAspect()) - */ - public void testNestedAspect() throws Exception { - File[] files = {file9}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.NestedAspect.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - // ensure that the file is entitled "Aspect PkgVisibleClass.NestedAspect" rather - // than "Class PkgVisibleClass.NestedAspect" - String[] strings = null; - if (LangUtil.is18VMOrGreater()) { - strings = new String[] { - "Aspect PkgVisibleClass.NestedAspect", - "<pre>static aspect <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>", - "Class PkgVisibleClass.NestedAspect", - "<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>"}; - } - else { - strings = new String[] { - "Aspect PkgVisibleClass.NestedAspect", - "<PRE>static aspect <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>", - "Class PkgVisibleClass.NestedAspect", - "<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>"}; - } - List<String> 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 PkgVisibleClass.NestedAspect")); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFile.getName() + " should not have class in its subtitle", - missing.contains("<pre>static class <span class=\"typeNameLabel\">PkgVisibleClass.NestedAspect</span>")); - } - else { - assertTrue(htmlFile.getName() + " should not have class in its subtitle", - missing.contains("<PRE>static class <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>")); - } - // get the html file for the enclosing class - File htmlFileClass = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.html"); - if (!htmlFileClass.exists()) { - fail("couldn't find " + htmlFileClass.getAbsolutePath() - + " - were there compilation errors?"); - } - - // ensure that the file is entitled "Class PkgVisibleClass" and - // has not been changed to "Aspect PkgVisibleClass" - String[] classStrings = null; - if (LangUtil.is18VMOrGreater()) { - classStrings = new String[] { - "Class PkgVisibleClass</h2>", - "<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>", - "Aspect PkgVisibleClass</h2>", - "<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"}; - } - else { - classStrings = new String[] { - "Class PkgVisibleClass</H2>", - "class <B>PkgVisibleClass</B><DT>extends java.lang.Object</DL>", - "Aspect PkgVisibleClass</H2>", - "aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>"}; - } - List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings); - assertEquals("There should be 2 missing strings",2,classMissing.size()); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title", - classMissing.contains("Aspect PkgVisibleClass</h2>")); - assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle", - classMissing.contains("<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>")); - } - else { - assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect PkgVisibleClass</H2>")); - assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",classMissing.contains("aspect <B>PkgVisibleClass</B><DT>extends java.lang.Object<DT>")); - } - } - - /** - * Test that in the case when you have a nested aspect whose - * name is part of the enclosing class, for example a class called - * ClassWithNestedAspect has nested aspect called NestedAspect, - * that the titles for the ajdoc are correct. - */ - public void testNestedAspectWithSimilarName() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect" - // rather than "Class ClassWithNestedAspect.NestedAspect" - String[] strings = null; - if (LangUtil.is18VMOrGreater()) { - strings = new String [] { - "Aspect ClassWithNestedAspect.NestedAspect", - "<pre>static aspect <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>", - "Class ClassWithNestedAspect.NestedAspect", - "<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>"}; - } - else { - strings = new String [] { - "Aspect ClassWithNestedAspect.NestedAspect", - "<PRE>static a;spect <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>", - "Class ClassWithNestedAspect.NestedAspect", - "<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"}; - } - List<String> 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 ClassWithNestedAspect.NestedAspect")); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFile.getName() + " should not have class in its subtitle", - missing.contains("<pre>static class <span class=\"typeNameLabel\">ClassWithNestedAspect.NestedAspect</span>")); - } - else { - assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>")); - } - - // get the html file for the enclosing class - File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html"); - if (htmlFileClass == null || !htmlFileClass.exists()) { - fail("couldn't find " + htmlFileClass.getAbsolutePath() - + " - were there compilation errors?"); - } - - // ensure that the file is entitled "Class ClassWithNestedAspect" and - // has not been changed to "Aspect ClassWithNestedAspect" - String[] classStrings = null; - if (LangUtil.is18VMOrGreater()) { - classStrings = new String[] { - "Class ClassWithNestedAspect</h2>", - "public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>", - "Aspect ClassWithNestedAspect</h2>", - "public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"}; - } - else { - classStrings = new String[] { - "Class ClassWithNestedAspect</H2>", - "public class <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>", - "Aspect ClassWithNestedAspect</H2>", - "public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>"}; - } - List<String> classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings); - assertEquals("There should be 2 missing strings",2,classMissing.size()); - if (LangUtil.is18VMOrGreater()) { - assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title", - classMissing.contains("Aspect ClassWithNestedAspect</h2>")); - assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle", - classMissing.contains("public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>")); - } - else { - assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title", - classMissing.contains("Aspect ClassWithNestedAspect</H2>")); - assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle", - classMissing.contains("public aspect <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>")); - } - } - - /** - * Test that everythings being decorated correctly within the ajdoc - * for the aspect when the aspect is a nested aspect - */ - public void testAdviceInNestedAspect() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.NestedAspect.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"ADVICE DETAIL SUMMARY", - "before(): p..", - HtmlDecorator.HtmlRelationshipKind.ADVISES, - "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\""); - assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" + - "' in the Advice Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"ADVICE SUMMARY", - "before(): p..", - HtmlDecorator.HtmlRelationshipKind.ADVISES, - "HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\""); - assertTrue("Should have 'before(): p.. advises HREF=\"../pkg/ClassWithNestedAspect.html#amethod()\"" + - "' in the Advice Summary section", b); - - } - - /** - * Test that everythings being decorated correctly within the ajdoc - * for the advised class when the aspect is a nested aspect - */ - public void testAdvisedByInNestedAspect() throws Exception { - File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT SUMMARY "); - assertFalse(htmlFile.getName() + " should not contain a pointcut summary section",b); - b = AjdocOutputChecker.containsString(htmlFile,"ADVICE SUMMARY "); - assertFalse(htmlFile.getName() + " should not contain an adivce summary section",b); - b = AjdocOutputChecker.containsString(htmlFile,"POINTCUT DETAIL "); - assertFalse(htmlFile.getName() + " should not contain a pointcut detail section",b); - b = AjdocOutputChecker.containsString(htmlFile,"ADVICE DETAIL "); - assertFalse(htmlFile.getName() + " should not contain an advice detail section",b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\""); - assertTrue("Should have 'amethod() advised by " + - "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" + - "' in the Method Detail section", b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.."); - assertFalse("Should not have the label " + - "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." + - " in the Method Detail section", b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\""); - assertTrue("Should have 'amethod() advised by " + - "HREF=\"../pkg/ClassWithNestedAspect.NestedAspect.html#before(): p..\"" + - "' in the Method Summary section", b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.."); - assertFalse("Should not have the label " + - "pkg.ClassWithNestedAspect.NestedAspect.NestedAspect.before(): p.." + - " in the Method Summary section", b); - - } - - 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() { -// String[] args = { "-d", -// getAbsolutePathOutdir(), -// file3.getAbsolutePath() }; -// org.aspectj.tools.ajdoc.Main.main(args); -// } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java deleted file mode 100644 index 8dc4c24fe..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/DeclareFormsTest.java +++ /dev/null @@ -1,569 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ - -package org.aspectj.tools.ajdoc; - -import java.io.File; -import java.util.List; - -import org.aspectj.util.LangUtil; - -/** - * @author Mik Kersten - */ -public class DeclareFormsTest extends AjdocTestCase { - - private String declareError = "declare error: quot;Illegal construct..quot"; - private String declareWarningQuotes = "declare warning: quot;Illegal call.quot;"; - private String declareWarning = "declare warning: \"Illegal call.\""; - private String declareParentsImpl = "declare parents: implements Serializable"; - private String declareSoft = "declare soft: foo.SizeException2"; - private String declarePrecedence = "declare precedence: foo.DeclareCoverage2, foo.InterTypeDecCoverage2"; - - private String doItHref = "HREF=\"../foo/Main2.html#doIt()\""; - private String pointHref = "HREF=\"../foo/Point2.html\""; - private String cHref = "HREF=\"../foo/C.html\""; - - private String doIt = "doIt()"; - - - public void testCoverage() { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage.java")}; - runAjdoc("private","1.6",files); - } - - /** - * Test that the declare statements appear in the Declare Detail - * and Declare Summary sections of the ajdoc - */ - public void testDeclareStatments() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - // check the contents of the declare detail summary - String[] strings = { - declareError, - declareWarning, - declareParentsImpl, - declareSoft, - declarePrecedence}; - - 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()); - } - - /** - * Declare warning's should have the 'matched by' relationship - * in the ajdoc for the declaring aspect - */ - public void testDeclareWarning() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY", - declareWarningQuotes, - HtmlDecorator.HtmlRelationshipKind.MATCHED_BY, - doItHref); - assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref + - "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"DECLARE SUMMARY", - declareWarningQuotes, - HtmlDecorator.HtmlRelationshipKind.MATCHED_BY, - doItHref); - assertTrue("Should have '" + declareWarningQuotes + " matched by " + doItHref + - "' in the Declare Summary section", b); - } - - /** - * The target of a declare warning should have the 'matches - * declare' relationship in the ajdoc - test the case when - * the declare warning matches a call join point - */ - public void testMatchesDeclareCall() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName(doIt), - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - declareWarningQuotes); - assertTrue("Should have '" + doIt + " matches declare " + - declareWarningQuotes + "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName(doIt), - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - declareWarningQuotes); - assertTrue("Should have '" + doIt + " matches declare " + - declareWarningQuotes + "' in the Declare Summary section", b); - } - - /** - * The target of a declare warning should have the 'matches - * declare' relationship in the ajdoc - test the case when - * the declare warning matches an execution join point - */ - public void testMatchesDeclareExecution() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("setX(int)"), -// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - "declare warning: quot;blahquot;"); - assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + - "' in the Method Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("setX(int)"), -// LangUtil.is18VMOrGreater()?"setX-int-":"setX(int)", - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - "declare warning: quot;blahquot;"); - assertTrue("Should have 'setX(int) matches declare declare warning: quot;blahquot;" + - "' in the Method Summary section", b); - } - - /** - * Declare parents's should have the 'declared on' relationship - * in the ajdoc for the declaring aspect - */ - public void testDeclareParents() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY", - declareParentsImpl, - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - pointHref); - assertTrue("Should have ' " + declareParentsImpl + " declared on " + - pointHref + "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"DECLARE SUMMARY", - declareParentsImpl, - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - pointHref); - assertTrue("Should have ' " + declareParentsImpl + " declared on " + - pointHref + "' in the Declare Summary section", b); - } - - /** - * The target of a declare parent should have the 'aspect - * declarations' relationship in the ajdoc - */ - public void testAspectDeclarations() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Point2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - boolean b = AjdocOutputChecker.classDataSectionContainsRel( - htmlFile, - HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS, - "declare parents: implements Serializable"); - assertTrue("The class data section should have 'aspect declarations" + - " declare parents: implements Serializable'",b); - - } - - /** - * Declare soft's should have the 'softens' relationship - * in the ajdoc for the declaring aspect - */ - public void testDeclareSoft() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareCoverage2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY", - declareSoft, - HtmlDecorator.HtmlRelationshipKind.SOFTENS, - doItHref); - assertTrue("Should have '" + declareSoft + " softens " + doItHref + - "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"DECLARE SUMMARY", - declareSoft, - HtmlDecorator.HtmlRelationshipKind.SOFTENS, - doItHref); - assertTrue("Should have '" + declareSoft + " softens " + doItHref + - "' in the Declare Summary section", b); - } - - /** - * The target of a declare soft should have the 'softened - * by' relationship in the ajdoc - */ - public void testSoftenedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareCoverage2.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/Main2.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName(doIt), - HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY, - declareSoft); - assertTrue("Should have '" + doIt + " softened by " + declareSoft + - "' in the Method Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName(doIt), - HtmlDecorator.HtmlRelationshipKind.SOFTENED_BY, - declareSoft); - assertTrue("Should have '" + doIt + " softened by " + declareSoft + - "' in the Method Summary section", b); - } - - private String toName(String name) { - if (LangUtil.is18VMOrGreater() && !LangUtil.is11VMOrGreater()) { - name = name.replace('(','-'); - name = name.replace(')','-'); - } - return name; - } - - /** - * Declare annotation should have the 'annotates' relationship - * in the ajdoc for the declaring aspect - */ - public void testDeclareAnnotation() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")}; - runAjdoc("private","1.6",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/DeclareAtType.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - // check there's no return type for the declare annotation - // statement in the declare summary section - String[] returnType = {"[]"}; - List missing = AjdocOutputChecker.getMissingStringsInSection( - htmlFile,returnType,"DECLARE SUMMARY"); - assertEquals("there should be no return type for declare annotation" + - " in the ajdoc",1,missing.size()); - assertEquals("there shouldn't be the '[]' return type for declare annotation" + - " in the ajdoc","[]",missing.get(0)); - - // check that the 'annotates' relationship is there - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY", - "declare @type: foo.C : @MyAnnotation", - HtmlDecorator.HtmlRelationshipKind.ANNOTATES, - cHref); - assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates " - + cHref + "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"DECLARE SUMMARY", - "declare @type: foo.C : @MyAnnotation", - HtmlDecorator.HtmlRelationshipKind.ANNOTATES, - cHref); - assertTrue("Should have 'declare @type: foo.C : @MyAnnotation annotates " - + cHref + "' in the Declare Summary section", b); - } - - /** - * The target of a declare method annotation should have the - * 'annotated by' relationship in the ajdoc within the method - * information - */ - public void testMethodAnnotatedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtMethod.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @method: public * foo.C.*(..) : @MyAnnotation"); - assertTrue("Should have 'amethod() annotated by " + - "declare @method: public * foo.C.*(..) : @MyAnnotation" + - "' in the Method Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @method: public * foo.C.*(..) : @MyAnnotation"); - assertTrue("Should have 'amethod() annotated by " + - "declare @method: public * foo.C.*(..) : @MyAnnotation" + - "' in the Method Summary section", b); - } - - /** - * The target of a declare method annotation should have the - * 'annotated by' relationship in the ajdoc within the method - * information - */ - public void testConstructorAnnotatedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtConstructor.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== CONSTRUCTOR DETAIL", - LangUtil.is11VMOrGreater()?"<init>(java.lang.String)":toName("C(java.lang.String)"), - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @constructor: foo.C.new(..) : @MyAnnotation"); - assertTrue("Should have '" + doIt + " annotated by " + - "declare @constructor: foo.C.new(..) : @MyAnnotation" + - "' in the Method Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== CONSTRUCTOR SUMMARY", - LangUtil.is11VMOrGreater()?"#%3Cinit%3E(java.lang.String)":toName("C(java.lang.String)"), - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @constructor: foo.C.new(..) : @MyAnnotation"); - assertTrue("Should have '" + doIt + " annotated by " + - "declare @constructor: foo.C.new(..) : @MyAnnotation" + - "' in the Method Summary section", b); - } - - /** - * The target of a declare method annotation should have the - * 'annotated by' relationship in the ajdoc within the method - * information - */ - public void testFieldAnnotatedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtField.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== FIELD DETAIL", - "x", - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @field: int foo.C.* : @MyAnnotation"); - assertTrue("Should have '" + doIt + " annotated by " + - "declare @field: int foo.C.* : @MyAnnotation" + - "' in the Field Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== FIELD SUMMARY", - "x", - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @field: int foo.C.* : @MyAnnotation"); - assertTrue("Should have '" + doIt + " annotated by " + - "declare @field: int foo.C.* : @MyAnnotation" + - "' in the Field Summary section", b); - } - - /** - * The target of a declare method annotation should have the - * 'annotated by' relationship in the ajdoc within the method - * information - */ - public void testTypeAnnotatedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareAtType.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - boolean b = AjdocOutputChecker.classDataSectionContainsRel( - htmlFile, - HtmlDecorator.HtmlRelationshipKind.ANNOTATED_BY, - "declare @type: foo.C : @MyAnnotation"); - assertTrue("The class data section should have 'annotated by" + - " declare @type: foo.C : @MyAnnotation'",b); - } - - /** - * Test that info for both "matches declare" and "advised by" - * appear in the ajdoc for a method when the method is affected - * by both. - */ - public void testMatchesDeclareAndAdvisedBy() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "A.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/C.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - "declare warning: quot;warningquot;"); - assertTrue("Should have 'amethod() matches declare declare warning: " + - "quot;warningquot;' in the Method Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.MATCHES_DECLARE, - "declare warning: quot;warningquot;"); - assertTrue("Should have 'amethod() matches declare declare warning: " + - "quot;warningquot;' in the Method Summary section", b); - - b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"=== METHOD DETAIL", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "before(): p.."); - assertTrue("the Method Detail should have amethod() advised by before(): p..",b); - - b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"=== METHOD SUMMARY", - toName("amethod()"), - HtmlDecorator.HtmlRelationshipKind.ADVISED_BY, - "before(): p.."); - assertTrue("the Method Summary should have amethod() advised by before(): p..",b); - } - - /** - * Test that if there are two declare parents statements within - * an aspect, one which extends and one which implements, that the - * ajdoc shows the correct information - */ - public void testTwoDeclareParents() throws Exception { - initialiseProject("declareForms"); - File[] files = {new File(getAbsoluteProjectDir() + File.separatorChar + "DeclareParents.aj")}; - runAjdoc("private","1.6",files); - - File htmlFile = new File(getAbsolutePathOutdir() + "/foo/DeclareParents.html"); - if (!htmlFile.exists()) { - fail("couldn't find " + htmlFile.getAbsolutePath() - + " - were there compilation errors?"); - } - - String[] strings = { - "declare parents: implements Serializable", - "HREF=\"../foo/Class1.html\"", - "declare parents: extends Observable", - "HREF=\"../foo/Class2.html\""}; - - // check that the correct declare statements are there - for (int i = 0; i < strings.length - 1; i = i+2) { - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY",strings[i], - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - strings[i+1]); - assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] + - "' in the Declare Detail section", b); - } - - for (int i = 0; i < strings.length - 1; i = i+2) { - boolean b = AjdocOutputChecker.summarySectionContainsRel( - htmlFile,"DECLARE SUMMARY", - strings[i], - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - strings[i+1]); - assertTrue("Should have ' " + strings[i] + " declared on " + strings[i+1] + - "' in the Declare Summary section", b); - } - - // check that we don't have declare statements for those that don't - // exist in the code - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlFile,"DECLARE DETAIL SUMMARY",strings[0], - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - strings[3]); - assertFalse("Should not have ' " + strings[0] + " declared on " + strings[3] + - "' in the Declare Detail section", b); - - } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java deleted file mode 100644 index 65ef3b3c9..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/EnumTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************** - * Copyright (c) 2005 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://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; - - -public class EnumTest extends AjdocTestCase { - - /** - * Test for pr122728 - no StringOutOfBoundsException - * when processing an Enum - */ - public void testEnum() throws Exception { - initialiseProject("pr122728"); - File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/MyEnum.java")}; - runAjdoc("private","1.5",files); - } - - /** - * Test for pr122728 - no StringOutOfBoundsException - * when processing an Enum - */ - public void testInlinedEnum() throws Exception { - initialiseProject("pr122728"); - File[] files = {new File(getAbsoluteProjectDir() + "/src/pack/ClassWithInnerEnum.java")}; - runAjdoc("private","1.5",files); - } - - /** - * Test for pr122728 - no StringOutOfBoundsException - * when processing an Enum - */ - public void testEnumWithMethods() throws Exception { - 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 deleted file mode 100644 index 837d7ef8c..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ExecutionTestCase.java +++ /dev/null @@ -1,37 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ - -package org.aspectj.tools.ajdoc; - -import java.io.File; - -import org.aspectj.bridge.Version; - -/** - * @author Mik Kersten - */ -public class ExecutionTestCase extends AjdocTestCase { - - public void testVersionMatch() { - String ajdocVersion = Main.getVersion(); - String compilerVersion = Version.text; - assertTrue("version check", ajdocVersion.endsWith(compilerVersion)); - } - - public void testFailingBuild() { - 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()); - } -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java deleted file mode 100644 index 2d97a82bf..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/FullyQualifiedArgumentTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************** - * Copyright (c) 2005 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://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.util.List; - -public class FullyQualifiedArgumentTest extends AjdocTestCase { - - /** - * Test for pr58520 - */ - public void testPr58520() throws Exception { - 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); - - // check the contents of A.html - File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html"); - if (!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)); - } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java deleted file mode 100644 index 899782d88..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/ITDTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/******************************************************************** - * Copyright (c) 2005 Contributors. All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://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.util.List; - -public class ITDTest extends AjdocTestCase { - - /** - * Test for pr119453 - */ - public void testITDDeclaredOn() throws Exception { - initialiseProject("pr119453"); - File[] files = { - new File(getAbsoluteProjectDir() + "/src/pack/C.java"), - new File(getAbsoluteProjectDir() + "/src/pack/A.aj") - }; - runAjdoc("private",files); - File htmlA = new File(getAbsolutePathOutdir() + "/pack/A.html"); - if (!htmlA.exists()) { - fail("couldn't find " + getAbsolutePathOutdir() + "/pack/A.html - were there compilation errors?"); - } - - // check field itd appears - boolean b = AjdocOutputChecker.detailSectionContainsRel( - htmlA,"DECLARE DETAIL SUMMARY", - "C.y", - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - "HREF=\"../pack/C.html\""); - assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" + - "' in the Declare Detail section", b); - b = AjdocOutputChecker.summarySectionContainsRel( - htmlA,"DECLARE SUMMARY", - "C.y", - HtmlDecorator.HtmlRelationshipKind.DECLARED_ON, - "HREF=\"../pack/C.html\""); - assertTrue("Should have 'C.y declared on HREF=\"../pack/C.html\"" + - "' in the Declare Summary section", b); - - // check the modifiers are correct in the declare detail summary - String[] stringsA = { "private int", - "public java.lang.String", - "<H3>C.y</H3>", - "public </TT><B>C.C", - "package void"}; - List 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 void", missing.get(0)); - - // check the modifiers are correct in the declare summary - String[] stringsA2 = {"private", "int", "public", "String", "package 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 void")); - - } - - /** - * Test for pr119453 - */ - public void testITDMatchesDeclare() throws Exception { - initialiseProject("pr119453"); - File[] files = { - new File(getAbsoluteProjectDir() + "/src/pack/C.java"), - new File(getAbsoluteProjectDir() + "/src/pack/A.aj") - }; - runAjdoc("private",files); - - // Check the contents of C.html - File htmlC = new File(getAbsolutePathOutdir() + "/pack/C.html"); - if (!htmlC.exists()) { - fail("couldn't find " + getAbsolutePathOutdir() - + "/pack/C.html - were there compilation errors?"); - } - - // 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 modifier information in 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)); - - 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); - - } - - /** - * Test that the ITD's do not appear in as 'aspect declarations' in the - * class data information. - */ - public void testNoAspectDeclarations() throws Exception { - initialiseProject("pr119453"); - File[] files = { - new File(getAbsoluteProjectDir() + "/src/pack/C.java"), - new File(getAbsoluteProjectDir() + "/src/pack/A.aj") - }; - runAjdoc("private",files); - - 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?"); - } - - boolean b = AjdocOutputChecker.classDataSectionContainsRel( - htmlC, - HtmlDecorator.HtmlRelationshipKind.ASPECT_DECLARATIONS, - "pack.A.C.y"); - assertFalse("The class data section should not have 'aspect declarations" + - " pack.A.C.y' since this is an ITD",b); - } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java deleted file mode 100644 index 33f0daecb..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/JDKVersionTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ -package org.aspectj.tools.ajdoc; - - -/** - * @author Mik Kersten - */ -public class JDKVersionTest extends AjdocTestCase { - -// public void testIsUsing1point4() { -// String v = System.getProperty("java.class.version","44.0"); -// assertTrue(("49.0".compareTo(v) > 0) && ("48.0".compareTo(v) <= 0)); -// assertFalse(Util.isExecutingOnJava5()); -// } - - public void testNothing() {} -// public void testIsUsing1point5() { -// assertTrue(Util.isExecutingOnJava5()); -// } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java deleted file mode 100644 index 61c0d67cd..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PatternsTestCase.java +++ /dev/null @@ -1,91 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ - -package org.aspectj.tools.ajdoc; - -import java.io.File; - -/** - * A long way to go until full coverage, but this is the place to add more. - * - * @author Mik Kersten - */ -public class PatternsTestCase extends AjdocTestCase { - - public void testSimpleExample() { - -// System.err.println(new File("testdata.figures-demo").exists()); -// File file1 = new File("testdata/patterns/allPatterns.lst"); - File outdir = new File("testdata/patterns/doc"); - File srcdir = new File("../../docs/sandbox/ubc-design-patterns/src"); - - String[] args = { -// "-XajdocDebug", - "-classpath", - AjdocTests.ASPECTJRT_PATH.getPath(), - "-d", - outdir.getAbsolutePath(), - "-sourcepath", - srcdir.getAbsolutePath(), - "ca.ubc.cs.spl.aspectPatterns.patternLibrary", - "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.java", - "ca.ubc.cs.spl.aspectPatterns.examples.abstractFactory.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.builder.java", - "ca.ubc.cs.spl.aspectPatterns.examples.builder.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.java", - "ca.ubc.cs.spl.aspectPatterns.examples.factoryMethod.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.prototype.java", - "ca.ubc.cs.spl.aspectPatterns.examples.prototype.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.singleton.java", - "ca.ubc.cs.spl.aspectPatterns.examples.singleton.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.adapter.java", - "ca.ubc.cs.spl.aspectPatterns.examples.adapter.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.bridge.java", - "ca.ubc.cs.spl.aspectPatterns.examples.bridge.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.composite.java", - "ca.ubc.cs.spl.aspectPatterns.examples.composite.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.decorator.java", - "ca.ubc.cs.spl.aspectPatterns.examples.decorator.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.facade.java", - "ca.ubc.cs.spl.aspectPatterns.examples.facade.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.java", - "ca.ubc.cs.spl.aspectPatterns.examples.flyweight.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.proxy.java", - "ca.ubc.cs.spl.aspectPatterns.examples.proxy.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.java", - "ca.ubc.cs.spl.aspectPatterns.examples.chainOfResponsibility.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.command.java", - "ca.ubc.cs.spl.aspectPatterns.examples.command.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.java", - "ca.ubc.cs.spl.aspectPatterns.examples.interpreter.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.iterator.java", - "ca.ubc.cs.spl.aspectPatterns.examples.iterator.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.mediator.java", - "ca.ubc.cs.spl.aspectPatterns.examples.mediator.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.memento.java", - "ca.ubc.cs.spl.aspectPatterns.examples.memento.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.observer.java", - "ca.ubc.cs.spl.aspectPatterns.examples.observer.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.state.java", - "ca.ubc.cs.spl.aspectPatterns.examples.state.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.strategy.java", - "ca.ubc.cs.spl.aspectPatterns.examples.strategy.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.java", - "ca.ubc.cs.spl.aspectPatterns.examples.templateMethod.aspectj", - "ca.ubc.cs.spl.aspectPatterns.examples.visitor.java", - "ca.ubc.cs.spl.aspectPatterns.examples.visitor.aspectj" - }; - - org.aspectj.tools.ajdoc.Main.main(args); - } - -} diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java deleted file mode 100644 index b3544d563..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/PointcutVisibilityTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ -package org.aspectj.tools.ajdoc; - -import java.io.File; -import java.util.List; - -/** - * @author Mik Kersten - */ -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.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")); - } - - /** - * 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.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.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 deleted file mode 100644 index 53f7a5ef9..000000000 --- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/SpacewarTestCase.java +++ /dev/null @@ -1,41 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2003 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Mik Kersten initial implementation - * ******************************************************************/ - package org.aspectj.tools.ajdoc; - -import java.io.File; - - -/** - * @author Mik Kersten - */ -public class SpacewarTestCase extends AjdocTestCase { - - private String[] dirs = {"spacewar","coordination"}; - - protected void setUp() throws Exception { - super.setUp(); - initialiseProject("spacewar"); - } - - public void testSimpleExample() { - runAjdoc(dirs); - } - - public void testPublicModeExample() { - runAjdoc("public",dirs); - } - - public void testPr134063() { - String lstFile = "spacewar" + File.separatorChar + "demo.lst"; - runAjdoc("private",lstFile); - } -} |