diff options
author | Andy Clement <aclement@pivotal.io> | 2019-11-25 10:40:44 -0800 |
---|---|---|
committer | Andy Clement <aclement@pivotal.io> | 2019-11-25 10:40:44 -0800 |
commit | 2704db20ecca12d3bbe514a4f7b84d297937de86 (patch) | |
tree | 2938cb6c560d2ea220272af703452ccd096702ca /ajdoc/src | |
parent | 41c7347b064093b531b04004d42665582ba0fff0 (diff) | |
download | aspectj-2704db20ecca12d3bbe514a4f7b84d297937de86.tar.gz aspectj-2704db20ecca12d3bbe514a4f7b84d297937de86.zip |
Java 13 support
Diffstat (limited to 'ajdoc/src')
-rw-r--r-- | ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java | 37 | ||||
-rw-r--r-- | ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java | 283 |
2 files changed, 172 insertions, 148 deletions
diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java index ec492fce9..7dd50b4ef 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -1,14 +1,14 @@ /* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, + * Copyright (c) 1999-2001 Xerox Corporation, * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Xerox/PARC initial implementation * Mik Kersten port to AspectJ 1.1+ code base * ******************************************************************/ @@ -77,7 +77,7 @@ class HtmlDecorator { /** * Before attempting to decorate the HTML file we have to verify that it exists, which depends on the documentation visibility * specified to c. - * + * * Depending on docModifier, can document - public: only public - protected: protected and public (default) - package: package * protected and public - private: everything */ @@ -229,6 +229,11 @@ class HtmlDecorator { // <h2 title="Class A" class="title">Class A</h2> classStartIndex = fileContents.toString().indexOf("<h2 title=\"Class "); int classEndIndex = fileContents.toString().indexOf("</h2>", classStartIndex); + if (classStartIndex == -1) { + // Java 13 - replaced h2 with h1 here + classStartIndex = fileContents.toString().indexOf("<h1 title=\"Class "); + classEndIndex = fileContents.toString().indexOf("</h1>", classStartIndex); + } if (classEndIndex != -1) { // Convert it to "<h2 title="Aspect A" class="title">Aspect A</h2>" String classLine = fileContents.toString().substring(classStartIndex, classEndIndex); @@ -307,7 +312,7 @@ class HtmlDecorator { insertDeclarationsSummary(fileBuffer, constDeclaredOn, ITD_CONSTRUCTOR_SUMMARY, index); } for (Iterator<IProgramElement> it = node.getChildren().iterator(); it.hasNext();) { - IProgramElement member = (IProgramElement) it.next(); + IProgramElement member = it.next(); if (member.getKind().equals(IProgramElement.Kind.POINTCUT)) { pointcuts.add(member); } else if (member.getKind().equals(IProgramElement.Kind.ADVICE)) { @@ -737,7 +742,7 @@ class HtmlDecorator { /** * Generates a relative directory path fragment that can be used to navigate "upwards" from the directory location implied by * the argument. - * + * * @param packagePath * @return String consisting of multiple "../" parts, one for each component part of the input <code>packagePath</code>. */ @@ -758,7 +763,7 @@ class HtmlDecorator { * Generate the "public int"-type information about the given IProgramElement. Used when dealing with ITDs. To mirror the * behaviour of methods and fields in classes, if we're generating the summary information we don't want to include "public" if * the accessibility of the IProgramElement is public. - * + * */ private static String generateModifierInformation(IProgramElement decl, boolean isDetails) { String intro = ""; @@ -828,7 +833,7 @@ class HtmlDecorator { * the characters between the /** that begins the comment and the 'star-slash' that ends it. The text is devided into one or * more lines. On each of these lines, the leading * characters are ignored; for lines other than the first, blanks and tabs * preceding the initial * characters are also discarded.</I> - * + * * TODO: implement formatting or linking for tags. */ static String getFormattedComment(IProgramElement decl) { @@ -883,11 +888,11 @@ class HtmlDecorator { static public IProgramElement[] getProgramElements(AsmManager model, String filename) { - IProgramElement file = (IProgramElement) model.getHierarchy().findElementForSourceFile(filename); + IProgramElement file = model.getHierarchy().findElementForSourceFile(filename); final List nodes = new ArrayList(); HierarchyWalker walker = new HierarchyWalker() { public void preProcess(IProgramElement node) { - IProgramElement p = (IProgramElement) node; + IProgramElement p = node; if (accept(node)) nodes.add(p); } diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java index c92e96d2e..61172346c 100644 --- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java +++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java @@ -1,13 +1,13 @@ /* ******************************************************************* * 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 + * 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; @@ -18,21 +18,21 @@ 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 = { + String[] args = { "-private", "-encoding", "EUCJIS", @@ -42,21 +42,21 @@ public class CoverageTestCase extends AjdocTestCase { "UTF-8", "-classpath", AjdocTests.ASPECTJRT_PATH.getPath(), - "-d", + "-d", getAbsolutePathOutdir(), - file0.getAbsolutePath(), + file0.getAbsolutePath(), }; org.aspectj.tools.ajdoc.Main.main(args); assertTrue(true); } - + /** - * Test the "-public" argument + * 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 @@ -69,7 +69,7 @@ public class CoverageTestCase extends AjdocTestCase { 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. @@ -81,7 +81,7 @@ public class CoverageTestCase extends AjdocTestCase { 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" */ @@ -91,13 +91,13 @@ public class CoverageTestCase extends AjdocTestCase { 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" + * Test that the ajdoc for a class has the title "Class" */ public void testAJdocHasClassTitle() throws Exception { File[] files = {new File(getAbsoluteProjectDir() + "/pkg/C.java")}; @@ -105,29 +105,29 @@ public class CoverageTestCase extends AjdocTestCase { 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" + * than "Class", but that the enclosing class is still "Class" */ public void testInnerAspect() throws Exception { File[] files = {file1, file2}; runAjdoc("private",AJDocConstants.VERSION,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[] { @@ -160,26 +160,31 @@ public class CoverageTestCase extends AjdocTestCase { 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()) { + + if (LangUtil.is13VMOrGreater()) { + classStrings = new String[] { + "Class ClassA</h1>", + "public abstract class <span class=\"typeNameLabel\">ClassA</span>", + "Aspect ClassA</H2>", + "public abstract aspect <span class=\"typeNameLabel\">ClassA</span>"}; + } else 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 { + } else { classStrings = new String[] { "Class ClassA</H2>", "public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>", @@ -191,29 +196,29 @@ public class CoverageTestCase extends AjdocTestCase { 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>")); + 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 + * with the named pointcut in it's description */ public void testAdviceNamingCoverage() throws Exception { File[] files = {file4}; runAjdoc("private",AJDocConstants.VERSION,files); - + File htmlFile = new File(getAbsolutePathOutdir() + "/foo/AdviceNamingCoverage.html"); if (!htmlFile.exists()) { fail("couldn't find " + htmlFile.getAbsolutePath() + " - were there compilation errors?"); } - - String[] strings = { + + String[] strings = { "after(): named..", "afterReturning(int,int): namedWithArgs..", "afterThrowing(): named..", @@ -231,19 +236,19 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that all the advises relationships appear in the + * Test that all the advises relationships appear in the * Advice Detail and Advice Summary sections and that - * the links are correct + * the links are correct */ public void testAdvisesRelationshipCoverage() throws Exception { File[] files = {file4}; runAjdoc("private",AJDocConstants.VERSION,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)\"", @@ -264,39 +269,39 @@ public class CoverageTestCase extends AjdocTestCase { "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] + + 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] + + 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 + * 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",AJDocConstants.VERSION,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..\""}; @@ -306,7 +311,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -314,20 +319,20 @@ public class CoverageTestCase extends AjdocTestCase { 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 + * 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",AJDocConstants.VERSION,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..\""}; @@ -351,20 +356,20 @@ public class CoverageTestCase extends AjdocTestCase { 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 + * 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",AJDocConstants.VERSION,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..\""}; @@ -374,7 +379,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -384,18 +389,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a constructor call pointcut + * 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",AJDocConstants.VERSION,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..\""}; @@ -405,7 +410,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -415,18 +420,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a get pointcut + * 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",AJDocConstants.VERSION,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..\""}; @@ -436,7 +441,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -446,18 +451,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a set pointcut + * 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",AJDocConstants.VERSION,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", @@ -465,7 +470,7 @@ public class CoverageTestCase extends AjdocTestCase { 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)"), @@ -479,7 +484,7 @@ public class CoverageTestCase extends AjdocTestCase { 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()"), @@ -495,18 +500,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with an initialization pointcut + * 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",AJDocConstants.VERSION,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..\""}; @@ -527,18 +532,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a staticinitialization pointcut + * 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",AJDocConstants.VERSION,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, @@ -548,18 +553,18 @@ public class CoverageTestCase extends AjdocTestCase { } /** - * Test that the advised by relationship appears in the ajdoc when the - * advice is associated with a handler pointcut + * 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",AJDocConstants.VERSION,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..\""}; @@ -569,7 +574,7 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -587,17 +592,17 @@ public class CoverageTestCase extends AjdocTestCase { } /** * Test that if have two before advice blocks from the same - * aspect affect the same method, then both appear in the ajdoc + * 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",AJDocConstants.VERSION,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..\"", @@ -608,21 +613,21 @@ public class CoverageTestCase extends AjdocTestCase { 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], @@ -630,7 +635,7 @@ public class CoverageTestCase extends AjdocTestCase { 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 @@ -638,12 +643,12 @@ public class CoverageTestCase extends AjdocTestCase { public void testNoSpuriousAdvisedByRels() throws Exception { File[] files = {file4}; runAjdoc("private",AJDocConstants.VERSION,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, @@ -652,40 +657,40 @@ public class CoverageTestCase extends AjdocTestCase { 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()) + * 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",AJDocConstants.VERSION,files); - + runAjdoc("private",AJDocConstants.VERSION,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[] { + 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[] { + strings = new String[] { "Aspect PkgVisibleClass.NestedAspect", "<PRE>static aspect <B>PkgVisibleClass.NestedAspect</B><DT>extends java.lang.Object</DL>", "Class PkgVisibleClass.NestedAspect", @@ -708,10 +713,17 @@ public class CoverageTestCase extends AjdocTestCase { 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.is13VMOrGreater()) { + classStrings = new String[] { + "Class PkgVisibleClass</h1>", + "<pre>class <span class=\"typeNameLabel\">PkgVisibleClass</span>", + "Aspect PkgVisibleClass</h2>", + "<pre>aspect <span class=\"typeNameLabel\">PkgVisibleClass</span>"}; + } else if (LangUtil.is18VMOrGreater()) { classStrings = new String[] { "Class PkgVisibleClass</h2>", @@ -742,20 +754,20 @@ public class CoverageTestCase extends AjdocTestCase { /** * Test that in the case when you have a nested aspect whose - * name is part of the enclosing class, for example a class called + * 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",AJDocConstants.VERSION,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" + // ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect" // rather than "Class ClassWithNestedAspect.NestedAspect" String[] strings = null; if (LangUtil.is18VMOrGreater()) { @@ -770,7 +782,7 @@ public class CoverageTestCase extends AjdocTestCase { "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>"}; + "<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()); @@ -782,26 +794,33 @@ public class CoverageTestCase extends AjdocTestCase { 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.is13VMOrGreater()) { + classStrings = new String[] { + "Class ClassWithNestedAspect</h1>", + "public class <span class=\"typeNameLabel\">ClassWithNestedAspect</span>", + "Aspect ClassWithNestedAspect</h2>", + "public aspect <span class=\"typeNameLabel\">ClassWithNestedAspect</span>"}; + } else if (LangUtil.is18VMOrGreater()) { - classStrings = new String[] { + 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[] { + classStrings = new String[] { "Class ClassWithNestedAspect</H2>", "public class <B>ClassWithNestedAspect</B><DT>extends java.lang.Object</DL>", "Aspect ClassWithNestedAspect</H2>", @@ -822,7 +841,7 @@ public class CoverageTestCase extends AjdocTestCase { 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 @@ -830,13 +849,13 @@ public class CoverageTestCase extends AjdocTestCase { public void testAdviceInNestedAspect() throws Exception { File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")}; runAjdoc("private",AJDocConstants.VERSION,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..", @@ -853,7 +872,7 @@ public class CoverageTestCase extends AjdocTestCase { "' 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 @@ -861,13 +880,13 @@ public class CoverageTestCase extends AjdocTestCase { public void testAdvisedByInNestedAspect() throws Exception { File[] files = {new File(getAbsoluteProjectDir() + "/pkg/ClassWithNestedAspect.java")}; runAjdoc("private",AJDocConstants.VERSION,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 "); @@ -876,7 +895,7 @@ public class CoverageTestCase extends AjdocTestCase { 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()"), @@ -914,7 +933,7 @@ public class CoverageTestCase extends AjdocTestCase { " in the Method Summary section", b); } - + private void createFiles() { file0 = new File(getAbsoluteProjectDir() + "/InDefaultPackage.java"); file1 = new File(getAbsoluteProjectDir() + "/foo/ClassA.java"); @@ -929,12 +948,12 @@ public class CoverageTestCase extends AjdocTestCase { file9 = new File(getAbsoluteProjectDir() + "/foo/PkgVisibleClass.java"); file10 = new File(getAbsoluteProjectDir() + "/foo/NoMembers.java"); } - + // public void testPlainJava() { -// String[] args = { "-d", +// String[] args = { "-d", // getAbsolutePathOutdir(), // file3.getAbsolutePath() }; // org.aspectj.tools.ajdoc.Main.main(args); // } - + } |