Search in sources :

Example 1 with TestSimpleJob

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

Example 2 with TestSimpleJob

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));
}
Also used : TestSimpleJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration) TestSimpleJob(com.dangdang.ddframe.job.fixture.job.TestSimpleJob) DefaultJobExceptionHandler(com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler) DefaultExecutorServiceHandler(com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler) Test(org.junit.Test)

Example 3 with TestSimpleJob

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

Example 4 with TestSimpleJob

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));
}
Also used : SimpleJobExecutor(com.dangdang.ddframe.job.executor.type.SimpleJobExecutor) TestSimpleJobConfiguration(com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration) TestSimpleJob(com.dangdang.ddframe.job.fixture.job.TestSimpleJob) Test(org.junit.Test)

Aggregations

TestSimpleJob (com.dangdang.ddframe.job.fixture.job.TestSimpleJob)4 TestSimpleJobConfiguration (com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration)3 Test (org.junit.Test)3 DefaultExecutorServiceHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler)1 DefaultJobExceptionHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler)1 SimpleJobExecutor (com.dangdang.ddframe.job.executor.type.SimpleJobExecutor)1 TestDataflowJobConfiguration (com.dangdang.ddframe.job.fixture.config.TestDataflowJobConfiguration)1 Before (org.junit.Before)1