Ejemplo n.º 1
0
 protected void assertRegCenterCommonInfo() {
   assertThat(
       REG_CENTER.get("/" + jobName + "/leader/election/host"), is(localHostService.getIp()));
   assertThat(REG_CENTER.get("/" + jobName + "/config/shardingTotalCount"), is("3"));
   assertThat(REG_CENTER.get("/" + jobName + "/config/shardingItemParameters"), is("0=A,1=B,2=C"));
   assertThat(REG_CENTER.get("/" + jobName + "/config/cron"), is("0/1 * * * * ?"));
   assertThat(
       REG_CENTER.get("/" + jobName + "/servers/" + localHostService.getIp() + "/hostName"),
       is(localHostService.getHostName()));
   if (disabled) {
     assertTrue(
         REG_CENTER.isExisted(
             "/" + jobName + "/servers/" + localHostService.getIp() + "/disabled"));
   } else {
     assertFalse(
         REG_CENTER.isExisted(
             "/" + jobName + "/servers/" + localHostService.getIp() + "/disabled"));
   }
   assertFalse(
       REG_CENTER.isExisted("/" + jobName + "/servers/" + localHostService.getIp() + "/stoped"));
   assertThat(
       REG_CENTER.get("/" + jobName + "/servers/" + localHostService.getIp() + "/status"),
       is(ServerStatus.READY.name()));
   REG_CENTER.remove("/" + jobName + "/leader/election");
   assertTrue(leaderElectionService.isLeader());
 }
 @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);
 }