use of com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobExecutorFactoryTest method assertGetJobExecutorWhenJobClassWhenUnsupportedJob.
@Test(expected = JobConfigurationException.class)
public void assertGetJobExecutorWhenJobClassWhenUnsupportedJob() {
when(jobFacade.getShardingContexts()).thenReturn(new ShardingContexts("fake_task_id", "unsupported_test_job", 10, "", Collections.<Integer, String>emptyMap()));
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
JobExecutorFactory.getJobExecutor(new OtherJob(), jobFacade);
}
use of com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class JobConfigurationGsonTypeAdapterTest method assertFromSimpleJobJson.
@Test
public void assertFromSimpleJobJson() {
TestJobRootConfiguration actual = GsonFactory.getGson().fromJson(APIJsonConstants.getSimpleJobJson(ThrowJobExceptionHandler.class.getCanonicalName()), TestJobRootConfiguration.class);
TestJobRootConfiguration expected = new TestJobRootConfiguration(new TestSimpleJobConfiguration(ThrowJobExceptionHandler.class.getCanonicalName(), DefaultExecutorServiceHandler.class.getCanonicalName()).getTypeConfig());
assertThat(GsonFactory.getGson().toJson(actual), is(GsonFactory.getGson().toJson(expected)));
}
use of com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration 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.config.TestSimpleJobConfiguration in project elastic-job by dangdangdotcom.
the class WrongJobExecutorTest method setUp.
@Before
public void setUp() throws NoSuchFieldException {
when(jobFacade.loadJobRootConfiguration(true)).thenReturn(new TestSimpleJobConfiguration());
wrongSimpleJobExecutor = new SimpleJobExecutor(new TestWrongJob(), jobFacade);
}
use of com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration 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);
}
Aggregations