use of com.netflix.simianarmy.TestMonkey in project SimianArmy by Netflix.
the class TestBasicCalendar method testMonkeyTime.
@Test
void testMonkeyTime() {
Calendar test = Calendar.getInstance();
Monkey monkey = new TestMonkey();
// using leap day b/c it is not a holiday & not a weekend
test.set(Calendar.YEAR, 2012);
test.set(Calendar.MONTH, Calendar.FEBRUARY);
test.set(Calendar.DAY_OF_MONTH, 29);
// 8am leap day
test.set(Calendar.HOUR_OF_DAY, 8);
setNow(test);
Assert.assertFalse(isMonkeyTime(monkey));
// 10am leap day
test.set(Calendar.HOUR_OF_DAY, 10);
setNow(test);
Assert.assertTrue(isMonkeyTime(monkey));
// 5pm leap day
test.set(Calendar.HOUR_OF_DAY, 17);
setNow(test);
Assert.assertFalse(isMonkeyTime(monkey));
// set to the following Saturday so we can test we dont run on weekends
// even though within "business hours"
test.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
test.set(Calendar.HOUR_OF_DAY, 10);
setNow(test);
Assert.assertFalse(isMonkeyTime(monkey));
// test config overrides
PROPS.setProperty("simianarmy.calendar.isMonkeyTime", Boolean.toString(true));
Assert.assertTrue(isMonkeyTime(monkey));
PROPS.setProperty("simianarmy.calendar.isMonkeyTime", Boolean.toString(false));
Assert.assertFalse(isMonkeyTime(monkey));
}
Aggregations