@Before
 public void setUp() throws NoSuchFieldException {
   MockitoAnnotations.initMocks(this);
   ReflectionUtils.setFieldValue(leaderElectionService, "jobNodeStorage", jobNodeStorage);
   ReflectionUtils.setFieldValue(leaderElectionService, "localHostService", localHostService);
   when(localHostService.getIp()).thenReturn("mockedIP");
   when(localHostService.getHostName()).thenReturn("mockedHostName");
   when(jobNodeStorage.getJobConfiguration()).thenReturn(jobConfig);
   jobConfig.setOverwrite(true);
 }
 @Before
 public void setUp() throws NoSuchFieldException {
   producerManager = ProducerManagerFactory.getInstance(schedulerDriver, regCenter);
   ReflectionUtils.setFieldValue(producerManager, "configService", configService);
   ReflectionUtils.setFieldValue(producerManager, "readyService", readyService);
   ReflectionUtils.setFieldValue(producerManager, "runningService", runningService);
   ReflectionUtils.setFieldValue(
       producerManager, "transientProducerScheduler", transientProducerScheduler);
   ReflectionUtils.setFieldValue(producerManager, "lifecycleService", lifecycleService);
 }
 @Before
 public void setUp() throws NoSuchFieldException {
   MockitoAnnotations.initMocks(this);
   ReflectionUtils.setFieldValue(
       electionListenerManager,
       electionListenerManager.getClass().getSuperclass().getDeclaredField("jobNodeStorage"),
       jobNodeStorage);
   ReflectionUtils.setFieldValue(electionListenerManager, "serverNode", serverNode);
   ReflectionUtils.setFieldValue(
       electionListenerManager, "leaderElectionService", leaderElectionService);
   ReflectionUtils.setFieldValue(electionListenerManager, "serverService", serverService);
 }
 public static void setFieldValue(
     final JobConfiguration jobConfig, final String fieldName, final Object fieldValue) {
   try {
     ReflectionUtils.setFieldValue(
         jobConfig, jobConfig.getClass().getDeclaredField(fieldName), fieldValue);
   } catch (final NoSuchFieldException ex) {
     throw new RuntimeException(ex);
   }
 }
Ejemplo n.º 5
0
 @After
 public void tearDown() throws SchedulerException, NoSuchFieldException {
   ProcessCountStatistics.reset(jobName);
   JobScheduler jobScheduler = JobRegistry.getInstance().getJob(jobName);
   if (null != jobScheduler) {
     JobRegistry.getInstance().getJob(jobName).shutdown();
   }
   ReflectionUtils.setFieldValue(JobRegistry.getInstance(), "instance", null);
 }
 @Before
 public void setUp() throws NoSuchFieldException {
   MockitoAnnotations.initMocks(this);
   schedulerFacade =
       new SchedulerFacade(null, jobConfig, Collections.<ElasticJobListener>emptyList());
   ReflectionUtils.setFieldValue(schedulerFacade, "configService", configService);
   ReflectionUtils.setFieldValue(schedulerFacade, "leaderElectionService", leaderElectionService);
   ReflectionUtils.setFieldValue(schedulerFacade, "serverService", serverService);
   ReflectionUtils.setFieldValue(schedulerFacade, "shardingService", shardingService);
   ReflectionUtils.setFieldValue(schedulerFacade, "executionService", executionService);
   ReflectionUtils.setFieldValue(schedulerFacade, "statisticsService", statisticsService);
   ReflectionUtils.setFieldValue(schedulerFacade, "monitorService", monitorService);
   ReflectionUtils.setFieldValue(schedulerFacade, "listenerManager", listenerManager);
 }
Ejemplo n.º 7
0
 @Before
 public void initMocks() throws NoSuchFieldException {
   MockitoAnnotations.initMocks(this);
   ReflectionUtils.setFieldValue(
       jobNodeStorage, "coordinatorRegistryCenter", coordinatorRegistryCenter);
 }
 @Before
 public void setUp() throws NoSuchFieldException {
   MockitoAnnotations.initMocks(this);
   ReflectionUtils.setFieldValue(guaranteeService, "jobNodeStorage", jobNodeStorage);
   ReflectionUtils.setFieldValue(guaranteeService, "configService", configService);
 }