Search in sources :

Example 1 with TestScriptJobConfiguration

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));
}
Also used : TestScriptJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration) ScriptJobExecutor(com.dangdang.ddframe.job.executor.type.ScriptJobExecutor) IgnoreJobExceptionHandler(com.dangdang.ddframe.job.fixture.handler.IgnoreJobExceptionHandler) Test(org.junit.Test)

Example 2 with TestScriptJobConfiguration

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();
}
Also used : TestScriptJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration) ThrowJobExceptionHandler(com.dangdang.ddframe.job.fixture.handler.ThrowJobExceptionHandler)

Example 3 with TestScriptJobConfiguration

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();
}
Also used : TestScriptJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration) IgnoreJobExceptionHandler(com.dangdang.ddframe.job.fixture.handler.IgnoreJobExceptionHandler) Test(org.junit.Test)

Example 4 with TestScriptJobConfiguration

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);
}
Also used : TestScriptJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration) IgnoreJobExceptionHandler(com.dangdang.ddframe.job.fixture.handler.IgnoreJobExceptionHandler)

Example 5 with TestScriptJobConfiguration

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)));
}
Also used : TestScriptJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration) TestJobRootConfiguration(com.dangdang.ddframe.job.fixture.config.TestJobRootConfiguration) Test(org.junit.Test)

Aggregations

TestScriptJobConfiguration (com.dangdang.ddframe.job.fixture.config.TestScriptJobConfiguration)5 IgnoreJobExceptionHandler (com.dangdang.ddframe.job.fixture.handler.IgnoreJobExceptionHandler)3 Test (org.junit.Test)3 ScriptJobExecutor (com.dangdang.ddframe.job.executor.type.ScriptJobExecutor)1 TestJobRootConfiguration (com.dangdang.ddframe.job.fixture.config.TestJobRootConfiguration)1 ThrowJobExceptionHandler (com.dangdang.ddframe.job.fixture.handler.ThrowJobExceptionHandler)1