Exemplo n.º 1
0
 @Test
 public void testNullOrEmpty() {
   try {
     CronMonthField field = new CronMonthField();
     int result = field.validateValue(null);
     fail("CronMonthField validated null param and returned: " + result);
     result = field.validateValue(" ");
     fail("CronMonthField validated \" \" param and returned: " + result);
   } catch (CronTimeFieldException e) {
     // ignore
   }
 }
Exemplo n.º 2
0
 @Test
 public void testInRange() {
   try {
     CronMonthField field = new CronMonthField();
     for (int i = 1; i < 13; i++) {
       assertEquals(i, field.validateValue(String.valueOf(i)));
     }
     assertEquals(1, field.validateValue("01"));
     assertEquals(12, field.validateValue("12"));
   } catch (CronTimeFieldException e) {
     fail("Exception thrown checking valid values");
     e.printStackTrace();
   }
 }
Exemplo n.º 3
0
 @Test
 public void testOutOfRange() {
   try {
     CronMonthField field = new CronMonthField();
     int result = field.validateValue("60");
     fail("CronMonthField validated \"60\" param and returned: " + result);
   } catch (CronTimeFieldException e) {
     // ignore
   }
   try {
     CronMonthField field = new CronMonthField();
     int result = field.validateValue("-1");
     fail("CronMonthField validated \"-1\" param and returned: " + result);
   } catch (CronTimeFieldException e) {
     // ignore
   }
 }
Exemplo n.º 4
0
 @Test
 public void testNonNumeric() {
   try {
     CronMonthField field = new CronMonthField();
     int result = field.validateValue("10m");
     fail("CronMonthField validated \"m10\" param and returned: " + result);
     result = field.validateValue("all");
     fail("CronMonthField validated \"all\" param and returned: " + result);
   } catch (CronTimeFieldException e) {
     // ignore
   }
   try {
     CronHourField field = new CronHourField("all");
     fail("Created ERXCronHourField with \"all\" param");
   } catch (CronTimeFieldException e) {
     // ignore
   }
 }
Exemplo n.º 5
0
 @Test
 public void testValidNonNumeric() {
   try {
     CronMonthField field = new CronMonthField();
     assertEquals(1, field.validateValue("Jan"));
     assertEquals(1, field.validateValue("jan"));
     assertEquals(2, field.validateValue("Feb"));
     assertEquals(3, field.validateValue("Mar"));
     assertEquals(4, field.validateValue("Apr"));
     assertEquals(5, field.validateValue("May"));
     assertEquals(6, field.validateValue("Jun"));
     assertEquals(7, field.validateValue("Jul"));
     assertEquals(8, field.validateValue("Aug"));
     assertEquals(9, field.validateValue("Sep"));
     assertEquals(10, field.validateValue("Oct"));
     assertEquals(11, field.validateValue("Nov"));
     assertEquals(12, field.validateValue("Dec"));
   } catch (CronTimeFieldException e) {
     e.printStackTrace();
     fail();
   }
 }