Search in sources :

Example 11 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class CloudJobFacadeTest method assertPostJobExecutionEvent.

@Test
public void assertPostJobExecutionEvent() {
    JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("fake_task_id", "test_job", ExecutionSource.NORMAL_TRIGGER, 0);
    jobFacade.postJobExecutionEvent(jobExecutionEvent);
    verify(eventBus).post(jobExecutionEvent);
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 12 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventBusTest method assertPostWithoutListener.

@Test
public void assertPostWithoutListener() throws NoSuchFieldException {
    jobEventBus = new JobEventBus();
    assertIsRegistered(false);
    ReflectionUtils.setFieldValue(jobEventBus, "eventBus", eventBus);
    jobEventBus.post(new JobExecutionEvent("fake_task_id", "test_event_bus_job", ExecutionSource.NORMAL_TRIGGER, 0));
    verify(eventBus, times(0)).post(Matchers.<JobEvent>any());
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 13 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventBusTest method assertPost.

@Test
public void assertPost() throws InterruptedException, NoSuchFieldException {
    jobEventBus = new JobEventBus(new TestJobEventConfiguration(jobEventCaller));
    assertIsRegistered(true);
    jobEventBus.post(new JobExecutionEvent("fake_task_id", "test_event_bus_job", ExecutionSource.NORMAL_TRIGGER, 0));
    while (!TestJobEventListener.isExecutionEventCalled()) {
        Thread.sleep(100L);
    }
    verify(jobEventCaller).call();
}
Also used : TestJobEventConfiguration(com.dangdang.ddframe.job.event.fixture.TestJobEventConfiguration) JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 14 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobExecutionEventTest method assertNewJobExecutionEvent.

@Test
public void assertNewJobExecutionEvent() {
    JobExecutionEvent actual = new JobExecutionEvent("fake_task_id", "test_job", JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
    assertThat(actual.getJobName(), is("test_job"));
    assertThat(actual.getSource(), is(JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER));
    assertThat(actual.getShardingItem(), is(0));
    assertNotNull(actual.getHostname());
    assertNotNull(actual.getStartTime());
    assertNull(actual.getCompleteTime());
    assertFalse(actual.isSuccess());
    assertThat(actual.getFailureCause(), is(""));
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Example 15 with JobExecutionEvent

use of com.dangdang.ddframe.job.event.type.JobExecutionEvent in project elastic-job by dangdangdotcom.

the class JobEventRdbListenerTest method assertPostJobExecutionEvent.

@Test
public void assertPostJobExecutionEvent() {
    JobExecutionEvent jobExecutionEvent = new JobExecutionEvent("fake_task_id", JOB_NAME, JobExecutionEvent.ExecutionSource.NORMAL_TRIGGER, 0);
    jobEventBus.post(jobExecutionEvent);
    verify(repository, atMost(1)).addJobExecutionEvent(jobExecutionEvent);
}
Also used : JobExecutionEvent(com.dangdang.ddframe.job.event.type.JobExecutionEvent) Test(org.junit.Test)

Aggregations

JobExecutionEvent (com.dangdang.ddframe.job.event.type.JobExecutionEvent)24 Test (org.junit.Test)20 Condition (com.dangdang.ddframe.job.event.rdb.JobEventRdbSearch.Condition)8 Date (java.util.Date)2 HashMap (java.util.HashMap)2 ShardingContext (com.dangdang.ddframe.job.api.ShardingContext)1 TestJobEventConfiguration (com.dangdang.ddframe.job.event.fixture.TestJobEventConfiguration)1 JobExecutionEventThrowable (com.dangdang.ddframe.job.event.type.JobExecutionEventThrowable)1 JobStatusTraceEvent (com.dangdang.ddframe.job.event.type.JobStatusTraceEvent)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1