Search in sources :

Example 1 with TestSimpleJobConfiguration

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

Example 2 with TestSimpleJobConfiguration

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

Example 3 with TestSimpleJobConfiguration

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));
}
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 4 with TestSimpleJobConfiguration

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

Example 5 with TestSimpleJobConfiguration

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

Aggregations

TestSimpleJobConfiguration (com.dangdang.ddframe.job.fixture.config.TestSimpleJobConfiguration)6 Test (org.junit.Test)4 TestSimpleJob (com.dangdang.ddframe.job.fixture.job.TestSimpleJob)3 DefaultExecutorServiceHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultExecutorServiceHandler)2 Before (org.junit.Before)2 DefaultJobExceptionHandler (com.dangdang.ddframe.job.executor.handler.impl.DefaultJobExceptionHandler)1 SimpleJobExecutor (com.dangdang.ddframe.job.executor.type.SimpleJobExecutor)1 TestJobRootConfiguration (com.dangdang.ddframe.job.fixture.config.TestJobRootConfiguration)1 ThrowJobExceptionHandler (com.dangdang.ddframe.job.fixture.handler.ThrowJobExceptionHandler)1 OtherJob (com.dangdang.ddframe.job.fixture.job.OtherJob)1 TestWrongJob (com.dangdang.ddframe.job.fixture.job.TestWrongJob)1