aboutsummaryrefslogtreecommitdiffstats
path: root/ajdoc
diff options
context:
space:
mode:
authorAndy Clement <aclement@gopivotal.com>2014-10-06 17:35:51 -0700
committerAndy Clement <aclement@gopivotal.com>2014-10-06 17:35:51 -0700
commitc8e951296c5f95e82d4c7c3f8eb9b0a647014e20 (patch)
tree2eaed5b80ad735e4c91e424098e35e221f4fea44 /ajdoc
parent102173fc11fc6648ed8f2283d3c5ad535e412c73 (diff)
downloadaspectj-c8e951296c5f95e82d4c7c3f8eb9b0a647014e20.tar.gz
aspectj-c8e951296c5f95e82d4c7c3f8eb9b0a647014e20.zip
Fix 436653: conditional aspect activation plus various polish
Modified test expectation system so it is possible to say the test cares about one particular message and the rest do not matter (prefix message string with '*') - crude but quick. Polished many places to exploit generics Upgraded all the tests to work on Java8 - some serious changes regarding ajdoc on Java8. Hopefully it has stayed backwards compatible with earlier JDK versions (e.g. if using AspectJ 1.8.3+ with a JDK less than 8) but no explicit testing done for this.
Diffstat (limited to 'ajdoc')
-rw-r--r--ajdoc/.isJava51
-rw-r--r--ajdoc/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java28
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java10
-rw-r--r--ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java196
5 files changed, 189 insertions, 58 deletions
diff --git a/ajdoc/.isJava5 b/ajdoc/.isJava5
new file mode 100644
index 000000000..136d06384
--- /dev/null
+++ b/ajdoc/.isJava5
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/ajdoc/.settings/org.eclipse.jdt.core.prefs b/ajdoc/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 12ff67cd1..000000000
--- a/ajdoc/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,12 +0,0 @@
-#Thu Oct 06 08:32:56 PDT 2005
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.3
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
-org.eclipse.jdt.core.compiler.source=1.3
diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
index bad35529f..04af19f2d 100644
--- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
+++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java
@@ -224,7 +224,20 @@ class HtmlDecorator {
classStartIndex = fileContents.toString().indexOf("<H2>\nClass ");
br = false;
}
- if (classStartIndex != -1) {
+ if (classStartIndex == -1) {
+ // Java8 looks more like this:
+ // <h2 title="Class A" class="title">Class A</h2>
+ classStartIndex = fileContents.toString().indexOf("<h2 title=\"Class ");
+ int classEndIndex = fileContents.toString().indexOf("</h2>", classStartIndex);
+ if (classEndIndex != -1) {
+ // Convert it to "<h2 title="Aspect A" class="title">Aspect A</h2>"
+ String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
+ String aspectLine = classLine.replaceAll("Class ","Aspect ");
+ fileContents.delete(classStartIndex, classEndIndex);
+ fileContents.insert(classStartIndex, aspectLine);
+ }
+ }
+ else if (classStartIndex != -1) {
int classEndIndex = fileContents.toString().indexOf("</H2>", classStartIndex);
if (classStartIndex != -1 && classEndIndex != -1) {
String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
@@ -249,6 +262,19 @@ class HtmlDecorator {
fileContents.insert(secondClassStartIndex, sb.toString());
}
}
+ else {
+ // Java8:
+ // <pre>static class <span class="typeNameLabel">ClassA.InnerAspect</span>
+ classStartIndex = fileContents.toString().indexOf("class <span class=\"typeNameLabel\">");
+ int classEndIndex = fileContents.toString().indexOf("</span>", classStartIndex);
+ if (classEndIndex != -1) {
+ // Convert it to "aspect <span class="typeNameLabel">ClassA.InnerAspect</span>"
+ String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
+ String aspectLine = "aspect"+fileContents.substring(classStartIndex+5,classEndIndex);
+ fileContents.delete(classStartIndex, classEndIndex);
+ fileContents.insert(classStartIndex, aspectLine);
+ }
+ }
}
}
file.delete();
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
index 10e22fbf6..dbe5125c5 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
@@ -50,20 +50,18 @@ public class AjdocOutputChecker {
}
/**
- * Returns those strings from the given array which aren't in the
- * html file
+ * Returns those strings from the given array which aren't in the html file.
*
* @param htmlFile
* @param an array of requiredStrings
* @return a List of those strings not found
* @throws Exception
*/
- public static List /*String*/ getMissingStringsInFile(File htmlFile,
- String[] requiredStrings) throws Exception {
- List missingStrings = new ArrayList();
+ 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)) {
+ if (!containsString(htmlFile, string)) {
missingStrings.add(string);
}
}
diff --git a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
index 0c0a0f268..afa27b319 100644
--- a/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
+++ b/ajdoc/testsrc/org/aspectj/tools/ajdoc/CoverageTestCase.java
@@ -14,8 +14,11 @@
import java.io.File;
import java.util.List;
+import org.aspectj.util.FileUtil;
import org.aspectj.util.LangUtil;
+import com.sun.org.apache.xml.internal.serializer.utils.Utils;
+
/**
* A long way to go until full coverage, but this is the place to add more.
@@ -128,14 +131,39 @@ public class CoverageTestCase extends AjdocTestCase {
// ensure that the file is entitled "Aspect ClassA.InnerAspect" rather
// than "Class ClassA.InnerAspect"
- String[] strings = { "Aspect 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 missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
- assertEquals("There should be 2 missing strings",2,missing.size());
- assertTrue(htmlFile.getName() + " should not have Class as it's title",missing.contains("Class ClassA.InnerAspect"));
- assertTrue(htmlFile.getName() + " should not have class in its subtitle",missing.contains("<PRE>static class <B>ClassA.InnerAspect</B><DT>extends java.lang.Object</DL>"));
+ }
+ 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");
@@ -146,14 +174,33 @@ public class CoverageTestCase extends AjdocTestCase {
// ensure that the file is entitled "Class ClassA" and
// has not been changed to "Aspect ClassA"
- String[] classStrings = { "Class ClassA</H2>",
- "public abstract class <B>ClassA</B><DT>extends java.lang.Object<DT>",
+ 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 <B>ClassA</B><DT>extends java.lang.Object<DT>"};
+ "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",2,classMissing.size());
+ 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>"));
- assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",classMissing.contains("public abstract aspect <B>ClassA</B><DT>extends java.lang.Object<DT>"));
+ 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>"));
+ }
}
/**
@@ -623,15 +670,32 @@ public class CoverageTestCase extends AjdocTestCase {
// ensure that the file is entitled "Aspect PkgVisibleClass.NestedAspect" rather
// than "Class PkgVisibleClass.NestedAspect"
- String[] strings = { "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 missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ 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"));
- 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>"));
-
+ 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()) {
@@ -641,14 +705,33 @@ public class CoverageTestCase extends AjdocTestCase {
// ensure that the file is entitled "Class PkgVisibleClass" and
// has not been changed to "Aspect PkgVisibleClass"
- String[] classStrings = { "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 classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ 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());
- 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>"));
+ 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>"));
+ }
}
/**
@@ -668,14 +751,31 @@ public class CoverageTestCase extends AjdocTestCase {
}
// ensure that the file is entitled "Aspect ClassWithNestedAspect.NestedAspect"
// rather than "Class ClassWithNestedAspect.NestedAspect"
- String[] strings = { "Aspect ClassWithNestedAspect.NestedAspect",
- "<PRE>static aspect <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>",
+ 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 <B>ClassWithNestedAspect.NestedAspect</B><DT>extends java.lang.Object</DL>"};
- List missing = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
+ "<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"));
- 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>"));
+ 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");
@@ -686,17 +786,35 @@ public class CoverageTestCase extends AjdocTestCase {
// ensure that the file is entitled "Class ClassWithNestedAspect" and
// has not been changed to "Aspect ClassWithNestedAspect"
- String[] classStrings = { "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 classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
+ 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());
- 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>"));
-
+ 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>"));
+ }
}
/**