From 01e7e776e2af1938f4a1daac08078284913994a1 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Tue, 21 Jun 2022 09:13:51 +0200 Subject: [PATCH 2/2] [it] Add test for javadoc MOJO toolchains --- .../JavadocToolchainsIntegrationTest.java | 39 +++++++++++++++++++ .../.xmvn/configuration.xml | 7 ++++ .../resources/testJavadocToolchains/pom.xml | 6 +++ .../src/main/java/somepkg/SomeClass.java | 24 ++++++++++++ .../testJavadocToolchains/toolchains.xml | 11 ++++++ .../fedoraproject/xmvn/mojo/JavadocMojo.java | 1 + 6 files changed, 88 insertions(+) create mode 100644 xmvn-it/src/test/java/org/fedoraproject/xmvn/it/maven/mojo/javadoc/JavadocToolchainsIntegrationTest.java create mode 100644 xmvn-it/src/test/resources/testJavadocToolchains/.xmvn/configuration.xml create mode 100644 xmvn-it/src/test/resources/testJavadocToolchains/pom.xml create mode 100644 xmvn-it/src/test/resources/testJavadocToolchains/src/main/java/somepkg/SomeClass.java create mode 100644 xmvn-it/src/test/resources/testJavadocToolchains/toolchains.xml diff --git a/xmvn-it/src/test/java/org/fedoraproject/xmvn/it/maven/mojo/javadoc/JavadocToolchainsIntegrationTest.java b/xmvn-it/src/test/java/org/fedoraproject/xmvn/it/maven/mojo/javadoc/JavadocToolchainsIntegrationTest.java new file mode 100644 index 00000000..c552652d --- /dev/null +++ b/xmvn-it/src/test/java/org/fedoraproject/xmvn/it/maven/mojo/javadoc/JavadocToolchainsIntegrationTest.java @@ -0,0 +1,39 @@ +/*- + * Copyright (c) 2021 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.fedoraproject.xmvn.it.maven.mojo.javadoc; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +import org.fedoraproject.xmvn.it.maven.mojo.AbstractMojoIntegrationTest; + +/** + * Integration tests for javadoc MOJO. + * + * @author Mikolaj Izdebski + */ +public class JavadocToolchainsIntegrationTest + extends AbstractMojoIntegrationTest +{ + @Test + public void testJavadocToolchains() + throws Exception + { + performTest( "org.fedoraproject.xmvn:xmvn-mojo:javadoc" ); + assertTrue( getStdout().anyMatch( s -> s.equals( "[INFO] Toolchain in xmvn-mojo: JDK[/tmp]" ) ) ); + } +} diff --git a/xmvn-it/src/test/resources/testJavadocToolchains/.xmvn/configuration.xml b/xmvn-it/src/test/resources/testJavadocToolchains/.xmvn/configuration.xml new file mode 100644 index 00000000..06f5b389 --- /dev/null +++ b/xmvn-it/src/test/resources/testJavadocToolchains/.xmvn/configuration.xml @@ -0,0 +1,7 @@ + + + + metadata.xml + + + diff --git a/xmvn-it/src/test/resources/testJavadocToolchains/pom.xml b/xmvn-it/src/test/resources/testJavadocToolchains/pom.xml new file mode 100644 index 00000000..5296a0fe --- /dev/null +++ b/xmvn-it/src/test/resources/testJavadocToolchains/pom.xml @@ -0,0 +1,6 @@ + + 4.0.0 + xmvn.its + javadoc-toolchains-test + 0.0.0-SNAPSHOT + diff --git a/xmvn-it/src/test/resources/testJavadocToolchains/src/main/java/somepkg/SomeClass.java b/xmvn-it/src/test/resources/testJavadocToolchains/src/main/java/somepkg/SomeClass.java new file mode 100644 index 00000000..087d2158 --- /dev/null +++ b/xmvn-it/src/test/resources/testJavadocToolchains/src/main/java/somepkg/SomeClass.java @@ -0,0 +1,24 @@ +/*- + * Copyright (c) 2016-2021 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package somepkg; + +/** + * @author Mikolaj Izdebski + */ +public class SomeClass +{ + +} diff --git a/xmvn-it/src/test/resources/testJavadocToolchains/toolchains.xml b/xmvn-it/src/test/resources/testJavadocToolchains/toolchains.xml new file mode 100644 index 00000000..9e92c646 --- /dev/null +++ b/xmvn-it/src/test/resources/testJavadocToolchains/toolchains.xml @@ -0,0 +1,11 @@ + + + jdk + + xmvn + + + /tmp + + + diff --git a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java index 2b06e702..cf388f5a 100644 --- a/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java +++ b/xmvn-mojo/src/main/java/org/fedoraproject/xmvn/mojo/JavadocMojo.java @@ -170,6 +170,7 @@ public class JavadocMojo Toolchain tc = toolchainManager.getToolchainFromBuildContext( "jdk", session ); if ( tc != null ) { + logger.info( "Toolchain in xmvn-mojo: " + tc ); javadocTool = tc.findTool( "javadoc" ); } Path javadocExecutable; -- 2.47.1