Commits

timemachine committed bf34912

Fixed unit test so the scheduler node name is auto set to host name.

Comments (0)

Files changed (1)

timemachine-scheduler/src/test/java/integration/timemachine/scheduler/MultipleSchedulersTest.java

 
 import timemachine.scheduler.Scheduler;
 import timemachine.scheduler.SchedulerFactory;
+import timemachine.scheduler.support.Utils;
 
 
 public class MultipleSchedulersTest {
 		Scheduler scheduler1 = null, scheduler2 = null, scheduler3 = null;
 		try {
 			String resName = MultipleSchedulersTest.class.getName().replaceAll("\\.", "/");
-			
+
+			// This scheduler has useSingleton Enabled! So we should have ID starting 1.
 			scheduler1 = new SchedulerFactory(
 					"classpath:///" + resName + "-1.properties").createScheduler();
+
+			// This scheduler has useSingleton Enabled! So we should have ID starting 2.
 			scheduler2 = new SchedulerFactory(
 					"classpath:///" + resName + "-2.properties").createScheduler();
+
+			// This scheduler has useSingleton Disabled! So we should have ID reset back to 1.
 			scheduler3 = new SchedulerFactory(
 					"classpath:///" + resName + "-3.properties").createScheduler();
 			
 			assertThat(scheduler2.getSchedulerId(), is(2L));
 			assertThat(scheduler3.getSchedulerId(), is(1L)); // note it's one!
 
+			String hostName = Utils.getIpHost().getItem2();
+			assertThat(scheduler1.getSchedulerNode().getSchedulerData().getName(), is("MyScheduler1"));
+			assertThat(scheduler2.getSchedulerNode().getSchedulerData().getName(), is("MyScheduler2"));
+			assertThat(scheduler3.getSchedulerNode().getSchedulerData().getName(), is("MyScheduler3"));
+			assertThat(scheduler1.getSchedulerNode().getName(), is(hostName));
+			assertThat(scheduler2.getSchedulerNode().getName(), is(hostName));
+			assertThat(scheduler3.getSchedulerNode().getName(), is(hostName));
+
 			assertThat(scheduler1.getSchedulerNode().getId(), is(1L));
 			assertThat(scheduler2.getSchedulerNode().getId(), is(2L));
 			assertThat(scheduler3.getSchedulerNode().getId(), is(1L)); // note it's one!
 			
-			assertThat(scheduler1.getName(), is("MyScheduler1"));
-			assertThat(scheduler2.getName(), is("MyScheduler2"));
-			assertThat(scheduler3.getName(), is("MyScheduler3"));
-			
+			assertThat(scheduler1.getName(), is(hostName));
+			assertThat(scheduler2.getName(), is(hostName));
+			assertThat(scheduler3.getName(), is(hostName));
+
 			assertThat(scheduler1.getSchedulerNode().getHost(), is(scheduler2.getSchedulerNode().getHost()));
 			assertThat(scheduler1.getSchedulerNode().getIp(), is(scheduler2.getSchedulerNode().getIp()));
-			
+
 			assertThat(scheduler3.getSchedulerNode().getHost(), is(scheduler2.getSchedulerNode().getHost()));
 			assertThat(scheduler3.getSchedulerNode().getIp(), is(scheduler2.getSchedulerNode().getIp()));
 		} finally {