This is an automated email from the ASF dual-hosted git repository.

terrymanu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new 1759bfe42 Fix unit tests failing on Windows Server 2025 combined with 
JDK 24 (#2512)
1759bfe42 is described below

commit 1759bfe42b7609b7c6fbae9c916532a7db566a0c
Author: Hengqian Ling <[email protected]>
AuthorDate: Thu May 7 23:44:13 2026 +0800

    Fix unit tests failing on Windows Server 2025 combined with JDK 24 (#2512)
---
 .../job/JobSpringNamespaceWithTypeTest.java        | 22 +++++++++++++++-------
 .../job/OneOffJobSpringNamespaceWithTypeTest.java  | 22 +++++++++++++++-------
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git 
a/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/JobSpringNamespaceWithTypeTest.java
 
b/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/JobSpringNamespaceWithTypeTest.java
index 69115626c..bf13d0ed4 100644
--- 
a/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/JobSpringNamespaceWithTypeTest.java
+++ 
b/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/JobSpringNamespaceWithTypeTest.java
@@ -24,26 +24,24 @@ import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.env.MapPropertySource;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 import org.springframework.test.util.ReflectionTestUtils;
 
+import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-/**
- * todo There is no `echo` program on Windows 11 cmd. Waiting for a fix.
- */
-@EnabledOnOs(OS.LINUX)
 @ExtendWith(SpringExtension.class)
-@ContextConfiguration(locations = "classpath:META-INF/job/withJobType.xml")
+@ContextConfiguration(locations = "classpath:META-INF/job/withJobType.xml", 
initializers = 
JobSpringNamespaceWithTypeTest.ScriptCommandLineInitializer.class)
 class JobSpringNamespaceWithTypeTest {
     
     private static final EmbedTestingServer EMBED_TESTING_SERVER = new 
EmbedTestingServer(3181);
@@ -72,4 +70,14 @@ class JobSpringNamespaceWithTypeTest {
         scheduler = (Scheduler) 
ReflectionTestUtils.getField(JobRegistry.getInstance().getJobScheduleController(scriptJobName),
 "scheduler");
         assertTrue(scheduler.isStarted());
     }
+    
+    static class ScriptCommandLineInitializer implements 
ApplicationContextInitializer<ConfigurableApplicationContext> {
+        
+        @Override
+        public void initialize(final ConfigurableApplicationContext 
applicationContext) {
+            String command = System.getProperty("os.name", 
"").contains("Windows") ? "cmd /c echo test" : "echo test";
+            applicationContext.getEnvironment().getPropertySources()
+                    .addFirst(new MapPropertySource("testScriptCommandLine", 
Collections.singletonMap("script.scriptCommandLine", command)));
+        }
+    }
 }
diff --git 
a/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java
 
b/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java
index 49e234f14..166396184 100644
--- 
a/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java
+++ 
b/spring/namespace/src/test/java/org/apache/shardingsphere/elasticjob/spring/namespace/job/OneOffJobSpringNamespaceWithTypeTest.java
@@ -25,24 +25,22 @@ import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.EnabledOnOs;
-import org.junit.jupiter.api.condition.OS;
 import org.junit.jupiter.api.extension.ExtendWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextInitializer;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.core.env.MapPropertySource;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit.jupiter.SpringExtension;
 
+import java.util.Collections;
 import java.util.concurrent.TimeUnit;
 
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
-/**
- * todo There is no `echo` program on Windows 11 cmd. Waiting for a fix.
- */
-@EnabledOnOs(OS.LINUX)
 @ExtendWith(SpringExtension.class)
-@ContextConfiguration(locations = 
"classpath:META-INF/job/oneOffWithJobType.xml")
+@ContextConfiguration(locations = 
"classpath:META-INF/job/oneOffWithJobType.xml", initializers = 
OneOffJobSpringNamespaceWithTypeTest.ScriptCommandLineInitializer.class)
 class OneOffJobSpringNamespaceWithTypeTest {
     
     private static final EmbedTestingServer EMBED_TESTING_SERVER = new 
EmbedTestingServer(3181);
@@ -71,4 +69,14 @@ class OneOffJobSpringNamespaceWithTypeTest {
         bootstrap.execute();
         Awaitility.await().atLeast(1L, TimeUnit.MILLISECONDS).atMost(1L, 
TimeUnit.MINUTES).untilAsserted(() -> assertTrue(regCenter.isExisted("/" + 
scriptJobName + "/sharding")));
     }
+    
+    static class ScriptCommandLineInitializer implements 
ApplicationContextInitializer<ConfigurableApplicationContext> {
+        
+        @Override
+        public void initialize(final ConfigurableApplicationContext 
applicationContext) {
+            String command = System.getProperty("os.name", 
"").contains("Windows") ? "cmd /c echo test" : "echo test";
+            applicationContext.getEnvironment().getPropertySources()
+                    .addFirst(new MapPropertySource("testScriptCommandLine", 
Collections.singletonMap("script.scriptCommandLine", command)));
+        }
+    }
 }

Reply via email to