-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Uses Maven profiles to configure ITs to validate the Java version and run specific test suits for each Java version. Closes #126
- Loading branch information
1 parent
0af010a
commit 144704b
Showing
11 changed files
with
170 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ on: | |
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- ubuntu-latest | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
invoker.goals=clean javadoc:javadoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>test</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<description>Integration Test: generate Javadoc for class and method</description> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.6.3</version> | ||
<configuration> | ||
<source>17</source> | ||
<additionalJOptions> | ||
<additionalJOption>-J--add-exports=jdk.javadoc/jdk.javadoc.internal.tool=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-J--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</additionalJOption> | ||
<additionalJOption>-Xdoclint:all,-html,-accessibility</additionalJOption> | ||
</additionalJOptions> | ||
<doclet>org.asciidoctor.asciidoclet.Asciidoclet</doclet> | ||
<docletArtifacts> | ||
<docletArtifact> | ||
<groupId>org.asciidoctor</groupId> | ||
<artifactId>asciidoclet</artifactId> | ||
<version>@project.version@</version> | ||
</docletArtifact> | ||
</docletArtifacts> | ||
<overview>src/main/java/overview.adoc</overview> | ||
<additionalOptions> | ||
--base-dir ${project.basedir} | ||
--attribute "project_name=${project.name}" | ||
--attribute "project_description=${project.description}" | ||
</additionalOptions> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
18 changes: 18 additions & 0 deletions
18
src/it/java-17/class-comments/src/main/java/example/StringUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package example; | ||
|
||
/** | ||
* Class comment for "{project_description}". | ||
*/ | ||
public class StringUtils { | ||
|
||
/** | ||
* This is a method comment. | ||
* | ||
* @param haystack the haystack | ||
* @param needle it stings | ||
* @return true if lucky | ||
*/ | ||
public boolean contains(String haystack, String needle) { | ||
return haystack.contains(needle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
String javaVersion = System.getProperty('java.version').split("\\.")[0] | ||
if (javaVersion != expected_java) { | ||
throw new Exception("Invalid Java version. Expected ${expected_java}, found $javaVersion") | ||
} | ||
|
||
def javadocExpectedPath = Path.of((String) basedir).resolve('target/site/apidocs') | ||
def expectedJavadoc = javadocExpectedPath.resolve('example/StringUtils.html') | ||
|
||
if (Files.list(javadocExpectedPath).count() == 0) { | ||
throw new Exception("${javadocExpectedPath.toFile().getAbsolutePath()} path cannot me empty") | ||
} | ||
|
||
def javadocContent = Files.readString(expectedJavadoc) | ||
|
||
def expectClassDescription = Html.div(Html.p('Class comment for "Integration Test: generate Javadoc for class and method".'), 'block') | ||
def expectMethodDescription = Html.div(Html.p('This is a method comment.'), 'block') | ||
|
||
assertStringContains(javadocContent, expectClassDescription) | ||
assertStringContains(javadocContent, expectMethodDescription) | ||
|
||
def expectMethodArgument1 = Html.dd(Html.code('haystack') + " - the haystack") | ||
def expectMethodArgument2 = Html.dd(Html.code('needle') + " - it stings") | ||
|
||
assertStringContains(javadocContent, expectMethodArgument1) | ||
assertStringContains(javadocContent, expectMethodArgument2) | ||
|
||
def expectMethodReturn = Html.dt("Returns:") + System.lineSeparator() + Html.dd('true if lucky') | ||
|
||
assertStringContains(javadocContent, expectMethodReturn) | ||
|
||
|
||
void assertStringContains(String value, String expected) { | ||
if (!value.contains(expected)) { | ||
throw new Exception("'$expected' expected to be present") | ||
} | ||
} | ||
|
||
class Html { | ||
|
||
static String div(String text, String classname) { | ||
return "<div class=\"${classname}\">${text}</div>" | ||
} | ||
|
||
static String p(String text) { | ||
return "<p>${text}</p>" | ||
} | ||
|
||
static String code(String text) { | ||
return "<code>${text}</code>" | ||
} | ||
|
||
static String dd(String text) { | ||
return "<dd>${text}</dd>" | ||
} | ||
|
||
static String dt(String text) { | ||
return "<dt>${text}</dt>" | ||
} | ||
} | ||
|
||
return true |