This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-exec.git
commit a0847a7211983153586c1afd3034a108808869d3 Author: Gary D. Gregory <[email protected]> AuthorDate: Sat May 24 08:45:00 2025 -0400 Fix Checkstyle issues Adjust Checkstyle modules for current sources --- src/conf/checkstyle.xml | 9 ++++++--- src/main/java/org/apache/commons/exec/DefaultExecutor.java | 8 ++++++-- .../java/org/apache/commons/exec/AbstractExecTest.java | 14 ++++++++++++-- src/test/java/org/apache/commons/exec/CommandLineTest.java | 1 - .../java/org/apache/commons/exec/DefaultExecutorTest.java | 14 +++++++------- .../java/org/apache/commons/exec/issues/Exec34Test.java | 4 ++-- .../java/org/apache/commons/exec/issues/Exec36Test.java | 10 +++++----- .../java/org/apache/commons/exec/issues/Exec49Test.java | 4 ++-- .../java/org/apache/commons/exec/issues/Exec60Test.java | 2 +- 9 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml index 2aaae9ac..52dc0fe9 100644 --- a/src/conf/checkstyle.xml +++ b/src/conf/checkstyle.xml @@ -64,8 +64,9 @@ <!-- See https://checkstyle.sf.net/config_javadoc.html --> <module name="JavadocType"> </module> - <module name="JavadocVariable" /> - + <module name="JavadocVariable"> + <property name="accessModifiers" value="public, protected"/> + </module> <!-- Checks for Naming Conventions. --> <!-- See https://checkstyle.sf.net/config_naming.html --> <module name="ConstantName" /> @@ -96,7 +97,9 @@ <!-- Checks for whitespace --> <!-- See https://checkstyle.sf.net/config_whitespace.html --> <module name="EmptyForIteratorPad" /> - <module name="NoWhitespaceAfter" /> + <module name="NoWhitespaceAfter"> + <property name="tokens" value="AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, ARRAY_DECLARATOR, INDEX_OP"/> + </module> <module name="NoWhitespaceBefore" /> <module name="OperatorWrap" /> <module name="ParenPad" /> diff --git a/src/main/java/org/apache/commons/exec/DefaultExecutor.java b/src/main/java/org/apache/commons/exec/DefaultExecutor.java index f5c4a552..90a56dcf 100644 --- a/src/main/java/org/apache/commons/exec/DefaultExecutor.java +++ b/src/main/java/org/apache/commons/exec/DefaultExecutor.java @@ -524,10 +524,14 @@ public class DefaultExecutor implements Executor { } } - /** @see org.apache.commons.exec.Executor#setExitValue(int) */ + /** + * {@inheritDoc} + * + * @see org.apache.commons.exec.Executor#setExitValue(int) + */ @Override public void setExitValue(final int value) { - setExitValues(new int[] { value }); + setExitValues(new int[] {value}); } /** @see org.apache.commons.exec.Executor#setExitValues(int[]) */ diff --git a/src/test/java/org/apache/commons/exec/AbstractExecTest.java b/src/test/java/org/apache/commons/exec/AbstractExecTest.java index 0b12ed95..6154dd58 100644 --- a/src/test/java/org/apache/commons/exec/AbstractExecTest.java +++ b/src/test/java/org/apache/commons/exec/AbstractExecTest.java @@ -19,10 +19,20 @@ package org.apache.commons.exec; import java.io.File; +/** + * Abstracts tests. + */ public abstract class AbstractExecTest { - public static final int TEST_TIMEOUT = 15000; - public static final int WATCHDOG_TIMEOUT = 3000; + /** + * Default test timeout in milliseconds. + */ + public static final int TEST_TIMEOUT = 15_000; + + /** + * Watchdog timeout in milliseconds. + */ + public static final int WATCHDOG_TIMEOUT = 3_000; private final File testDir = new File("src/test/scripts"); diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java b/src/test/java/org/apache/commons/exec/CommandLineTest.java index a7286712..9f5c0ac9 100644 --- a/src/test/java/org/apache/commons/exec/CommandLineTest.java +++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java @@ -37,7 +37,6 @@ public class CommandLineTest { @Test public void testAddArgument() { final CommandLine cmdl = new CommandLine("test"); - cmdl.addArgument("foo"); cmdl.addArgument("bar"); assertEquals("[test, foo, bar]", cmdl.toString()); diff --git a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java index 6a4eb22f..2d59e461 100644 --- a/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java +++ b/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java @@ -57,18 +57,18 @@ import org.junitpioneer.jupiter.SetSystemProperty; public class DefaultExecutorTest { /** Maximum time to wait (15s) */ - private static final int WAITFOR_TIMEOUT = 15000; + private static final int WAITFOR_TIMEOUT = 15_000; private static final Duration WAITFOR_TIMEOUT_D = Duration.ofMillis(WAITFOR_TIMEOUT); // Get suitable exit codes for the OS - private static int SUCCESS_STATUS; // test script successful exit code - private static int ERROR_STATUS; // test script error exit code + private static int successStatus; // test script successful exit code + private static int errorStatus; // test script error exit code @BeforeAll public static void classSetUp() { final int[] statuses = TestUtil.getTestScriptCodesForOS(); - SUCCESS_STATUS = statuses[0]; - ERROR_STATUS = statuses[1]; + successStatus = statuses[0]; + errorStatus = statuses[1]; } private final Executor exec = DefaultExecutor.builder().get(); @@ -539,7 +539,7 @@ public class DefaultExecutorTest { */ @Test public void testExecuteWithCustomExitValue1() throws Exception { - exec.setExitValue(ERROR_STATUS); + exec.setExitValue(errorStatus); final CommandLine cl = new CommandLine(errorTestScript); exec.execute(cl); } @@ -552,7 +552,7 @@ public class DefaultExecutorTest { @Test public void testExecuteWithCustomExitValue2() throws Exception { final CommandLine cl = new CommandLine(errorTestScript); - exec.setExitValue(SUCCESS_STATUS); + exec.setExitValue(successStatus); try { exec.execute(cl); fail("Must throw ExecuteException"); diff --git a/src/test/java/org/apache/commons/exec/issues/Exec34Test.java b/src/test/java/org/apache/commons/exec/issues/Exec34Test.java index 93131bda..08976aba 100644 --- a/src/test/java/org/apache/commons/exec/issues/Exec34Test.java +++ b/src/test/java/org/apache/commons/exec/issues/Exec34Test.java @@ -48,7 +48,7 @@ public class Exec34Test { * @throws Exception the test failed */ @Test - public void testExec34_1() throws Exception { + public void testExec34Part1() throws Exception { final CommandLine cmdLine = new CommandLine(pingScript); cmdLine.addArgument("10"); // sleep 10 seconds @@ -69,7 +69,7 @@ public class Exec34Test { * @throws Exception the test failed */ @Test - public void testExec34_2() throws Exception { + public void testExec34Part2() throws Exception { final CommandLine cmdLine = new CommandLine(pingScript); cmdLine.addArgument("10"); // sleep 10 seconds diff --git a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java index 9d5e5848..142c93aa 100644 --- a/src/test/java/org/apache/commons/exec/issues/Exec36Test.java +++ b/src/test/java/org/apache/commons/exec/issues/Exec36Test.java @@ -53,7 +53,7 @@ public class Exec36Test { */ @Test @Disabled - public void _testExec36_4() throws Exception { + public void testExec36Part4() throws Exception { CommandLine cmdl; @@ -75,7 +75,7 @@ public class Exec36Test { */ @Test @Disabled - public void _testExec36_5() { + public void testExec36Part5() { CommandLine cmdl; @@ -96,7 +96,7 @@ public class Exec36Test { */ @Test @Disabled - public void _testExec36_6() { + public void testExec36Part6() { final String commandLine = "C:\\CVS_DB\\WeightsEngine /f WeightsEngine.mak CFG=\"WeightsEngine - Win32Release\""; @@ -127,7 +127,7 @@ public class Exec36Test { */ @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) - public void testExec36_1() throws Exception { + public void testExec36Part1() throws Exception { CommandLine cmdl; /** @@ -160,7 +160,7 @@ public class Exec36Test { * @throws Exception the test failed */ @Test - public void testExec36_2() throws Exception { + public void testExec36Part2() throws Exception { String expected; diff --git a/src/test/java/org/apache/commons/exec/issues/Exec49Test.java b/src/test/java/org/apache/commons/exec/issues/Exec49Test.java index feba4da7..0e0dbe80 100644 --- a/src/test/java/org/apache/commons/exec/issues/Exec49Test.java +++ b/src/test/java/org/apache/commons/exec/issues/Exec49Test.java @@ -46,7 +46,7 @@ public class Exec49Test { */ @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) - public void testExec49_1() throws Exception { + public void testExec49Part1() throws Exception { final CommandLine cl = CommandLine.parse("/bin/ls"); cl.addArgument("/opt"); // redirect stdout/stderr to pipedOutputStream @@ -77,7 +77,7 @@ public class Exec49Test { */ @Test @DisabledOnOs(org.junit.jupiter.api.condition.OS.WINDOWS) - public void testExec49_2() throws Exception { + public void testExec49Part2() throws Exception { final CommandLine cl = CommandLine.parse("/bin/ls"); cl.addArgument("/opt"); // redirect only stdout to pipedOutputStream diff --git a/src/test/java/org/apache/commons/exec/issues/Exec60Test.java b/src/test/java/org/apache/commons/exec/issues/Exec60Test.java index 7fa024e9..b56e3635 100644 --- a/src/test/java/org/apache/commons/exec/issues/Exec60Test.java +++ b/src/test/java/org/apache/commons/exec/issues/Exec60Test.java @@ -44,7 +44,7 @@ public class Exec60Test extends AbstractExecTest { */ @Disabled("The test is fragile and might fail out of the blue") @Test - public void testExec_60() throws Exception { + public void testExec60() throws Exception { final int start = 0; final int seconds = 1;
