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

@ -43,6 +43,15 @@
<version>9</version>
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
@ -132,6 +141,7 @@
<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>
</additionalOptions>
<detectJavaApiLink>false</detectJavaApiLink>
<useStandardDocletOptions>true</useStandardDocletOptions>
</configuration>
<executions>

View File

@ -285,7 +285,7 @@ public class Options implements Cloneable, OptionProvider {
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"
+ "otherwise a full path is accepted as well.\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"
+ "<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"

View File

@ -67,12 +67,15 @@ public class UmlGraph implements Doclet {
private Options options;
private StandardDoclet standard;
public UmlGraph() {
this.options = new Options();
this.standard = new StandardDoclet();
}
@Override
public void init(Locale locale, Reporter reporter) {
this.locale = locale;
this.reporter = reporter;
this.options = new Options();
this.standard = new StandardDoclet();
}
@Override
@ -233,9 +236,10 @@ public class UmlGraph implements Doclet {
}
return views;
} else
} else {
return Collections.emptyList();
}
}
/**
* Builds a view along with its parent views, recursively

View File

@ -26,6 +26,14 @@ import java.util.ArrayList;
import java.util.Arrays;
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
* @author wolf
@ -41,12 +49,15 @@ public class BasicTest {
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>();
File outFolder = new File(testDestFolder);
if (!outFolder.exists())
if (!outFolder.exists()) {
outFolder.mkdirs();
}
TestUtils.cleanFolder(outFolder, true);
@ -64,14 +75,14 @@ public class BasicTest {
pw.println();
pw.println();
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)
throws IOException {
String[] options = new String[] { "-docletpath", "build", "-private", "-d",
outFolder.getAbsolutePath(), "-sourcepath", "testdata/java", "-compact",
"-subpackages", "gr.spinellis", "-views" };
String[] options = new String[] { "--docletpath=build", "-private",
"--d=\"" + outFolder.getAbsolutePath() + "\"", "--sourcepath=\"testdata/java\"", "-compact",
"--subpackages=\"gr.spinellis\"", "-views" };
runDoclet(options);
List<String> viewFiles = new ArrayList<String>();
@ -118,8 +129,8 @@ public class BasicTest {
dotFile.delete();
File refFile = new File(testRefFolder, outFileName);
String javaPath = new File(testSourceFolder, javaFiles[i]).getAbsolutePath();
String[] options = new String[] { "-docletpath", "build", "-hide", "Hidden",
"-compact", "-private", "-d", testDestFolder, "-output", outFileName, javaPath };
String[] options = new String[] { "--docletpath=build", "--hide=\"Hidden\"",
"-compact", "-private", "--d=\"" + testDestFolder + "\"", "--output=\"" + outFileName + "\"", javaPath };
runDoclet(options);
compare(differences, dotFile, refFile);
@ -128,8 +139,9 @@ public class BasicTest {
}
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();
}
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.PrintWriter;
import java.util.Arrays;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.umlgraph.doclet.UmlGraphDoc;
public class RunDoc {
@ -34,14 +40,15 @@ public class RunDoc {
File outFolder = new File(docFolder);
if (!outFolder.exists())
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" };
runDoclet(options);
}
private static void runDoclet(String[] options) {
com.sun.tools.javadoc.Main.execute("UMLGraph test", pw, pw, pw,
"org.umlgraph.doclet.UmlGraphDoc", options);
DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
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.PrintWriter;
import java.util.Arrays;
import javax.tools.DocumentationTool;
import javax.tools.ToolProvider;
import org.umlgraph.doclet.UmlGraph;
public class RunOne {
@ -53,8 +59,8 @@ public class RunOne {
}
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.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
* @author wolf
@ -41,7 +48,9 @@ public class UmlDocTest {
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>();
File outFolder = new File(testDestFolder);
@ -68,10 +77,11 @@ public class UmlDocTest {
private static void runTest(List<String> differences) throws IOException {
File outFolder = new File(testDestFolder);
String[] options = new String[] { "-docletpath", "build", "-private", "-d",
outFolder.getAbsolutePath(), "-sourcepath", testSourceFolder, "-compact",
File srcFolder = new File(testSourceFolder);
String[] options = new String[] { "-private", "--d=\"" + outFolder.getAbsolutePath() + "\"",
"--source-path=\"" + srcFolder.getAbsolutePath() + "\"", "-compact",
"-subpackages", "gr.spinellis", "-inferrel", "-inferdep", "-qualify",
"-postfixpackage", "-collpackages", "java.util.*" };
"-postfixpackage", "--collpackages=\"java.util.*\"" };
runDoclet(options);
compareDocletOutputs(differences, new File(testRefFolder), new File(testDestFolder));
@ -119,9 +129,10 @@ public class UmlDocTest {
differences.add(out.getName() + " is different from the reference");
} else {
if (!TestUtils.textFilesEquals(pw, ref, out))
if (!TestUtils.textFilesEquals(pw, ref, out)) {
differences.add(out.getName() + " is different from the reference");
}
}
i++;
j++;
} else if (compare < 0) {
@ -147,12 +158,13 @@ public class UmlDocTest {
*/
private static void runDoclet(String[] options) {
pw.print("Run javadoc -doclet " + doclet);
for (String o : options)
for (String o : options) {
pw.print(" " + o);
}
pw.println();
com.sun.tools.javadoc.Main.execute("UMLDoc test", pw, pw, pw,
doclet, options);
System.exit(0);
DocumentationTool systemDocumentationTool = ToolProvider.getSystemDocumentationTool();
DocumentationTool.DocumentationTask task = systemDocumentationTool.getTask(pw, null, null, UmlGraphDoc.class, Arrays.asList(options), null);
task.call();
}
}