continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r332393 - in /maven/continuum/trunk/continuum-web/src: main/java/org/apache/maven/continuum/web/validation/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/maven/ test/java/org/apache/maven/continuum/ test/java/or...
Date Thu, 10 Nov 2005 23:06:37 GMT
Author: evenisse
Date: Thu Nov 10 15:06:29 2005
New Revision: 332393

URL: http://svn.apache.org/viewcvs?rev=332393&view=rev
Log:
Improve test in cron expression validator

Added:
    maven/continuum/trunk/continuum-web/src/test/
    maven/continuum/trunk/continuum-web/src/test/java/
    maven/continuum/trunk/continuum-web/src/test/java/org/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/
    maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
  (with props)
Modified:
    maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/CronExpressionValidator.java

Modified: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/CronExpressionValidator.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/CronExpressionValidator.java?rev=332393&r1=332392&r2=332393&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/CronExpressionValidator.java
(original)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/validation/CronExpressionValidator.java
Thu Nov 10 15:06:29 2005
@@ -18,6 +18,7 @@
 
 import org.codehaus.plexus.formica.FormicaException;
 import org.codehaus.plexus.formica.validation.AbstractValidator;
+import org.codehaus.plexus.util.StringUtils;
 import org.quartz.CronTrigger;
 
 import java.text.ParseException;
@@ -34,11 +35,22 @@
     {
         try
         {
+            String[] cronParams = StringUtils.split( cronExpression );
+            if ( cronParams.length != 6 )
+            {
+                return false;
+            }
+
             CronTrigger cronTrigger = new CronTrigger();
 
             cronTrigger.setCronExpression( cronExpression );
 
-            return true;
+            if ( cronParams[3].equals( "?" ) || cronParams[5].equals( "?" ) )
+            {
+                return true;
+            }
+
+            return false;
         }
         catch ( ParseException e )
         {

Added: maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java?rev=332393&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
(added)
+++ maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
Thu Nov 10 15:06:29 2005
@@ -0,0 +1,43 @@
+package org.apache.maven.continuum.web.validation;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class CronExpressionValidatorTest
+    extends PlexusTestCase
+{
+    public void testValidation()
+        throws Exception
+    {
+        CronExpressionValidator validator = new CronExpressionValidator();
+
+        assertTrue( validator.validate( "0 0 * * * ?" ) );
+
+        assertTrue( validator.validate( "0 0 * ? * *" ) );
+
+        assertTrue( validator.validate( "0 0,15,30,45 * * * ?" ) );
+
+        assertFalse( validator.validate( "0 0" ) );
+
+        assertFalse( validator.validate( "0 0 * * * *" ) );
+    }
+}

Propchange: maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-web/src/test/java/org/apache/maven/continuum/web/validation/CronExpressionValidatorTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message