use of com.dangdang.ddframe.job.fixture.job.TestSimpleJob in project elastic-job by dangdangdotcom.
the class JobExecutorFactoryTest method assertGetJobExecutorTwice.
@Test
public void assertGetJobExecutorTwice() {
when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "twice_test_job", 10, "", Collections.<Integer, String>emptyMap()));
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestDataflowJobConfiguration(false));
AbstractElasticJobExecutor executor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
AbstractElasticJobExecutor anotherExecutor = JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade);
assertTrue(executor.hashCode() != anotherExecutor.hashCode());
}
use of com.dangdang.ddframe.job.fixture.job.TestSimpleJob in project elastic-job by dangdangdotcom.
the class SimpleJobExecutorTest method assertNewExecutorWithDefaultHandlers.
@Test
public void assertNewExecutorWithDefaultHandlers() throws NoSuchFieldException {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration("ErrorHandler", Object.class.getName()));
SimpleJobExecutor simpleJobExecutor = new SimpleJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("executorService")), instanceOf(new DefaultExecutorServiceHandler().createExecutorService("test_job").getClass()));
assertThat(ReflectionUtils.getFieldValue(simpleJobExecutor, AbstractElasticJobExecutor.class.getDeclaredField("jobExceptionHandler")), instanceOf(DefaultJobExceptionHandler.class));
}
use of com.dangdang.ddframe.job.fixture.job.TestSimpleJob in project elastic-job by dangdangdotcom.
the class SimpleJobExecutorTest method setUp.
@Before
public void setUp() throws NoSuchFieldException {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
simpleJobExecutor = new SimpleJobExecutor(new TestSimpleJob(jobCaller), jobFacade);
}
use of com.dangdang.ddframe.job.fixture.job.TestSimpleJob in project elastic-job by dangdangdotcom.
the class JobExecutorFactoryTest method assertGetJobExecutorForSimpleJob.
@Test
public void assertGetJobExecutorForSimpleJob() {
when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "simple_test_job", 10, "", Collections.<Integer, String>emptyMap()));
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
assertThat(JobExecutorFactory.getJobExecutor(new TestSimpleJob(null), jobFacade), instanceOf(SimpleJobExecutor.class));
}
Aggregations