fix junit dep / jdk11+ build

This commit is contained in:
Laurent SCHOELENS 2023-03-24 16:11:29 +01:00
parent cd8c3629a1
commit d273b6a3ef
7 changed files with 83 additions and 39 deletions

10
pom.xml
View File

@ -42,6 +42,15 @@
<artifactId>oss-parent</artifactId> <artifactId>oss-parent</artifactId>
<version>9</version> <version>9</version>
</parent> </parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build> <build>
<resources> <resources>
@ -132,6 +141,7 @@
<option>--link="https://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/"</option> <option>--link="https://docs.oracle.com/javase/7/docs/jdk/api/javadoc/doclet/"</option>
<option>--link="https://download.oracle.com/javase/7/docs/api/"</option> <option>--link="https://download.oracle.com/javase/7/docs/api/"</option>
</additionalOptions> </additionalOptions>
<detectJavaApiLink>false</detectJavaApiLink>
<useStandardDocletOptions>true</useStandardDocletOptions> <useStandardDocletOptions>true</useStandardDocletOptions>
</configuration> </configuration>
<executions> <executions>

View File

@ -285,7 +285,7 @@ public class Options implements Cloneable, OptionProvider {
return true; return true;
} }
}, },
new Option("-output", true, "Specify the output file (default <code>graph.dot</code>).\n" new Option("--output", true, "Specify the output file (default <code>graph.dot</code>).\n"
+ "If the output directory is provided, -output can only specify a file name,\n" + "If the output directory is provided, -output can only specify a file name,\n"
+ "otherwise a full path is accepted as well.\n" + "otherwise a full path is accepted as well.\n"
+ "If the filename specified is a dash, then the results are printed on the\n" + "If the filename specified is a dash, then the results are printed on the\n"
@ -507,13 +507,6 @@ public class Options implements Cloneable, OptionProvider {
} }
}, },
new Option("-hideGenerics", false, "?", null) {
@Override
public boolean process(String option, List<String> arguments) {
hideGenerics = true;
return true;
}
},
new Option("--link", true, "A clone of the standard doclet\n" new Option("--link", true, "A clone of the standard doclet\n"
+ "<a href=\"http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#link\">-link</a>\n" + "<a href=\"http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/javadoc.html#link\">-link</a>\n"
+ "option, allows UMLGraph to generate links from class symbols to their external javadoc\n" + "option, allows UMLGraph to generate links from class symbols to their external javadoc\n"

View File

@ -66,13 +66,16 @@ public class UmlGraph implements Doclet {
private Reporter reporter; private Reporter reporter;
private Options options; private Options options;
private StandardDoclet standard; private StandardDoclet standard;
public UmlGraph() {
this.options = new Options();
this.standard = new StandardDoclet();
}
@Override @Override
public void init(Locale locale, Reporter reporter) { public void init(Locale locale, Reporter reporter) {
this.locale = locale; this.locale = locale;
this.reporter = reporter; this.reporter = reporter;
this.options = new Options();
this.standard = new StandardDoclet();
} }
@Override @Override
@ -233,8 +236,9 @@ public class UmlGraph implements Doclet {
} }
return views; return views;
} else } else {
return Collections.emptyList(); return Collections.emptyList();
}
} }
/** /**

View File

@ -26,6 +26,14 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.umlgraph.doclet.UmlGraph;
/** /**
* UmlGraph regression tests * UmlGraph regression tests
* @author wolf * @author wolf
@ -41,12 +49,15 @@ public class BasicTest {
static PrintWriter pw = new PrintWriter(System.out); static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) throws IOException { @Test
@Ignore
public void test() throws IOException {
List<String> differences = new ArrayList<String>(); List<String> differences = new ArrayList<String>();
File outFolder = new File(testDestFolder); File outFolder = new File(testDestFolder);
if (!outFolder.exists()) if (!outFolder.exists()) {
outFolder.mkdirs(); outFolder.mkdirs();
}
TestUtils.cleanFolder(outFolder, true); TestUtils.cleanFolder(outFolder, true);
@ -64,14 +75,14 @@ public class BasicTest {
pw.println(); pw.println();
pw.println(); pw.println();
pw.flush(); pw.flush();
System.exit(differences.size() > 0 ? 1 : 0); Assert.assertEquals("Some differences found " + differences.size(), 0, differences.size());
} }
private static void performViewTests(List<String> differences, File outFolder) private static void performViewTests(List<String> differences, File outFolder)
throws IOException { throws IOException {
String[] options = new String[] { "-docletpath", "build", "-private", "-d", String[] options = new String[] { "--docletpath=build", "-private",
outFolder.getAbsolutePath(), "-sourcepath", "testdata/java", "-compact", "--d=\"" + outFolder.getAbsolutePath() + "\"", "--sourcepath=\"testdata/java\"", "-compact",
"-subpackages", "gr.spinellis", "-views" }; "--subpackages=\"gr.spinellis\"", "-views" };
runDoclet(options); runDoclet(options);
List<String> viewFiles = new ArrayList<String>(); List<String> viewFiles = new ArrayList<String>();
@ -118,8 +129,8 @@ public class BasicTest {
dotFile.delete(); dotFile.delete();
File refFile = new File(testRefFolder, outFileName); File refFile = new File(testRefFolder, outFileName);
String javaPath = new File(testSourceFolder, javaFiles[i]).getAbsolutePath(); String javaPath = new File(testSourceFolder, javaFiles[i]).getAbsolutePath();
String[] options = new String[] { "-docletpath", "build", "-hide", "Hidden", String[] options = new String[] { "--docletpath=build", "--hide=\"Hidden\"",
"-compact", "-private", "-d", testDestFolder, "-output", outFileName, javaPath }; "-compact", "-private", "--d=\"" + testDestFolder + "\"", "--output=\"" + outFileName + "\"", javaPath };
runDoclet(options); runDoclet(options);
compare(differences, dotFile, refFile); compare(differences, dotFile, refFile);
@ -128,8 +139,9 @@ public class BasicTest {
} }
private static void runDoclet(String[] options) { private static void runDoclet(String[] options) {
com.sun.tools.javadoc.Main.execute("UMLGraph test", pw, pw, pw, DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
"org.umlgraph.doclet.UmlGraph", options); DocumentationTool.DocumentationTask task = systemDocumentationTool.getTask(pw, null, null, UmlGraph.class, Arrays.asList(options), null);
task.call();
} }
private static void compare(List<String> differences, File dotFile, File refFile) private static void compare(List<String> differences, File dotFile, File refFile)

View File

@ -21,6 +21,12 @@ package org.umlgraph.test;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Arrays;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.umlgraph.doclet.UmlGraphDoc;
public class RunDoc { public class RunDoc {
@ -34,14 +40,15 @@ public class RunDoc {
File outFolder = new File(docFolder); File outFolder = new File(docFolder);
if (!outFolder.exists()) if (!outFolder.exists())
outFolder.mkdirs(); outFolder.mkdirs();
String[] options = new String[] { "-docletpath", "build", "-private", "-d", docFolder, String[] options = new String[] { "-docletpath", "build", "-private", "--d", docFolder,
"-sourcepath", sourcesFolder, "-subpackages", "gr.spinellis" }; "-sourcepath", sourcesFolder, "-subpackages", "gr.spinellis" };
runDoclet(options); runDoclet(options);
} }
private static void runDoclet(String[] options) { private static void runDoclet(String[] options) {
com.sun.tools.javadoc.Main.execute("UMLGraph test", pw, pw, pw, DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
"org.umlgraph.doclet.UmlGraphDoc", options); DocumentationTool.DocumentationTask task = systemDocumentationTool.getTask(pw, null, null, UmlGraphDoc.class, Arrays.asList(options), null);
task.call();
} }
} }

View File

@ -21,6 +21,12 @@ package org.umlgraph.test;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Arrays;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.umlgraph.doclet.UmlGraph;
public class RunOne { public class RunOne {
@ -53,8 +59,8 @@ public class RunOne {
} }
private static void runDoclet(String[] options) { private static void runDoclet(String[] options) {
com.sun.tools.javadoc.Main.execute("UMLGraph test", pw, pw, pw, "org.umlgraph.doclet.UmlGraph", options); DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
DocumentationTool.DocumentationTask task = systemDocumentationTool.getTask(pw, null, null, UmlGraph.class, Arrays.asList(options), null);
task.call();
} }
} }

View File

@ -25,6 +25,13 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.junit.Ignore;
import org.junit.Test;
import org.umlgraph.doclet.UmlGraphDoc;
/** /**
* UmlGraphDoc doclet regression tests * UmlGraphDoc doclet regression tests
* @author wolf * @author wolf
@ -41,7 +48,9 @@ public class UmlDocTest {
static PrintWriter pw = new PrintWriter(System.out); static PrintWriter pw = new PrintWriter(System.out);
public static void main(String[] args) throws IOException { @Test
@Ignore
public void test() throws IOException {
List<String> differences = new ArrayList<String>(); List<String> differences = new ArrayList<String>();
File outFolder = new File(testDestFolder); File outFolder = new File(testDestFolder);
@ -68,10 +77,11 @@ public class UmlDocTest {
private static void runTest(List<String> differences) throws IOException { private static void runTest(List<String> differences) throws IOException {
File outFolder = new File(testDestFolder); File outFolder = new File(testDestFolder);
String[] options = new String[] { "-docletpath", "build", "-private", "-d", File srcFolder = new File(testSourceFolder);
outFolder.getAbsolutePath(), "-sourcepath", testSourceFolder, "-compact", String[] options = new String[] { "-private", "--d=\"" + outFolder.getAbsolutePath() + "\"",
"--source-path=\"" + srcFolder.getAbsolutePath() + "\"", "-compact",
"-subpackages", "gr.spinellis", "-inferrel", "-inferdep", "-qualify", "-subpackages", "gr.spinellis", "-inferrel", "-inferdep", "-qualify",
"-postfixpackage", "-collpackages", "java.util.*" }; "-postfixpackage", "--collpackages=\"java.util.*\"" };
runDoclet(options); runDoclet(options);
compareDocletOutputs(differences, new File(testRefFolder), new File(testDestFolder)); compareDocletOutputs(differences, new File(testRefFolder), new File(testDestFolder));
@ -119,8 +129,9 @@ public class UmlDocTest {
differences.add(out.getName() + " is different from the reference"); differences.add(out.getName() + " is different from the reference");
} else { } else {
if (!TestUtils.textFilesEquals(pw, ref, out)) if (!TestUtils.textFilesEquals(pw, ref, out)) {
differences.add(out.getName() + " is different from the reference"); differences.add(out.getName() + " is different from the reference");
}
} }
i++; i++;
j++; j++;
@ -146,13 +157,14 @@ public class UmlDocTest {
* @param options * @param options
*/ */
private static void runDoclet(String[] options) { private static void runDoclet(String[] options) {
pw.print("Run javadoc -doclet " + doclet); pw.print("Run javadoc -doclet " + doclet);
for (String o : options) for (String o : options) {
pw.print(" " + o); pw.print(" " + o);
pw.println(); }
com.sun.tools.javadoc.Main.execute("UMLDoc test", pw, pw, pw, pw.println();
doclet, options); DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
System.exit(0); DocumentationTool.DocumentationTask task = systemDocumentationTool.getTask(pw, null, null, UmlGraphDoc.class, Arrays.asList(options), null);
task.call();
} }
} }