You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/10/29 10:05:40 UTC
[shardingsphere-elasticjob] branch master updated: Determine
command by platform in ScriptJobExecutorTest (#1673)
This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 ebcba7b Determine command by platform in ScriptJobExecutorTest (#1673)
ebcba7b is described below
commit ebcba7b0893bd0241f459d444ce16b0bcd1bb185
Author: 吴伟杰 <ro...@me.com>
AuthorDate: Thu Oct 29 18:05:25 2020 +0800
Determine command by platform in ScriptJobExecutorTest (#1673)
---
.../elasticjob/script/ScriptJobExecutorTest.java | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java
index 625694c..672bab5 100644
--- a/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java
+++ b/elasticjob-ecosystem/elasticjob-executor/elasticjob-executor-type/elasticjob-script-executor/src/test/java/org/apache/shardingsphere/elasticjob/script/ScriptJobExecutorTest.java
@@ -17,6 +17,7 @@
package org.apache.shardingsphere.elasticjob.script;
+import org.apache.commons.exec.OS;
import org.apache.shardingsphere.elasticjob.api.ElasticJob;
import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
@@ -78,9 +79,21 @@ public final class ScriptJobExecutorTest {
@Test
public void assertProcess() {
when(jobConfig.getProps()).thenReturn(properties);
- when(properties.getProperty(ScriptJobProperties.SCRIPT_KEY)).thenReturn("echo script-job");
+ when(properties.getProperty(ScriptJobProperties.SCRIPT_KEY)).thenReturn(determineCommandByPlatform());
jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
}
+
+ private String determineCommandByPlatform() {
+ return OS.isFamilyWindows() ? getWindowsEcho() : getEcho();
+ }
+
+ private String getWindowsEcho() {
+ return "cmd /c echo script-job";
+ }
+
+ private String getEcho() {
+ return "echo script-job";
+ }
@Test
public void assertGetType() {