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/04 16:16:50 UTC
[shardingsphere-elasticjob-lite] branch master updated: Add test
case for ElasticJobExecutor (#940)
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-lite.git
The following commit(s) were added to refs/heads/master by this push:
new 12088f1 Add test case for ElasticJobExecutor (#940)
12088f1 is described below
commit 12088f145c4d84c9aa894428c69bfee4adc89e7d
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jul 5 00:16:42 2020 +0800
Add test case for ElasticJobExecutor (#940)
* Add test case for ElasticJobExecutor
* Remove useless test cases
* Merge fixture
* refactor test cases package
---
...ecutorTest.java => ElasticJobExecutorTest.java} | 162 +++++++++----------
.../fixture/executor/ClassedFooJobExecutor.java | 4 +-
.../fixture/executor/TypedFooJobExecutor.java | 2 +-
.../{type => }/fixture/job/DetailedFooJob.java | 2 +-
.../executor/{type => }/fixture/job/FailedJob.java | 2 +-
.../executor/{type => }/fixture/job/FooJob.java | 2 +-
.../executor/type/JobItemExecutorFactoryTest.java | 10 +-
.../type/impl/DataflowJobExecutorTest.java | 179 ---------------------
.../lite/executor/type/impl/ElasticJobVerify.java | 54 -------
.../executor/type/impl/ScriptJobExecutorTest.java | 92 -----------
.../executor/type/impl/WrongJobExecutorTest.java | 84 ----------
.../elasticjob/lite/fixture/job/JobCaller.java | 43 -----
.../elasticjob/lite/fixture/job/OtherJob.java | 23 ---
.../lite/fixture/job/TestDataflowJob.java | 42 -----
.../elasticjob/lite/fixture/job/TestSimpleJob.java | 33 ----
.../elasticjob/lite/fixture/job/TestWrongJob.java | 31 ----
...e.elasticjob.lite.executor.type.JobItemExecutor | 4 +-
17 files changed, 91 insertions(+), 678 deletions(-)
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
similarity index 54%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
index a34e74f..f75cc8f 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/SimpleJobExecutorTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/ElasticJobExecutorTest.java
@@ -7,7 +7,7 @@
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,19 +15,14 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
+package org.apache.shardingsphere.elasticjob.lite.executor;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.ClassedFooJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.FooJob;
import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.job.JobCaller;
-import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestSimpleJob;
-import org.apache.shardingsphere.elasticjob.lite.handler.error.impl.LogJobErrorHandler;
-import org.apache.shardingsphere.elasticjob.lite.handler.threadpool.impl.CPUUsageJobExecutorServiceHandler;
import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
@@ -39,44 +34,43 @@ import org.mockito.junit.MockitoJUnitRunner;
import java.util.Collections;
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
-public final class SimpleJobExecutorTest {
+public final class ElasticJobExecutorTest {
@Mock
private CoordinatorRegistryCenter regCenter;
@Mock
- private JobCaller jobCaller;
+ private FooJob fooJob;
+
+ private JobConfiguration jobConfig;
@Mock
private JobFacade jobFacade;
+ @Mock
+ private ClassedFooJobExecutor jobItemExecutor;
+
private ElasticJobExecutor elasticJobExecutor;
@Before
public void setUp() {
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, "THROW"), Collections.emptyList(), null);
+ jobConfig = createJobConfiguration();
+ elasticJobExecutor = new ElasticJobExecutor(regCenter, fooJob, jobConfig, Collections.emptyList(), null);
ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
+ ReflectionUtils.setFieldValue(elasticJobExecutor, "jobItemExecutor", jobItemExecutor);
}
- private JobConfiguration createJobConfiguration(final String jobExecutorServiceHandlerType, final String jobErrorHandlerType) {
+ private JobConfiguration createJobConfiguration() {
return JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
- .cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").jobParameter("param").failover(true).misfire(false)
- .jobExecutorServiceHandlerType(jobExecutorServiceHandlerType).jobErrorHandlerType(jobErrorHandlerType).description("desc").build();
- }
-
- @Test
- public void assertNewExecutorWithDefaultHandlers() {
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestSimpleJob(jobCaller), createJobConfiguration(null, null), Collections.emptyList(), null);
- assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "executorService"), instanceOf(new CPUUsageJobExecutorServiceHandler().createExecutorService("test_job").getClass()));
- assertThat(ReflectionUtils.getFieldValue(elasticJobExecutor, "jobErrorHandler"), instanceOf(LogJobErrorHandler.class));
+ .cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").jobParameter("param").failover(true).misfire(false).jobErrorHandlerType("THROW").description("desc").build();
}
@Test(expected = JobSystemException.class)
@@ -85,128 +79,112 @@ public final class SimpleJobExecutorTest {
try {
elasticJobExecutor.execute();
} finally {
- verify(jobFacade).checkJobExecutionEnvironment();
- verify(jobCaller, times(0)).execute();
+ verify(jobItemExecutor, times(0)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
}
@Test
- public void assertExecuteWhenPreviousJobStillRunning() throws JobExecutionEnvironmentException {
- ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap());
+ public void assertExecuteWhenPreviousJobStillRunning() {
+ ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", ShardingContextsBuilder.JOB_NAME, 3, "", Collections.emptyMap());
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true);
elasticJobExecutor.execute();
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_FINISHED,
"Previous job 'test_job' - shardingItems '[]' is still running, misfired job will start after previous job completed.");
- verify(jobFacade).checkJobExecutionEnvironment();
- verify(jobFacade).getShardingContexts();
- verify(jobFacade).misfireIfRunning(shardingContexts.getShardingItemParameters().keySet());
- verify(jobCaller, times(0)).execute();
+ verify(jobItemExecutor, times(0)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
@Test
- public void assertExecuteWhenShardingItemsIsEmpty() throws JobExecutionEnvironmentException {
- ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", Collections.emptyMap());
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
+ public void assertExecuteWhenShardingItemsIsEmpty() {
+ ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 3, "", Collections.emptyMap());
+ prepareForIsNotMisfire(jobFacade, shardingContexts);
elasticJobExecutor.execute();
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_FINISHED, "Sharding item for job 'test_job' is empty.");
- verify(jobFacade).checkJobExecutionEnvironment();
- verify(jobFacade).getShardingContexts();
- verify(jobFacade).misfireIfRunning(shardingContexts.getShardingItemParameters().keySet());
- verify(jobCaller, times(0)).execute();
+ verify(jobItemExecutor, times(0)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
@Test(expected = JobSystemException.class)
- public void assertExecuteWhenRunOnceAndThrowExceptionForSingleShardingItem() throws JobExecutionEnvironmentException {
- assertExecuteWhenRunOnceAndThrowException(ShardingContextsBuilder.getSingleShardingContexts());
+ public void assertExecuteFailureWhenThrowExceptionForSingleShardingItem() {
+ assertExecuteFailureWhenThrowException(ShardingContextsBuilder.getSingleShardingContexts());
}
@Test
- public void assertExecuteWhenRunOnceAndThrowExceptionForMultipleShardingItems() throws JobExecutionEnvironmentException {
- assertExecuteWhenRunOnceAndThrowException(ShardingContextsBuilder.getMultipleShardingContexts());
+ public void assertExecuteFailureWhenThrowExceptionForMultipleShardingItems() {
+ assertExecuteFailureWhenThrowException(ShardingContextsBuilder.getMultipleShardingContexts());
}
- private void assertExecuteWhenRunOnceAndThrowException(final ShardingContexts shardingContexts) throws JobExecutionEnvironmentException {
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- doThrow(RuntimeException.class).when(jobCaller).execute();
+ private void assertExecuteFailureWhenThrowException(final ShardingContexts shardingContexts) {
+ prepareForIsNotMisfire(jobFacade, shardingContexts);
+ doThrow(RuntimeException.class).when(jobItemExecutor).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
try {
elasticJobExecutor.execute();
} finally {
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_RUNNING, "");
- String errorMessage;
- String lineSeparator = System.getProperty("line.separator");
- if (1 == shardingContexts.getShardingItemParameters().size()) {
- errorMessage = "{0=java.lang.RuntimeException" + lineSeparator + "}";
- } else {
- errorMessage = "{0=java.lang.RuntimeException" + lineSeparator + ", 1=java.lang.RuntimeException" + lineSeparator + "}";
- }
- verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_ERROR, errorMessage);
- verify(jobFacade).checkJobExecutionEnvironment();
- verify(jobFacade).getShardingContexts();
- verify(jobFacade).misfireIfRunning(shardingContexts.getShardingItemParameters().keySet());
+ verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_ERROR, getErrorMessage(shardingContexts));
verify(jobFacade).registerJobBegin(shardingContexts);
- verify(jobCaller, times(shardingContexts.getShardingTotalCount())).execute();
+ verify(jobItemExecutor, times(shardingContexts.getShardingTotalCount())).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
verify(jobFacade).registerJobCompleted(shardingContexts);
}
}
+ private String getErrorMessage(final ShardingContexts shardingContexts) {
+ return 1 == shardingContexts.getShardingItemParameters().size()
+ ? "{0=java.lang.RuntimeException" + System.lineSeparator() + "}"
+ : "{0=java.lang.RuntimeException" + System.lineSeparator() + ", 1=java.lang.RuntimeException" + System.lineSeparator() + "}";
+ }
+
@Test
- public void assertExecuteWhenRunOnceSuccessForSingleShardingItems() {
- assertExecuteWhenRunOnceSuccess(ShardingContextsBuilder.getSingleShardingContexts());
+ public void assertExecuteSuccessForSingleShardingItems() {
+ assertExecuteSuccess(ShardingContextsBuilder.getSingleShardingContexts());
}
@Test
- public void assertExecuteWhenRunOnceSuccessForMultipleShardingItems() {
- assertExecuteWhenRunOnceSuccess(ShardingContextsBuilder.getMultipleShardingContexts());
+ public void assertExecuteSuccessForMultipleShardingItems() {
+ assertExecuteSuccess(ShardingContextsBuilder.getMultipleShardingContexts());
}
- private void assertExecuteWhenRunOnceSuccess(final ShardingContexts shardingContexts) {
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
+ private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
+ prepareForIsNotMisfire(jobFacade, shardingContexts);
elasticJobExecutor.execute();
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_FINISHED, "");
- ElasticJobVerify.verifyForIsNotMisfire(jobFacade, shardingContexts);
- verify(jobCaller, times(shardingContexts.getShardingTotalCount())).execute();
+ verifyForIsNotMisfire(jobFacade, shardingContexts);
+ verify(jobItemExecutor, times(shardingContexts.getShardingTotalCount())).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
@Test
- public void assertExecuteWhenRunOnceWithMisfireIsEmpty() {
+ public void assertExecuteWithMisfireIsEmpty() {
ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
elasticJobExecutor.execute();
- ElasticJobVerify.verifyForIsNotMisfire(jobFacade, shardingContexts);
- verify(jobCaller, times(2)).execute();
+ verifyForIsNotMisfire(jobFacade, shardingContexts);
+ verify(jobItemExecutor, times(2)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
@Test
- public void assertExecuteWhenRunOnceWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() {
+ public void assertExecuteWithMisfireIsNotEmptyButIsNotEligibleForJobRunning() {
ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
elasticJobExecutor.execute();
- ElasticJobVerify.verifyForIsNotMisfire(jobFacade, shardingContexts);
- verify(jobCaller, times(2)).execute();
+ verifyForIsNotMisfire(jobFacade, shardingContexts);
+ verify(jobItemExecutor, times(2)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
verify(jobFacade, times(0)).clearMisfire(shardingContexts.getShardingItemParameters().keySet());
}
@Test
- public void assertExecuteWhenRunOnceWithMisfire() throws JobExecutionEnvironmentException {
+ public void assertExecuteWithMisfire() {
ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(true, false);
elasticJobExecutor.execute();
verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
verify(jobFacade, times(2)).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_RUNNING, "");
- verify(jobFacade).checkJobExecutionEnvironment();
- verify(jobFacade).getShardingContexts();
verify(jobFacade).misfireIfRunning(shardingContexts.getShardingItemParameters().keySet());
verify(jobFacade, times(2)).registerJobBegin(shardingContexts);
- verify(jobCaller, times(4)).execute();
+ verify(jobItemExecutor, times(4)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
verify(jobFacade, times(2)).registerJobCompleted(shardingContexts);
}
@@ -214,12 +192,11 @@ public final class SimpleJobExecutorTest {
public void assertBeforeJobExecutedFailure() {
ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
doThrow(RuntimeException.class).when(jobFacade).beforeJobExecuted(shardingContexts);
try {
elasticJobExecutor.execute();
} finally {
- verify(jobCaller, times(0)).execute();
+ verify(jobItemExecutor, times(0)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
}
@@ -227,13 +204,30 @@ public final class SimpleJobExecutorTest {
public void assertAfterJobExecutedFailure() {
ShardingContexts shardingContexts = ShardingContextsBuilder.getMultipleShardingContexts();
when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
- when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
doThrow(RuntimeException.class).when(jobFacade).afterJobExecuted(shardingContexts);
try {
elasticJobExecutor.execute();
} finally {
- verify(jobCaller, times(2)).execute();
+ verify(jobItemExecutor, times(2)).process(eq(fooJob), eq(jobConfig), eq(jobFacade), any());
}
}
+
+ private void prepareForIsNotMisfire(final JobFacade jobFacade, final ShardingContexts shardingContexts) {
+ when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
+ when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
+ when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
+ }
+
+ private void verifyForIsNotMisfire(final JobFacade jobFacade, final ShardingContexts shardingContexts) {
+ try {
+ verify(jobFacade).checkJobExecutionEnvironment();
+ } catch (final JobExecutionEnvironmentException ex) {
+ throw new RuntimeException(ex);
+ }
+ verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
+ verify(jobFacade).beforeJobExecuted(shardingContexts);
+ verify(jobFacade).registerJobBegin(shardingContexts);
+ verify(jobFacade).registerJobCompleted(shardingContexts);
+ verify(jobFacade).afterJobExecuted(shardingContexts);
+ }
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/ClassedFooJobExecutor.java
similarity index 89%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/ClassedFooJobExecutor.java
index 71d5111..e04a2bc 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/ClassedFooJobExecutor.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/ClassedFooJobExecutor.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor;
+package org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
import org.apache.shardingsphere.elasticjob.lite.executor.type.ClassedJobItemExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FooJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.FooJob;
public final class ClassedFooJobExecutor implements ClassedJobItemExecutor<FooJob> {
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/TypedFooJobExecutor.java
similarity index 94%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/TypedFooJobExecutor.java
index 9f32b1f..6c54bf4 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/executor/TypedFooJobExecutor.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/executor/TypedFooJobExecutor.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor;
+package org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/DetailedFooJob.java
similarity index 91%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/DetailedFooJob.java
index fb7a7fd..65e25ca 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/DetailedFooJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/DetailedFooJob.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.fixture.job;
public final class DetailedFooJob implements FooJob {
}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FailedJob.java
similarity index 92%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FailedJob.java
index 84c3026..04d7234 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FailedJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FailedJob.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.fixture.job;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FooJob.java
similarity index 92%
rename from elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java
rename to elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FooJob.java
index cb00238..40fcc60 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/fixture/job/FooJob.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/fixture/job/FooJob.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job;
+package org.apache.shardingsphere.elasticjob.lite.executor.fixture.job;
import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java
index c99029e..8fa051f 100644
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java
+++ b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/JobItemExecutorFactoryTest.java
@@ -18,11 +18,11 @@
package org.apache.shardingsphere.elasticjob.lite.executor.type;
import org.apache.shardingsphere.elasticjob.lite.exception.JobConfigurationException;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.ClassedFooJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.TypedFooJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.DetailedFooJob;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FailedJob;
-import org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.job.FooJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.ClassedFooJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.TypedFooJobExecutor;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.DetailedFooJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.FailedJob;
+import org.apache.shardingsphere.elasticjob.lite.executor.fixture.job.FooJob;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
deleted file mode 100644
index b2a108a..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/DataflowJobExecutorTest.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.job.JobCaller;
-import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestDataflowJob;
-import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Arrays;
-import java.util.Collections;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class DataflowJobExecutorTest {
-
- @Mock
- private CoordinatorRegistryCenter regCenter;
-
- @Mock
- private JobCaller jobCaller;
-
- @Mock
- private JobFacade jobFacade;
-
- private ShardingContexts shardingContexts;
-
- private ElasticJobExecutor elasticJobExecutor;
-
- @After
- public void tearDown() {
- ElasticJobVerify.verifyForIsNotMisfire(jobFacade, shardingContexts);
- }
-
- @Test
- public void assertExecuteWhenFetchDataIsNullAndEmpty() {
- setUp(true, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(null);
- when(jobCaller.fetchData(1)).thenReturn(Collections.emptyList());
- elasticJobExecutor.execute();
- verify(jobCaller).fetchData(0);
- verify(jobCaller).fetchData(1);
- verify(jobCaller, times(0)).processData(any());
- }
-
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyForUnStreamingProcessAndSingleShardingItem() {
- setUp(false, ShardingContextsBuilder.getSingleShardingContexts());
- doThrow(new IllegalStateException()).when(jobCaller).fetchData(0);
- elasticJobExecutor.execute();
- verify(jobCaller).fetchData(0);
- verify(jobCaller, times(0)).processData(any());
- }
-
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyForUnStreamingProcessAndMultipleShardingItems() {
- setUp(false, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(Arrays.asList(1, 2));
- when(jobCaller.fetchData(1)).thenReturn(Arrays.asList(3, 4));
- doThrow(new IllegalStateException()).when(jobCaller).processData(4);
- elasticJobExecutor.execute();
- verify(jobCaller).fetchData(0);
- verify(jobCaller).fetchData(1);
- verify(jobCaller).processData(1);
- verify(jobCaller).processData(2);
- verify(jobCaller).processData(3);
- verify(jobCaller).processData(4);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyForStreamingProcessAndSingleShardingItem() {
- setUp(true, ShardingContextsBuilder.getSingleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(Collections.singletonList(1), Collections.emptyList());
- elasticJobExecutor.execute();
- verify(jobCaller, times(2)).fetchData(0);
- verify(jobCaller).processData(1);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyForStreamingProcessAndMultipleShardingItems() {
- setUp(true, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(Collections.singletonList(1), Collections.emptyList());
- when(jobCaller.fetchData(1)).thenReturn(Collections.singletonList(2), Collections.emptyList());
- elasticJobExecutor.execute();
- verify(jobCaller, times(2)).fetchData(0);
- verify(jobCaller, times(2)).fetchData(1);
- verify(jobCaller).processData(1);
- verify(jobCaller).processData(2);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyAndProcessFailureWithExceptionForStreamingProcess() {
- setUp(true, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(Collections.singletonList(1), Collections.emptyList());
- when(jobCaller.fetchData(1)).thenReturn(Arrays.asList(2, 3), Collections.emptyList());
- doThrow(new IllegalStateException()).when(jobCaller).processData(2);
- elasticJobExecutor.execute();
- verify(jobCaller, times(2)).fetchData(0);
- verify(jobCaller, times(1)).fetchData(1);
- verify(jobCaller).processData(1);
- verify(jobCaller).processData(2);
- verify(jobCaller, times(0)).processData(3);
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyAndIsEligibleForJobRunningForStreamingProcess() {
- setUp(true, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobCaller.fetchData(0)).thenReturn(Arrays.asList(1, 2), Collections.emptyList());
- when(jobCaller.fetchData(1)).thenReturn(Arrays.asList(3, 4), Collections.emptyList());
- doThrow(new IllegalStateException()).when(jobCaller).processData(4);
- elasticJobExecutor.execute();
- verify(jobCaller, times(2)).fetchData(0);
- verify(jobCaller, times(1)).fetchData(1);
- verify(jobCaller).processData(1);
- verify(jobCaller).processData(2);
- verify(jobCaller).processData(3);
- verify(jobCaller).processData(4);
- }
-
- @Test
- public void assertExecuteWhenFetchDataIsNotEmptyAndIsNotEligibleForJobRunningForStreamingProcess() {
- setUp(true, ShardingContextsBuilder.getMultipleShardingContexts());
- when(jobFacade.isNeedSharding()).thenReturn(true);
- when(jobCaller.fetchData(0)).thenReturn(Arrays.asList(1, 2));
- when(jobCaller.fetchData(1)).thenReturn(Arrays.asList(3, 4));
- doThrow(new IllegalStateException()).when(jobCaller).processData(4);
- elasticJobExecutor.execute();
- verify(jobCaller).fetchData(0);
- verify(jobCaller).fetchData(1);
- verify(jobCaller).processData(1);
- verify(jobCaller).processData(2);
- verify(jobCaller).processData(3);
- verify(jobCaller).processData(4);
- }
-
- private void setUp(final boolean isStreamingProcess, final ShardingContexts shardingContexts) {
- this.shardingContexts = shardingContexts;
- JobConfiguration jobConfig = JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
- .cron("0/1 * * * * ?").jobErrorHandlerType("IGNORE").setProperty(DataflowJobExecutor.STREAM_PROCESS_KEY, Boolean.toString(isStreamingProcess)).build();
- when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, new TestDataflowJob(jobCaller), jobConfig, Collections.emptyList(), null);
- ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java
deleted file mode 100644
index 2a82b53..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ElasticJobVerify.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-
-import lombok.AccessLevel;
-import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobExecutionEnvironmentException;
-import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@NoArgsConstructor(access = AccessLevel.PRIVATE)
-final class ElasticJobVerify {
-
- static void prepareForIsNotMisfire(final JobFacade jobFacade, final ShardingContexts shardingContexts) {
- when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- when(jobFacade.misfireIfRunning(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
- when(jobFacade.isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet())).thenReturn(false);
- }
-
- public static void verifyForIsNotMisfire(final JobFacade jobFacade, final ShardingContexts shardingContexts) {
- try {
- verify(jobFacade).checkJobExecutionEnvironment();
- } catch (final JobExecutionEnvironmentException ex) {
- throw new RuntimeException(ex);
- }
- verify(jobFacade).getShardingContexts();
- verify(jobFacade).postJobStatusTraceEvent(shardingContexts.getTaskId(), State.TASK_STAGING, "Job 'test_job' execute begin.");
- verify(jobFacade).misfireIfRunning(shardingContexts.getShardingItemParameters().keySet());
- verify(jobFacade).beforeJobExecuted(shardingContexts);
- verify(jobFacade).registerJobBegin(shardingContexts);
- verify(jobFacade).registerJobCompleted(shardingContexts);
- verify(jobFacade).isExecuteMisfired(shardingContexts.getShardingItemParameters().keySet());
- verify(jobFacade).afterJobExecuted(shardingContexts);
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
deleted file mode 100644
index e954819..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/ScriptJobExecutorTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collections;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class ScriptJobExecutorTest {
-
- @Mock
- private CoordinatorRegistryCenter regCenter;
-
- @Mock
- private JobFacade jobFacade;
-
- private ElasticJobExecutor elasticJobExecutor;
-
- @Test
- public void assertExecuteWhenCommandLineIsEmpty() {
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, ShardingContextsBuilder.getMultipleShardingContexts());
- elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("", "IGNORE"), Collections.emptyList(), null);
- ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
- elasticJobExecutor.execute();
- }
-
- @Test(expected = JobSystemException.class)
- public void assertExecuteWhenExecuteFailureForSingleShardingItems() {
- assertExecuteWhenExecuteFailure(ShardingContextsBuilder.getSingleShardingContexts());
- }
-
- @Test
- public void assertExecuteWhenExecuteFailureForMultipleShardingItems() {
- assertExecuteWhenExecuteFailure(ShardingContextsBuilder.getMultipleShardingContexts());
- }
-
- private void assertExecuteWhenExecuteFailure(final ShardingContexts shardingContexts) {
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("not_exists_file", "THROW"), Collections.emptyList(), null);
- ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
- elasticJobExecutor.execute();
- }
-
- @Test
- public void assertExecuteSuccessForMultipleShardingItems() {
- assertExecuteSuccess(ShardingContextsBuilder.getMultipleShardingContexts());
- }
-
- @Test
- public void assertExecuteSuccessForSingleShardingItems() {
- assertExecuteSuccess(ShardingContextsBuilder.getSingleShardingContexts());
- }
-
- private void assertExecuteSuccess(final ShardingContexts shardingContexts) {
- ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
- elasticJobExecutor = new ElasticJobExecutor(regCenter, "SCRIPT", createJobConfiguration("exists_file param0 param1", "IGNORE"), Collections.emptyList(), null);
- ReflectionUtils.setFieldValue(elasticJobExecutor, "jobFacade", jobFacade);
- elasticJobExecutor.execute();
- }
-
- private JobConfiguration createJobConfiguration(final String scriptCommandLine, final String jobErrorHandlerType) {
- return JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
- .cron("0/1 * * * * ?").jobErrorHandlerType(jobErrorHandlerType).setProperty(ScriptJobExecutor.SCRIPT_KEY, scriptCommandLine).build();
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
deleted file mode 100644
index 7d7983a..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/executor/type/impl/WrongJobExecutorTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.executor.type.impl;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.config.JobConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.executor.ElasticJobExecutor;
-import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.executor.ShardingContexts;
-import org.apache.shardingsphere.elasticjob.lite.fixture.ShardingContextsBuilder;
-import org.apache.shardingsphere.elasticjob.lite.fixture.job.TestWrongJob;
-import org.apache.shardingsphere.elasticjob.lite.reg.base.CoordinatorRegistryCenter;
-import org.apache.shardingsphere.elasticjob.lite.tracing.event.JobStatusTraceEvent.State;
-import org.apache.shardingsphere.elasticjob.lite.util.ReflectionUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public final class WrongJobExecutorTest {
-
- @Mock
- private CoordinatorRegistryCenter regCenter;
-
- @Mock
- private JobFacade jobFacade;
-
- private ElasticJobExecutor wrongJobExecutor;
-
- @Before
- public void setUp() {
- wrongJobExecutor = new ElasticJobExecutor(regCenter, new TestWrongJob(), createJobConfiguration(), Collections.emptyList(), null);
- ReflectionUtils.setFieldValue(wrongJobExecutor, "jobFacade", jobFacade);
- }
-
- private JobConfiguration createJobConfiguration() {
- return JobConfiguration.newBuilder(ShardingContextsBuilder.JOB_NAME, 3)
- .cron("0/1 * * * * ?").shardingItemParameters("0=A,1=B,2=C").jobParameter("param").failover(true).misfire(false).jobErrorHandlerType("THROW").description("desc").build();
- }
-
- @Test(expected = RuntimeException.class)
- public void assertWrongJobExecutorWithSingleItem() {
- Map<Integer, String> map = new HashMap<>(1, 1);
- map.put(0, "A");
- ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", map);
- when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- wrongJobExecutor.execute();
- }
-
- @Test
- public void assertWrongJobExecutorWithMultipleItems() {
- Map<Integer, String> map = new HashMap<>(1, 1);
- map.put(0, "A");
- map.put(1, "B");
- ShardingContexts shardingContexts = new ShardingContexts("fake_task_id", "test_job", 10, "", map);
- when(jobFacade.getShardingContexts()).thenReturn(shardingContexts);
- wrongJobExecutor.execute();
- verify(jobFacade).getShardingContexts();
- verify(jobFacade).postJobStatusTraceEvent("fake_task_id", State.TASK_RUNNING, "");
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/JobCaller.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/JobCaller.java
deleted file mode 100644
index 57b77c7..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/JobCaller.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.job;
-
-import java.util.List;
-
-public interface JobCaller {
-
- /**
- * Execute job.
- */
- void execute();
-
- /**
- * Fetch the data.
- *
- * @param shardingItem sharding items of job
- * @return the list of data fetched
- */
- List<Object> fetchData(int shardingItem);
-
- /**
- * Process the data.
- *
- * @param data the data of the job
- */
- void processData(Object data);
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/OtherJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/OtherJob.java
deleted file mode 100644
index 07a9ba7..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/OtherJob.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.job;
-
-import org.apache.shardingsphere.elasticjob.lite.api.job.ElasticJob;
-
-public final class OtherJob implements ElasticJob {
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestDataflowJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestDataflowJob.java
deleted file mode 100644
index fe0e708..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestDataflowJob.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.job;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.DataflowJob;
-
-import java.util.List;
-
-@RequiredArgsConstructor
-public final class TestDataflowJob implements DataflowJob<Object> {
-
- private final JobCaller jobCaller;
-
- @Override
- public List<Object> fetchData(final ShardingContext shardingContext) {
- return jobCaller.fetchData(shardingContext.getShardingItem());
- }
-
- @Override
- public void processData(final ShardingContext shardingContext, final List<Object> data) {
- for (Object each : data) {
- jobCaller.processData(each);
- }
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestSimpleJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestSimpleJob.java
deleted file mode 100644
index 36acb79..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestSimpleJob.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.job;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
-
-@RequiredArgsConstructor
-public final class TestSimpleJob implements SimpleJob {
-
- private final JobCaller jobCaller;
-
- @Override
- public void execute(final ShardingContext shardingContext) {
- jobCaller.execute();
- }
-}
diff --git a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestWrongJob.java b/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestWrongJob.java
deleted file mode 100644
index 46ecfb6..0000000
--- a/elastic-job-lite-core/src/test/java/org/apache/shardingsphere/elasticjob/lite/fixture/job/TestWrongJob.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.shardingsphere.elasticjob.lite.fixture.job;
-
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.job.ShardingContext;
-import org.apache.shardingsphere.elasticjob.lite.api.job.type.SimpleJob;
-
-@RequiredArgsConstructor
-public final class TestWrongJob implements SimpleJob {
-
- @Override
- public void execute(final ShardingContext shardingContext) {
- throw new RuntimeException("WrongJobException");
- }
-}
diff --git a/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor b/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
index 611350f..349a0c4 100644
--- a/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
+++ b/elastic-job-lite-core/src/test/resources/META-INF/services/org.apache.shardingsphere.elasticjob.lite.executor.type.JobItemExecutor
@@ -15,5 +15,5 @@
# limitations under the License.
#
-org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.ClassedFooJobExecutor
-org.apache.shardingsphere.elasticjob.lite.executor.type.fixture.executor.TypedFooJobExecutor
+org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.ClassedFooJobExecutor
+org.apache.shardingsphere.elasticjob.lite.executor.fixture.executor.TypedFooJobExecutor