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/07/22 05:57:54 UTC
[shardingsphere-elasticjob] branch master updated: Add test case
for TaskExecutor's constructor for job type (#1236) (#1236)
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 c9f54b3 Add test case for TaskExecutor's constructor for job type (#1236) (#1236)
c9f54b3 is described below
commit c9f54b3958a127ccca9200e6f1eed6525f77e9a7
Author: Tboy <gu...@immomo.com>
AuthorDate: Wed Jul 22 13:57:43 2020 +0800
Add test case for TaskExecutor's constructor for job type (#1236) (#1236)
---
.../cloud/executor/prod/TaskExecutorTest.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java
index c05393e..b1ec6cd 100755
--- a/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java
+++ b/elasticjob-cloud/elasticjob-cloud-executor/src/test/java/org/apache/shardingsphere/elasticjob/cloud/executor/prod/TaskExecutorTest.java
@@ -38,6 +38,10 @@ import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.concurrent.ExecutorService;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@@ -127,4 +131,20 @@ public final class TaskExecutorTest {
public void assertError() {
taskExecutor.error(executorDriver, "");
}
+
+ @Test
+ @SneakyThrows
+ public void assertConstructor() {
+ TestSimpleJob testSimpleJob = new TestSimpleJob();
+ taskExecutor = new TaskExecutor(testSimpleJob);
+ Field fieldElasticJob = TaskExecutor.class.getDeclaredField("elasticJob");
+ fieldElasticJob.setAccessible(true);
+ Field fieldElasticJobType = TaskExecutor.class.getDeclaredField("elasticJobType");
+ fieldElasticJobType.setAccessible(true);
+ assertTrue(fieldElasticJob.get(taskExecutor) == testSimpleJob);
+ assertNull(fieldElasticJobType.get(taskExecutor));
+ taskExecutor = new TaskExecutor("simpleJob");
+ assertThat(fieldElasticJobType.get(taskExecutor), is("simpleJob"));
+ assertNull(fieldElasticJob.get(taskExecutor));
+ }
}