You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/08/03 11:04:09 UTC

[3/6] CAMEL-4075 added camel-quartz2 component with thanks to Zemian

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextRestartTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextRestartTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextRestartTest.java
new file mode 100644
index 0000000..bef8a97
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextRestartTest.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class QuartzTwoCamelContextRestartTest {
+
+    private DefaultCamelContext camel1;
+    private DefaultCamelContext camel2;
+
+    @Before
+    public void setUp() throws Exception {
+        camel1 = new DefaultCamelContext();
+        camel1.setName("camel-1");
+        camel1.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("log:one", "mock:one");
+            }
+        });
+        camel1.start();
+
+        camel2 = new DefaultCamelContext();
+        camel2.setName("camel-2");
+        camel2.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("log:two", "mock:two");
+            }
+        });
+        camel2.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+    }
+
+    @Test
+    public void testTwoCamelContextRestart() throws Exception {
+        MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
+        mock1.expectedMinimumMessageCount(2);
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
+        mock2.expectedMinimumMessageCount(6);
+        mock1.assertIsSatisfied();
+
+        camel1.stop();
+
+        mock2.assertIsSatisfied();
+
+        // should resume triggers when we start camel 1 again
+        // fetch mock endpoint again because we have stopped camel context
+        mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
+        mock1.expectedMinimumMessageCount(3);
+        camel1.start();
+
+        mock1.assertIsSatisfied();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSameNameClashTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSameNameClashTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSameNameClashTest.java
new file mode 100644
index 0000000..0a90154
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSameNameClashTest.java
@@ -0,0 +1,86 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class QuartzTwoCamelContextSameNameClashTest extends Assert {
+
+    private DefaultCamelContext camel1;
+    private DefaultCamelContext camel2;
+
+    @Before
+    public void setUp() throws Exception {
+        camel1 = new DefaultCamelContext();
+        camel1.setName("myCamel");
+        camel1.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?")
+                    .log("Fired one")
+                    .to("mock:one");
+            }
+        });
+        camel1.start();
+
+        camel2 = new DefaultCamelContext();
+        camel2.setName("myCamel");
+        camel2.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?")
+                    .log("Fired two")
+                    .to("mock:two");
+            }
+        });
+        camel2.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+    }
+
+    @Test
+    public void testTwoCamelContext() throws Exception {
+        assertNotSame(camel1.getManagementName(), camel2.getManagementName());
+
+        MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
+        mock1.expectedMinimumMessageCount(2);
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
+        mock2.expectedMinimumMessageCount(6);
+        mock1.assertIsSatisfied();
+
+        camel1.stop();
+
+        mock2.assertIsSatisfied();
+
+        camel2.stop();        
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSuspendResumeTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSuspendResumeTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSuspendResumeTest.java
new file mode 100644
index 0000000..c55c848
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextSuspendResumeTest.java
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class QuartzTwoCamelContextSuspendResumeTest {
+
+    private DefaultCamelContext camel1;
+    private DefaultCamelContext camel2;
+
+    @Before
+    public void setUp() throws Exception {
+        camel1 = new DefaultCamelContext();
+        camel1.setName("camel-1");
+        camel1.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("mock:one");
+            }
+        });
+        camel1.start();
+
+        camel2 = new DefaultCamelContext();
+        camel2.setName("camel-2");
+        camel2.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("mock:two");
+            }
+        });
+        camel2.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+    }
+
+    @Test
+    public void testTwoCamelContextRestart() throws Exception {
+        MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
+        mock1.expectedMinimumMessageCount(2);
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
+        mock2.expectedMinimumMessageCount(6);
+        mock1.assertIsSatisfied();
+
+        camel1.suspend();
+
+        mock2.assertIsSatisfied();
+
+        // should resume triggers when we start camel 1 again
+        mock1.reset();
+        mock1.expectedMinimumMessageCount(2);
+        camel1.resume();
+
+        mock1.assertIsSatisfied();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextTest.java
new file mode 100644
index 0000000..9fbd053
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/QuartzTwoCamelContextTest.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @version 
+ */
+public class QuartzTwoCamelContextTest extends Assert {
+
+    private DefaultCamelContext camel1;
+    private DefaultCamelContext camel2;
+
+    @Before
+    public void setUp() throws Exception {
+        camel1 = new DefaultCamelContext();
+        camel1.setName("camel-1");
+        camel1.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").to("mock:one");
+            }
+        });
+        camel1.start();
+
+        camel2 = new DefaultCamelContext();
+        camel2.setName("camel-2");
+        camel2.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myOtherGroup/myOtherTimerName?cron=0/1+*+*+*+*+?").to("mock:two");
+            }
+        });
+        camel2.start();
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        camel1.stop();
+        camel2.stop();
+    }
+
+    @Test
+    public void testTwoCamelContext() throws Exception {
+        MockEndpoint mock1 = camel1.getEndpoint("mock:one", MockEndpoint.class);
+        mock1.expectedMinimumMessageCount(2);
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:two", MockEndpoint.class);
+        mock2.expectedMinimumMessageCount(6);
+        mock1.assertIsSatisfied();
+
+        camel1.stop();
+
+        mock2.assertIsSatisfied();
+
+        camel2.stop();        
+    }
+    
+    @Test
+    public void testThirdCamelContext() throws Exception {
+        camel1.stop();
+        
+        camel2.stop();
+                
+        DefaultCamelContext camel3 = new DefaultCamelContext();
+        camel3.setName("camel-3");
+        camel3.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("quartz2://myThirdGroup/myThirdTimerName?cron=0/1+*+*+*+*+?").to("mock:three");
+            }
+        });
+        camel3.start();
+        
+        MockEndpoint mock3 = camel3.getEndpoint("mock:three", MockEndpoint.class);
+        mock3.expectedMinimumMessageCount(2);
+        
+        mock3.assertIsSatisfied();
+        camel3.stop();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.java
new file mode 100644
index 0000000..a81e4ac
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringQuartzCronRouteTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.xml");
+    }
+
+    @Test
+    public void testQuartzCronRoute() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(3);
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppTest.java
new file mode 100644
index 0000000..f493b7a
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppTest.java
@@ -0,0 +1,79 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.TestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringQuartzPersistentStoreRestartAppTest extends TestSupport {
+
+    @Test
+    public void testQuartzPersistentStoreRestart() throws Exception {
+        // load spring app
+        AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.xml");
+
+        app.start();
+
+        CamelContext camel = app.getBean("camelContext", CamelContext.class);
+        assertNotNull(camel);
+
+        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
+        mock.expectedMinimumMessageCount(2);
+
+        mock.assertIsSatisfied();
+
+        app.stop();
+        
+        log.info("Restarting ...");
+        log.info("Restarting ...");
+        log.info("Restarting ...");
+
+        // NOTE:
+        // To test a restart where the app has crashed, then you can in QuartzEndpoint
+        // in the doShutdown method, then remove the following code line
+        //  deleteTrigger(getTrigger());
+        // then when we restart then there is old stale data which QuartzComponent
+        // is supposed to handle and start again
+
+        // load spring app
+        AbstractXmlApplicationContext app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartTest.xml");
+
+        app2.start();
+
+        CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
+        assertNotNull(camel2);
+
+        MockEndpoint mock2 = camel2.getEndpoint("mock:result", MockEndpoint.class);
+        mock2.expectedMinimumMessageCount(2);
+
+        mock2.assertIsSatisfied();
+
+        app2.stop();
+
+        // we're done so let's properly close the application contexts
+        app.close();
+        app2.close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartRouteTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartRouteTest.java
new file mode 100644
index 0000000..4da993f
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartRouteTest.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringQuartzPersistentStoreRestartRouteTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.xml");
+    }
+
+    @Test
+    public void testQuartzPersistentStore() throws Exception {
+        // skip testing on aix
+        if (isPlatform("aix")) {
+            return;
+        }
+
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(2);
+
+        assertMockEndpointsSatisfied();
+
+        // restart route
+        context().stopRoute("myRoute");
+        mock.reset();
+        mock.expectedMessageCount(0);
+
+        // wait a bit
+        Thread.sleep(2000);
+
+        assertMockEndpointsSatisfied();
+
+        // start route, and we got messages again
+        mock.reset();
+        mock.expectedMinimumMessageCount(2);
+
+        context().startRoute("myRoute");
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.java
new file mode 100644
index 0000000..957cee4
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.java
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringQuartzPersistentStoreTest extends CamelSpringTestSupport {
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreTest.xml");
+    }
+
+    @Test
+    public void testQuartzPersistentStore() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMinimumMessageCount(3);
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/StatefulQuartzRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/StatefulQuartzRouteTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/StatefulQuartzRouteTest.java
new file mode 100644
index 0000000..5ee23ac
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/component/quartz2/StatefulQuartzRouteTest.java
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.quartz2;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import java.util.List;
+
+/**
+ * @version 
+ */
+public class StatefulQuartzRouteTest extends CamelTestSupport {
+    protected MockEndpoint resultEndpoint;
+
+    @Test
+    public void testQuartz() throws Exception {
+        resultEndpoint = getMockEndpoint("mock:result");
+        resultEndpoint.expectedMessageCount(2);
+        resultEndpoint.message(0).header("triggerName").isEqualTo("myTimerName");
+        resultEndpoint.message(0).header("triggerGroup").isEqualTo("myGroup");
+
+        // lets test the receive worked
+        resultEndpoint.assertIsSatisfied();
+
+        List<Exchange> list = resultEndpoint.getReceivedExchanges();
+        for (Exchange exchange : list) {
+            Message in = exchange.getIn();
+            log.debug("Received: " + in + " with headers: " + in.getHeaders());
+        }
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                // START SNIPPET: example
+                from("quartz2://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1&stateful=true").to("mock:result");
+                // END SNIPPET: example
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/CronScheduledRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/CronScheduledRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/CronScheduledRoutePolicyTest.java
new file mode 100644
index 0000000..1d50801
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/CronScheduledRoutePolicyTest.java
@@ -0,0 +1,241 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.SuspendableService;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz2.QuartzComponent;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ServiceHelper;
+import org.junit.Test;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version 
+ */
+public class CronScheduledRoutePolicyTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testScheduledStartRoutePolicyWithTwoRoutes() throws Exception {
+        MockEndpoint success1 = context.getEndpoint("mock:success1", MockEndpoint.class);
+        MockEndpoint success2 = context.getEndpoint("mock:success2", MockEndpoint.class);
+        success1.expectedMessageCount(1);
+        success2.expectedMessageCount(1);
+
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteStartTime("*/3 * * * * ?");
+
+                from("direct:start1")
+                    .routeId("test1")
+                    .routePolicy(policy)
+                    .to("mock:success1");
+
+                from("direct:start2")
+                    .routeId("test2")
+                    .routePolicy(policy)
+                    .to("mock:success2");
+            }
+        });
+        context.start();
+        context.stopRoute("test1", 0, TimeUnit.MILLISECONDS);
+        context.stopRoute("test2", 0, TimeUnit.MILLISECONDS);
+
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test1") == ServiceStatus.Started);
+        assertTrue(context.getRouteStatus("test2") == ServiceStatus.Started);
+        template.sendBody("direct:start1", "Ready or not, Here, I come");
+        template.sendBody("direct:start2", "Ready or not, Here, I come");
+
+        success1.assertIsSatisfied();
+        success2.assertIsSatisfied();
+    }
+
+    @Test
+    public void testScheduledStopRoutePolicyWithTwoRoutes() throws Exception {
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteStopTime("*/3 * * * * ?");
+                policy.setRouteStopGracePeriod(0);
+                policy.setTimeUnit(TimeUnit.MILLISECONDS);
+
+                from("direct:start1")
+                    .routeId("test1")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+
+                from("direct:start2")
+                    .routeId("test2")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+            }
+        });
+        context.start();
+
+        Thread.sleep(5000);
+
+        assertTrue(context.getRouteStatus("test1") == ServiceStatus.Stopped);
+        assertTrue(context.getRouteStatus("test2") == ServiceStatus.Stopped);
+    }
+
+    @Test
+    public void testScheduledStartRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {    
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteStartTime("*/3 * * * * ?");
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            }
+        });
+        context.start();
+        context.stopRoute("test", 0, TimeUnit.MILLISECONDS);
+        
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+
+    @Test
+    public void testScheduledStopRoutePolicy() throws Exception {
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteStopTime("*/3 * * * * ?");
+                policy.setRouteStopGracePeriod(0);
+                policy.setTimeUnit(TimeUnit.MILLISECONDS);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+            }
+        });
+        context.start();
+        
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
+    }
+    
+    @Test
+    public void testScheduledStopRoutePolicyWithExtraPolicy() throws Exception {
+        final MyRoutePolicy myPolicy = new MyRoutePolicy();
+
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteStopTime("*/3 * * * * ?");
+                policy.setRouteStopGracePeriod(0);
+                policy.setTimeUnit(TimeUnit.MILLISECONDS);
+
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy, myPolicy)
+                    .to("mock:unreachable");
+            }
+        });
+        context.start();
+        
+        Thread.sleep(5000);
+
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
+        assertTrue("Should have called onStart", myPolicy.isStart());
+        assertTrue("Should have called onStop", myPolicy.isStop());
+    }
+    
+    @Test
+    public void testScheduledSuspendRoutePolicy() throws Exception {
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteSuspendTime("*/3 * * * * ?");
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+            } 
+        });
+        context.start();
+        
+        Thread.sleep(5000);
+
+        // when suspending its only the consumer that suspends
+        // there is a ticket to improve this
+        Consumer consumer = context.getRoute("test").getConsumer();
+        SuspendableService ss = (SuspendableService) consumer;
+        assertTrue("Consumer should be suspended", ss.isSuspended());
+    }
+    
+    @Test
+    public void testScheduledResumeRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+                policy.setRouteResumeTime("*/3 * * * * ?");
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            } 
+        });
+        context.start();
+
+        ServiceHelper.suspendService(context.getRoute("test").getConsumer());
+
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+
+        success.assertIsSatisfied();
+    }  
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MultiplePoliciesOnRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MultiplePoliciesOnRouteTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MultiplePoliciesOnRouteTest.java
new file mode 100644
index 0000000..1aeff90
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MultiplePoliciesOnRouteTest.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz2.QuartzComponent;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.ThrottlingInflightRoutePolicy;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import java.util.Date;
+
+/**
+ * @version 
+ */
+public class MultiplePoliciesOnRouteTest extends CamelTestSupport {
+    private String url = "seda:foo?concurrentConsumers=20";
+    private int size = 100;
+    
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = new JndiRegistry(createJndiContext());
+        registry.bind("startPolicy", createRouteStartPolicy());
+        registry.bind("throttlePolicy", createThrottlePolicy());
+        return registry;
+    }
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    private RoutePolicy createRouteStartPolicy() {
+        SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+        long startTime = System.currentTimeMillis() + 3000L;
+        policy.setRouteStartDate(new Date(startTime));
+        policy.setRouteStartRepeatCount(1);
+        policy.setRouteStartRepeatInterval(3000);
+        
+        return policy;
+    }
+    
+    private RoutePolicy createThrottlePolicy() {
+        ThrottlingInflightRoutePolicy policy = new ThrottlingInflightRoutePolicy();
+        policy.setMaxInflightExchanges(10);
+        return policy;
+    }
+    
+    @Test
+    public void testMultiplePoliciesOnRoute() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
+        success.expectedMinimumMessageCount(size - 10);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {   
+                from(url)
+                    .routeId("test")
+                    .routePolicyRef("startPolicy, throttlePolicy")
+                    .to("log:foo?groupSize=10")
+                    .to("mock:success");
+            }
+        });
+        context.start();
+
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+            Thread.sleep(3);
+        }
+
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MyRoutePolicy.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MyRoutePolicy.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MyRoutePolicy.java
new file mode 100644
index 0000000..5df1861
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/MyRoutePolicy.java
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.Route;
+import org.apache.camel.impl.RoutePolicySupport;
+
+/**
+ *
+ */
+public class MyRoutePolicy extends RoutePolicySupport {
+    
+    private boolean start;
+    private boolean stop;
+
+    @Override
+    public void onStart(Route route) {
+        start = true;
+    }
+
+    @Override
+    public void onStop(Route route) {
+        stop = true;
+    }
+
+    public boolean isStart() {
+        return start;
+    }
+
+    public boolean isStop() {
+        return stop;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/RouteAutoStopFalseCronScheduledPolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/RouteAutoStopFalseCronScheduledPolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/RouteAutoStopFalseCronScheduledPolicyTest.java
new file mode 100644
index 0000000..2a459a4
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/RouteAutoStopFalseCronScheduledPolicyTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+/**
+ * Test CronScheduledRoutePolicy also works if the route has been configured
+ * with noAutoStartup
+ */
+public class RouteAutoStopFalseCronScheduledPolicyTest extends CamelTestSupport {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testCronPolicy() throws Exception {
+        // send a message on the seda queue so we have a message to start with
+        template.sendBody("seda:foo", "Hello World");
+
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+
+        final CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+        policy.setRouteStartTime("*/5 * * * * ?");
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("seda:foo").routeId("foo").noAutoStartup()
+                        .routePolicy(policy)
+                        .to("mock:foo");
+            }
+        });
+        context.start();
+
+        assertMockEndpointsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleDate.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleDate.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleDate.java
new file mode 100644
index 0000000..3a50de7
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleDate.java
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import java.util.Date;
+
+public class SimpleDate extends Date {
+
+    private static final long serialVersionUID = 1L;
+
+    public SimpleDate() {
+        this(3000);
+    }
+
+    public SimpleDate(long milliseconds) {
+        super(System.currentTimeMillis() + milliseconds);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledCombinedRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledCombinedRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledCombinedRoutePolicyTest.java
new file mode 100644
index 0000000..17e254b
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledCombinedRoutePolicyTest.java
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz2.QuartzComponent;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+import java.util.Date;
+
+/**
+ * @version 
+ */
+public class SimpleScheduledCombinedRoutePolicyTest extends CamelTestSupport {
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testScheduledStartAndStopRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {   
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long startTime = System.currentTimeMillis() + 3000L;
+                long stopTime = System.currentTimeMillis() + 8000L;
+                policy.setRouteStartDate(new Date(startTime));
+                policy.setRouteStartRepeatCount(1);
+                policy.setRouteStartRepeatInterval(3000);
+                policy.setRouteStopDate(new Date(stopTime));
+                policy.setRouteStopRepeatCount(1);
+                policy.setRouteStopRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            }
+        });
+        context.start();
+        
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
+        
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledRoutePolicyTest.java
new file mode 100644
index 0000000..87ae238
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SimpleScheduledRoutePolicyTest.java
@@ -0,0 +1,257 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz2.QuartzComponent;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.util.ServiceHelper;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version 
+ */
+public class SimpleScheduledRoutePolicyTest extends CamelTestSupport {
+    private static final transient Logger LOG = LoggerFactory.getLogger(SimpleScheduledRoutePolicyTest.class);
+    
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    @Test
+    public void testScheduledStartRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {   
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long startTime = System.currentTimeMillis() + 3000L;
+                policy.setRouteStartDate(new Date(startTime));
+                policy.setRouteStartRepeatCount(1);
+                policy.setRouteStartRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            }
+        });
+        context.start();
+        context.stopRoute("test", 0, TimeUnit.MILLISECONDS);
+        
+        Thread.sleep(5000);
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+
+    @Test
+    public void testScheduledStopRoutePolicy() throws Exception {
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long startTime = System.currentTimeMillis() + 3000;
+                policy.setRouteStopDate(new Date(startTime));
+                policy.setRouteStopRepeatCount(1);
+                policy.setRouteStopRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+            }
+        });
+        context.start();
+        
+        Thread.sleep(4000);
+
+        assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
+
+        boolean consumerStopped = false;
+        try {
+            template.sendBody("direct:start", "Ready or not, Here, I come");
+        } catch (CamelExecutionException e) {
+            consumerStopped = true;
+        }    
+        assertTrue(consumerStopped);
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+    } 
+    
+    @Test
+    public void testScheduledSuspendRoutePolicy() throws Exception {
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long startTime = System.currentTimeMillis() + 3000L;
+                policy.setRouteSuspendDate(new Date(startTime));
+                policy.setRouteSuspendRepeatCount(1);
+                policy.setRouteSuspendRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:unreachable");
+            } 
+        });
+        context.start();
+        
+        Thread.sleep(4000);
+
+        boolean consumerSuspended = false;
+        try {
+            template.sendBody("direct:start", "Ready or not, Here, I come");
+        } catch (CamelExecutionException e) {
+            consumerSuspended = true;
+        }        
+        assertTrue(consumerSuspended);
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+    }    
+    
+    @Test
+    public void testScheduledResumeRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long startTime = System.currentTimeMillis() + 3000L;
+                policy.setRouteResumeDate(new Date(startTime));
+                policy.setRouteResumeRepeatCount(1);
+                policy.setRouteResumeRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            } 
+        });
+        context.start();
+
+        ServiceHelper.suspendService(context.getRoute("test").getConsumer());
+        try {
+            template.sendBody("direct:start", "Ready or not, Here, I come");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            LOG.debug("Consumer successfully suspended");
+        } 
+        
+        Thread.sleep(4000);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+        
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+    
+    @Test
+    public void testScheduledSuspendAndResumeRoutePolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long suspendTime = System.currentTimeMillis() + 1000L;
+                policy.setRouteSuspendDate(new Date(suspendTime));
+                policy.setRouteSuspendRepeatCount(0);
+                policy.setRouteSuspendRepeatInterval(3000);
+                long resumeTime = System.currentTimeMillis() + 4000L;
+                policy.setRouteResumeDate(new Date(resumeTime));
+                policy.setRouteResumeRepeatCount(1);
+                policy.setRouteResumeRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            } 
+        });
+        context.start();
+        Thread.sleep(1000);
+        
+        try {
+            template.sendBody("direct:start", "Ready or not, Here, I come");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            LOG.debug("Consumer successfully suspended");
+        } 
+        
+        Thread.sleep(4000);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+        
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+    
+    @Test
+    public void testScheduledSuspendAndRestartPolicy() throws Exception {
+        MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);
+        success.expectedMessageCount(1);
+        
+        context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                SimpleScheduledRoutePolicy policy = new SimpleScheduledRoutePolicy();
+                long suspendTime = System.currentTimeMillis() + 1000L;
+                policy.setRouteSuspendDate(new Date(suspendTime));
+                policy.setRouteSuspendRepeatCount(0);
+                long startTime = System.currentTimeMillis() + 4000L;
+                policy.setRouteStartDate(new Date(startTime));
+                policy.setRouteResumeRepeatCount(1);
+                policy.setRouteResumeRepeatInterval(3000);
+                
+                from("direct:start")
+                    .routeId("test")
+                    .routePolicy(policy)
+                    .to("mock:success");
+            } 
+        });
+        context.start();
+        Thread.sleep(1000);
+        
+        try {
+            template.sendBody("direct:start", "Ready or not, Here, I come");
+            fail("Should have thrown an exception");
+        } catch (CamelExecutionException e) {
+            LOG.debug("Consumer successfully suspended");
+        } 
+        
+        Thread.sleep(4000);
+        template.sendBody("direct:start", "Ready or not, Here, I come");
+        
+        context.getComponent("quartz2", QuartzComponent.class).stop();
+        success.assertIsSatisfied();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringCronScheduledRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringCronScheduledRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringCronScheduledRoutePolicyTest.java
new file mode 100644
index 0000000..2a7d97f
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringCronScheduledRoutePolicyTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringCronScheduledRoutePolicyTest extends SpringScheduledRoutePolicyTest {
+
+    @Before
+    public void setUp() {
+        setApplicationContext(new ClassPathXmlApplicationContext("org/apache/camel/routepolicy/quartz2/CronPolicies.xml"));
+        setTestType(TestType.CRON);
+    }
+    
+    @Test
+    public void testScheduledStartRoutePolicy() throws Exception {
+        startTest();
+    }
+
+    @Test
+    public void testScheduledStopRoutePolicy() throws Exception {
+        stopTest();
+    }
+    
+    @Test
+    public void testScheduledSuspendRoutePolicy() throws Exception {
+        suspendTest();
+    }
+    
+    @Test
+    public void testScheduledResumeRoutePolicy() throws Exception {
+        resumeTest();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringMultiplePoliciesOnRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringMultiplePoliciesOnRouteTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringMultiplePoliciesOnRouteTest.java
new file mode 100644
index 0000000..b370301
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringMultiplePoliciesOnRouteTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.test.spring.CamelSpringTestSupport;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * @version 
+ */
+public class SpringMultiplePoliciesOnRouteTest extends CamelSpringTestSupport {
+    private String url = "seda:foo?concurrentConsumers=20";
+    private int size = 100;
+
+    @Test
+    public void testMultiplePoliciesOnRoute() throws Exception {
+        // we use seda which are not persistent and hence can loose a message
+        // when we get graceful shutdown support we can prevent this
+        getMockEndpoint("mock:success").expectedMinimumMessageCount(size - 10);
+
+        for (int i = 0; i < size; i++) {
+            template.sendBody(url, "Message " + i);
+            Thread.sleep(3);
+        }
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/routepolicy/quartz2/MultiplePolicies.xml");
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringScheduledRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringScheduledRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringScheduledRoutePolicyTest.java
new file mode 100644
index 0000000..b4b40ac
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringScheduledRoutePolicyTest.java
@@ -0,0 +1,139 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.model.ModelCamelContext;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.test.junit4.TestSupport;
+import org.apache.camel.util.ServiceHelper;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @version 
+ */
+public abstract class SpringScheduledRoutePolicyTest extends TestSupport {
+    protected enum TestType {
+        SIMPLE, CRON
+    }
+    private ClassPathXmlApplicationContext applicationContext;
+    private TestType testType;       
+    
+    public void startTest() throws Exception {
+        CamelContext context = startRouteWithPolicy("startPolicy");
+        
+        MockEndpoint mock = context.getEndpoint("mock:success", MockEndpoint.class);
+        mock.expectedMinimumMessageCount(1);
+        
+        context.stopRoute("testRoute", 0, TimeUnit.MILLISECONDS);
+        
+        Thread.sleep(4000);
+        assertTrue(context.getRouteStatus("testRoute") == ServiceStatus.Started);
+        context.createProducerTemplate().sendBody("direct:start", "Ready or not, Here, I come");
+
+        context.stop();
+        mock.assertIsSatisfied();
+    }
+
+    
+    public void stopTest() throws Exception {
+        boolean consumerStopped = false;
+        
+        CamelContext context = startRouteWithPolicy("stopPolicy");
+        
+        Thread.sleep(4000);
+        assertTrue(context.getRouteStatus("testRoute") == ServiceStatus.Stopped);
+        try {
+            context.createProducerTemplate().sendBody("direct:start", "Ready or not, Here, I come");
+        } catch (CamelExecutionException e) {
+            consumerStopped = true;
+        }    
+        context.stop();
+        assertTrue(consumerStopped);
+    }
+    
+    
+    public void suspendTest() throws Exception {
+        boolean consumerSuspended = false;
+
+        CamelContext context = startRouteWithPolicy("suspendPolicy");
+        
+        Thread.sleep(4000);
+        try {
+            context.createProducerTemplate().sendBody("direct:start", "Ready or not, Here, I come");
+        } catch (CamelExecutionException e) {
+            consumerSuspended = true;
+        }        
+        
+        context.stop();
+        assertTrue(consumerSuspended);
+    }
+    
+    public void resumeTest() throws Exception {
+        CamelContext context = startRouteWithPolicy("resumePolicy");
+        
+        MockEndpoint mock = context.getEndpoint("mock:success", MockEndpoint.class);
+        mock.expectedMinimumMessageCount(1);
+
+        ServiceHelper.suspendService(context.getRoute("testRoute").getConsumer());
+        
+        Thread.sleep(4000);
+        context.createProducerTemplate().sendBody("direct:start", "Ready or not, Here, I come");
+        
+        context.stop();
+        mock.assertIsSatisfied();
+    }
+    
+    @SuppressWarnings("unchecked")
+    private CamelContext startRouteWithPolicy(String policyBeanName) throws Exception {
+        CamelContext context = new DefaultCamelContext();
+        List<RouteDefinition> routes = (List<RouteDefinition>)applicationContext.getBean("testRouteContext");
+        RoutePolicy policy = applicationContext.getBean(policyBeanName, RoutePolicy.class);
+        assertTrue(getTestType() == TestType.SIMPLE 
+            ? policy instanceof SimpleScheduledRoutePolicy 
+            : policy instanceof CronScheduledRoutePolicy);
+        routes.get(0).routePolicy(policy);
+        ((ModelCamelContext)context).addRouteDefinitions(routes);
+        context.start();
+        return context;
+    }
+    
+    public ClassPathXmlApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+    public void setApplicationContext(ClassPathXmlApplicationContext applicationContext) {
+        this.applicationContext = applicationContext;
+    }
+
+    public TestType getTestType() {
+        return testType;
+    }
+
+    public void setTestType(TestType testType) {
+        this.testType = testType;
+    }    
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringSimpleScheduledRoutePolicyTest.java
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringSimpleScheduledRoutePolicyTest.java b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringSimpleScheduledRoutePolicyTest.java
new file mode 100644
index 0000000..98e9862
--- /dev/null
+++ b/components/camel-quartz2/src/test/java/org/apache/camel/routepolicy/quartz2/SpringSimpleScheduledRoutePolicyTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.routepolicy.quartz2;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SpringSimpleScheduledRoutePolicyTest extends SpringScheduledRoutePolicyTest {
+    
+    @Before
+    public void setUp() {
+        setApplicationContext(new ClassPathXmlApplicationContext("org/apache/camel/routepolicy/quartz2/SimplePolicies.xml"));
+        setTestType(TestType.SIMPLE);
+    }
+    
+    @Test
+    public void testScheduledStartRoutePolicy() throws Exception {
+        startTest();
+    }
+
+    @Test
+    public void testScheduledStopRoutePolicy() throws Exception {
+        stopTest();
+    }
+    
+    @Test
+    public void testScheduledSuspendRoutePolicy() throws Exception {
+        suspendTest();
+    }
+    
+    @Test
+    public void testScheduledResumeRoutePolicy() throws Exception {
+        resumeTest();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/resources/log4j.properties b/components/camel-quartz2/src/test/resources/log4j.properties
new file mode 100644
index 0000000..86e4b3e
--- /dev/null
+++ b/components/camel-quartz2/src/test/resources/log4j.properties
@@ -0,0 +1,37 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements.  See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You 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.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, file
+
+# uncomment the following to enable camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+#log4j.logger.org.apache.camel.component.quartz2=DEBUG
+#log4j.logger.org.apache.camel.routepolicy.quartz2=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1}:%-4L - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-quartz2-test.log

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.xml b/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.xml
new file mode 100644
index 0000000..57276a4
--- /dev/null
+++ b/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzCronRouteTest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="quartz2://myGroup/myTimerName?cron=0/2+*+*+*+*+?"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/e429d7c0/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartTest.xml b/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartTest.xml
new file mode 100644
index 0000000..26f18fd
--- /dev/null
+++ b/components/camel-quartz2/src/test/resources/org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartTest.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <!-- the persistent store for quartz -->
+  <jdbc:embedded-database id="camel_quartz" type="DERBY">
+    <!-- do not load script as database alreaady exists -->
+  </jdbc:embedded-database>
+
+  <bean id="quartz" class="org.apache.camel.component.quartz2.QuartzComponent">
+    <property name="scheduler" ref="scheduler"/>
+    <property name="autoStartScheduler" value="true"/>
+  </bean>
+
+  <!-- jdbc:initialize-database must come before this so the job store exists -->
+  <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
+    <property name="dataSource" ref="camel_quartz"/>
+    <property name="autoStartup" value="false"/>
+    <!-- let Camel start -->
+    <property name="schedulerContextAsMap">
+      <!-- hook Camel into Quartz -->
+      <map>
+        <entry key="CamelQuartzCamelContext" value-ref="camelContext"/>
+      </map>
+    </property>
+    <property name="quartzProperties">
+      <props>
+        <prop key="org.quartz.scheduler.instanceName">myscheduler</prop>
+        <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
+        <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
+        <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
+        <prop key="org.quartz.jobStore.isClustered">false</prop>
+      </props>
+    </property>
+  </bean>
+
+  <camelContext id="camelContext" managementNamePattern="#name#" xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="quartz2://app/test?trigger.repeatInterval=1000&amp;trigger.repeatCount=-1&amp;stateful=true"/>
+      <to uri="log:trigger"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
+
+</beans>