use of com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class JobExecutorFactoryTest method assertGetJobExecutorForScriptJob.
@Test
public void assertGetJobExecutorForScriptJob() {
when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "script_test_job", 10, "", Collections.<Integer, String>emptyMap()));
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("test.sh", IgnoreJobExceptionHandler.class));
assertThat(JobExecutorFactory.getJobExecutor(null, jobFacade), instanceOf(ScriptJobExecutor.class));
}
use of com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class ScriptJobExecutorTest method assertExecuteWhenExecuteFailure.
@SuppressWarnings("unchecked")
private void assertExecuteWhenExecuteFailure(final ShardingContexts shardingContexts) throws IOException, NoSuchFieldException {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("not_exists_file", ThrowJobExceptionHandler.class));
scriptJobExecutor = new ScriptJobExecutor(jobFacade);
scriptJobExecutor.execute();
}
use of com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class ScriptJobExecutorTest method assertExecuteWhenCommandLineIsEmpty.
@Test
public void assertExecuteWhenCommandLineIsEmpty() throws IOException {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, ShardingContextsBuilder.getMultipleShardingContexts());
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("", IgnoreJobExceptionHandler.class));
scriptJobExecutor = new ScriptJobExecutor(jobFacade);
scriptJobExecutor.execute();
}
use of com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class ScriptJobExecutorTest method assertExecuteSuccess.
private void assertExecuteSuccess(final ShardingContexts shardingContexts) throws IOException, NoSuchFieldException {
ElasticJobVerify.prepareForIsNotMisfire(jobFacade, shardingContexts);
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestScriptJobConfiguration("exists_file param0 param1", IgnoreJobExceptionHandler.class));
scriptJobExecutor = new ScriptJobExecutor(jobFacade);
scriptJobExecutor.execute();
verify(jobFacade).loadJobRootConfiguration(true);
}
use of com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration in project elastic-job by dangdangdotcom.
the class JobConfigurationGsonTypeAdapterTest method assertFromScriptJobJson.
@Test
public void assertFromScriptJobJson() {
TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getScriptJobJson(ThrowJobExceptionHandler.class.getCanonicalName()), TestJobRootConfiguration.class);
TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestScriptJobConfiguration("test.sh", ThrowJobExceptionHandler.class).getTypeConfig());
assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
}
Aggregations