This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-invoker-plugin.git
commit b96f41d11392b694780dd2de0e36e36d35520da8 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Mon Nov 23 01:14:15 2026 +0100 Add Selector-level toolchain regression test --- .../maven/plugins/invoker/InvokerProperties.java | 2 +- .../apache/maven/plugins/invoker/SelectorTest.java | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java index fd58336..7e0af9a 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerProperties.java @@ -370,7 +370,7 @@ class InvokerProperties { } /** - * Determines whether these invoker properties contain a build definition for the specified selector index. + * Determines whether these invoker properties contain a selector definition for the specified index. * * @param index the index * @return <code>true</code> if the selector with the specified index is defined, <code>false</code> otherwise. diff --git a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java index 8c94a6c..3e356ae 100644 --- a/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java +++ b/src/test/java/org/apache/maven/plugins/invoker/SelectorTest.java @@ -20,9 +20,14 @@ package org.apache.maven.plugins.invoker; import java.util.Properties; +import org.apache.maven.plugins.invoker.AbstractInvokerMojo.ToolchainPrivateManager; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; /** * Test for {@link Selector}. @@ -73,4 +78,20 @@ class SelectorTest { props.setProperty("selector.2.os.family", "!myos"); assertThat(selector.getSelection(invokerProperties)).isZero(); } + + @Test + void toolchainOnlySelector() { + ToolchainPrivateManager toolchainPrivateManager = mock(ToolchainPrivateManager.class); + Selector selector = new Selector("3.2.5", "1.7", toolchainPrivateManager); + + Properties props = new Properties(); + props.setProperty("selector.1.invoker.toolchain.jdk.version", "17"); + InvokerProperties invokerProperties = new InvokerProperties(props); + + when(toolchainPrivateManager.isToolchains(eq("jdk"), any())).thenReturn(false); + assertThat(selector.getSelection(invokerProperties)).isEqualTo(Selector.SELECTOR_MULTI); + + when(toolchainPrivateManager.isToolchains(eq("jdk"), any())).thenReturn(true); + assertThat(selector.getSelection(invokerProperties)).isZero(); + } }
