Repository: jmrozanec/cron-utils (java)

Issue:
IllegalArgumentException for valid spring cron expression
I got sample expressions from docs of org.springframework.scheduling.support.CronSequenceGenerator class and try to get description of these expressions by CronDefinitionBuilder.instanceDefinitionFor(CronType.SPRING).
After that I've got exception Both, a day-of-week AND a day-of-month parameter, are not supported.

this is test case

```java
package ru.rencredit.budgetcontrol.test.cronutils;

import java.util.Locale;

import org.hamcrest.core.IsEqual;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import com.cronutils.descriptor.CronDescriptor;
import com.cronutils.model.CronType;
import com.cronutils.model.definition.CronDefinition;
import com.cronutils.model.definition.CronDefinitionBuilder;
import com.cronutils.parser.CronParser;

@RunWith(Parameterized.class)
public class CronUtilsTest
{
	@Parameters
	public static Object[] expressions()
	{
		return new Object[] {
				new Expr("0 0 * * * *", "every hour"),
				new Expr("*/10 * * * * *", "every 10 seconds"),
				new Expr("0 0 8-10 * * *", "every hour between 8 and 10"),
				new Expr("0 0 6,19 * * *", "at 6 and 19 hours"),
				new Expr("0 0/30 8-10 * * *", "every 30 minutes every hour between 8 and 10"),
				new Expr("0 0 9-17 * * MON-FRI", "every hour between 9 and 17 every day between Monday and Friday"),
				new Expr("0 0 0 25 12 ?", "at 00:00 at 25 day at December month")
		};
	}
	
	private Expr expressionToTest;
	
	public CronUtilsTest(Expr expressionToTest)
	{
		this.expressionToTest = expressionToTest;
	}
	
	@Test()
	public void test()
	{
		CronParser pareser = new CronParser( CronDefinitionBuilder.instanceDefinitionFor(CronType.SPRING) );
		
		String actualDescription = CronDescriptor.instance(Locale.ENGLISH).describe(pareser.parse(expressionToTest.getExpression()));
		
		Assert.assertThat(actualDescription, IsEqual.equalTo(expressionToTest.getDescription()));
	}
	
	
	private static class Expr
	{
		private final String expression;
		private final String description;
		
		public Expr(String expression, String description)
		{
			super();
			this.expression = expression;
			this.description = description;
		}
		public String getExpression()
		{
			return expression;
		}
		public String getDescription()
		{
			return description;
		}
	}
}

```

Pull request description:
Remove quartz specific cron validation from the spring cron definition.
Add test to cover the examples listed in the spring javadoc.

Fixes #343 

Patch:
diff --git a/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java b/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java
index 1b05014..b84bd2d 100755
--- a/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java
+++ b/src/main/java/com/cronutils/model/definition/CronDefinitionBuilder.java
@@ -348,7 +348,6 @@ public class CronDefinitionBuilder {
                 .withDayOfMonth().supportsL().supportsW().supportsLW().supportsQuestionMark().and()
                 .withMonth().and()
                 .withDayOfWeek().withValidRange(1, 7).withMondayDoWValue(2).supportsHash().supportsL().supportsQuestionMark().and()
-                .withCronValidation(CronConstraintsFactory.ensureEitherDayOfWeekOrDayOfMonth())
                 .instance();
     }
 


Test patch:
diff --git a/src/test/java/com/cronutils/model/definition/Issue343Test.java b/src/test/java/com/cronutils/model/definition/Issue343Test.java
new file mode 100644
index 0000000..c05c449
--- /dev/null
+++ b/src/test/java/com/cronutils/model/definition/Issue343Test.java
@@ -0,0 +1,45 @@
+package com.cronutils.model.definition;
+
+import com.cronutils.model.Cron;
+import com.cronutils.model.CronType;
+import com.cronutils.parser.CronParser;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class Issue343Test {
+
+    @Parameterized.Parameters(name = "{0}")
+    public static Object[] expressions() {
+        // List of expressions from https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/support/CronSequenceGenerator.html
+        return new Object[]{
+                "0 0 * * * *",
+                "*/10 * * * * *",
+                "0 0 8-10 * * *",
+                "0 0 6,19 * * *",
+                "0 0/30 8-10 * * *",
+                "0 0 9-17 * * MON-FRI",
+                "0 0 0 25 12 ?"
+        };
+    }
+
+    private final String expression;
+
+    public Issue343Test(String expression) {
+        this.expression = expression;
+    }
+
+    @Test
+    public void testSpringCronExpressions() {
+        CronParser parser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.SPRING));
+
+        try {
+            Cron parsed = parser.parse(expression);
+            Assert.assertNotNull(parsed);
+        } catch (IllegalArgumentException e) {
+            Assert.fail("This expression should pass: " + expression);
+        }
+    }
+}