You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/05/24 13:57:31 UTC
(commons-exec) 05/20: Checkstyle: Fix IllegalType
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 9118f6e4b3387b59082463f6f377c9c80a54ce42
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat May 24 09:04:27 2025 -0400
Checkstyle: Fix IllegalType
---
src/test/java/org/apache/commons/exec/CommandLineTest.java | 12 ++++++------
.../commons/exec/launcher/VmsCommandLauncherTest.java | 3 ++-
.../java/org/apache/commons/exec/util/MapUtilTest.java | 14 ++++----------
3 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/src/test/java/org/apache/commons/exec/CommandLineTest.java b/src/test/java/org/apache/commons/exec/CommandLineTest.java
index 69472200..df7ef69c 100644
--- a/src/test/java/org/apache/commons/exec/CommandLineTest.java
+++ b/src/test/java/org/apache/commons/exec/CommandLineTest.java
@@ -164,13 +164,13 @@ public class CommandLineTest {
CommandLine cmdl;
- final HashMap<String, Object> substitutionMap = new HashMap<>();
+ final Map<String, Object> substitutionMap = new HashMap<>();
substitutionMap.put("JAVA_HOME", "/usr/local/java");
substitutionMap.put("appMainClass", "foo.bar.Main");
substitutionMap.put("file1", new File("./pom.xml"));
substitutionMap.put("file2", new File(".\\temp\\READ ME.txt"));
- final HashMap<String, String> incompleteMap = new HashMap<>();
+ final Map<String, String> incompleteMap = new HashMap<>();
incompleteMap.put("JAVA_HOME", "/usr/local/java");
// do not pass substitution map
@@ -211,7 +211,7 @@ public class CommandLineTest {
String[] result;
// build the user supplied parameters
- final HashMap<String, String> substitutionMap = new HashMap<>();
+ final Map<String, String> substitutionMap = new HashMap<>();
substitutionMap.put("JAVA_HOME", "C:\\Programme\\jdk1.5.0_12");
substitutionMap.put("appMainClass", "foo.bar.Main");
@@ -258,7 +258,7 @@ public class CommandLineTest {
cmdl.addArgument("/p");
cmdl.addArgument("/h");
cmdl.addArgument("${file}", false);
- final HashMap<String, String> params = new HashMap<>();
+ final Map<String, String> params = new HashMap<>();
params.put("file", "C:\\Document And Settings\\documents\\432432.pdf");
cmdl.setSubstitutionMap(params);
final String[] result = cmdl.toStrings();
@@ -381,7 +381,7 @@ public class CommandLineTest {
*/
@Test
public void testParseComplexCommandLine1() {
- final HashMap<String, String> substitutionMap = new HashMap<>();
+ final Map<String, String> substitutionMap = new HashMap<>();
substitutionMap.put("in", "source.jpg");
substitutionMap.put("out", "target.jpg");
final CommandLine cmdl = CommandLine.parse("cmd /C convert ${in} -resize \"\'500x> \'\" ${out}", substitutionMap);
@@ -428,7 +428,7 @@ public class CommandLineTest {
@Test
public void testToString() throws Exception {
CommandLine cmdl;
- final HashMap<String, String> params = new HashMap<>();
+ final Map<String, String> params = new HashMap<>();
// use no arguments
cmdl = CommandLine.parse("AcroRd32.exe", params);
diff --git a/src/test/java/org/apache/commons/exec/launcher/VmsCommandLauncherTest.java b/src/test/java/org/apache/commons/exec/launcher/VmsCommandLauncherTest.java
index b3d41f97..67bcacb9 100644
--- a/src/test/java/org/apache/commons/exec/launcher/VmsCommandLauncherTest.java
+++ b/src/test/java/org/apache/commons/exec/launcher/VmsCommandLauncherTest.java
@@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.HashMap;
+import java.util.Map;
import org.apache.commons.exec.CommandLine;
import org.junit.jupiter.api.Test;
@@ -41,7 +42,7 @@ public class VmsCommandLauncherTest extends AbstractCommandLauncherTest<VmsComma
final VmsCommandLauncher commandLauncher = createCommandLauncher();
final CommandLine cl = CommandLine.parse("a b \"c d\"");
assertNotNull(commandLauncher.createCommandFile(cl, null));
- final HashMap<String, String> env = new HashMap<>();
+ final Map<String, String> env = new HashMap<>();
assertNotNull(commandLauncher.createCommandFile(cl, env));
env.put("EnvKey", "EnvValue");
assertNotNull(commandLauncher.createCommandFile(cl, env));
diff --git a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
index e0954010..3d498ad8 100644
--- a/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
+++ b/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
@@ -31,20 +31,18 @@ import org.junit.jupiter.api.Test;
/**
*/
public class MapUtilTest {
+
/**
* Test copying of map
*/
@Test
public void testCopyMap() throws Exception {
-
- final HashMap<String, String> procEnvironment = new HashMap<>();
+ final Map<String, String> procEnvironment = new HashMap<>();
procEnvironment.put("JAVA_HOME", "/usr/opt/java");
-
final Map<String, String> result = MapUtils.copy(procEnvironment);
assertEquals(1, result.size());
assertEquals(1, procEnvironment.size());
assertEquals("/usr/opt/java", result.get("JAVA_HOME"));
-
result.remove("JAVA_HOME");
assertTrue(result.isEmpty());
assertEquals(1, procEnvironment.size());
@@ -55,10 +53,8 @@ public class MapUtilTest {
*/
@Test
public void testMergeMap() throws Exception {
-
final Map<String, String> procEnvironment = EnvironmentUtils.getProcEnvironment();
- final HashMap<String, String> applicationEnvironment = new HashMap<>();
-
+ final Map<String, String> applicationEnvironment = new HashMap<>();
applicationEnvironment.put("appMainClass", "foo.bar.Main");
final Map<String, String> result = MapUtils.merge(procEnvironment, applicationEnvironment);
assertEquals(procEnvironment.size() + applicationEnvironment.size(), result.size());
@@ -70,10 +66,8 @@ public class MapUtilTest {
*/
@Test
public void testPrefixMap() throws Exception {
-
- final HashMap<String, String> procEnvironment = new HashMap<>();
+ final Map<String, String> procEnvironment = new HashMap<>();
procEnvironment.put("JAVA_HOME", "/usr/opt/java");
-
final Map<String, String> result = MapUtils.prefix(procEnvironment, "env");
assertEquals(procEnvironment.size(), result.size());
assertEquals("/usr/opt/java", result.get("env.JAVA_HOME"));