Commits

bayard  committed 171ecee

Adding an exception throwing when the day of week or day of month contains both an L and numbers as that is not (yet) supported. Reported in QUARTZ-640 by Rex Wong

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@80869f7d36a-ea1c-0410-88ea-9fd03e4c9665

  • Participants
  • Parent commits 69ac12b

Comments (0)

Files changed (2)

File src/java/org/quartz/CronExpression.java

 
             while (exprsTok.hasMoreTokens() && exprOn <= YEAR) {
                 String expr = exprsTok.nextToken().trim();
+
+                // throw an exception if L is used with other days of the month
+                if(exprOn == DAY_OF_MONTH && expr.indexOf('L') != -1 && expr.length() > 1) {
+                    throw new ParseException("Support for specifying 'L' and 'LW' with other days of the month is not implemented", -1);
+                }
+                // throw an exception if L is used with other days of the week
+                if(exprOn == DAY_OF_WEEK && expr.indexOf('L') != -1 && expr.length() > 1) {
+                    throw new ParseException("Support for specifying 'L' with other days of the week is not implemented", -1);
+                }
+                
                 StringTokenizer vTok = new StringTokenizer(expr, ",");
                 while (vTok.hasMoreTokens()) {
                     String v = vTok.nextToken();

File src/test/java/org/quartz/CronExpressionTest.java

         }
     }
 
+    public void testQuartz640() throws ParseException {
+        try {
+            CronExpression cronExpression = new CronExpression("0 43 9 1,5,29,L * ?");
+            fail("Expected ParseException did not fire for L combined with other days of the month");
+        } catch(ParseException pe) {
+            assertTrue("Incorrect ParseException thrown", 
+                pe.getMessage().startsWith("Support for specifying 'L' and 'LW' with other days of the month is not implemented"));
+        }
+        try {
+            CronExpression cronExpression = new CronExpression("0 43 9 ? * SAT,SUN,L");
+            fail("Expected ParseException did not fire for L combined with other days of the week");
+        } catch(ParseException pe) {
+            assertTrue("Incorrect ParseException thrown", 
+                pe.getMessage().startsWith("Support for specifying 'L' with other days of the week is not implemented"));
+        }
+        try {
+            CronExpression cronExpression = new CronExpression("0 43 9 ? * 6,7,L");
+            fail("Expected ParseException did not fire for L combined with other days of the week");
+        } catch(ParseException pe) {
+            assertTrue("Incorrect ParseException thrown", 
+                pe.getMessage().startsWith("Support for specifying 'L' with other days of the week is not implemented"));
+        }
+    }
+
 }