This is an automated email from the ASF dual-hosted git repository.
ffang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 6770272f5b9 [CAMEL-17988]add tests in camel-quartz-starter (#537)
6770272f5b9 is described below
commit 6770272f5b941f04f4c50cce3a170d4018b54280
Author: Freeman(Yue) Fang <[email protected]>
AuthorDate: Fri Apr 22 13:49:09 2022 -0400
[CAMEL-17988]add tests in camel-quartz-starter (#537)
---
components-starter/camel-quartz-starter/pom.xml | 12 ++
.../quartz/springboot/BaseQuartzTest.java | 52 +++++++
.../springboot/DelegateEndpointQuartzTest.java | 167 +++++++++++++++++++++
.../FileConsumerQuartzSchedulerRestartTest.java | 101 +++++++++++++
.../FileConsumerQuartzSchedulerTest.java | 93 ++++++++++++
.../component/quartz/springboot/FromFileBase.java | 73 +++++++++
.../springboot/FromFileQuartzSchedulerTest.java | 105 +++++++++++++
.../springboot/MultiplePoliciesOnRouteTest.java | 119 +++++++++++++++
.../springboot/QuartUnderscoreTimerNameTest.java | 88 +++++++++++
.../springboot/QuartzAddDynamicRouteTest.java | 104 +++++++++++++
...uartzAddRoutesAfterCamelContextStartedTest.java | 81 ++++++++++
.../quartz/springboot/QuartzAutoStartTest.java | 104 +++++++++++++
.../quartz/springboot/QuartzCronMappingTest.java | 100 ++++++++++++
.../quartz/springboot/QuartzCronRoute2Test.java | 91 +++++++++++
.../springboot/QuartzCronRouteDurableJobTest.java | 70 +++++++++
.../springboot/QuartzCronRouteFireNowTest.java | 96 ++++++++++++
.../quartz/springboot/QuartzCronRouteTest.java | 109 ++++++++++++++
.../QuartzCronRouteWithSmallCacheTest.java | 121 +++++++++++++++
.../springboot/QuartzCronTriggerRouteTest.java | 99 ++++++++++++
.../springboot/QuartzCustomCalendarFireTest.java | 119 +++++++++++++++
.../springboot/QuartzCustomCalendarNoFireTest.java | 115 ++++++++++++++
.../quartz/springboot/QuartzInterruptTest.java | 99 ++++++++++++
.../springboot/QuartzJobRouteUnderscoreTest.java | 98 ++++++++++++
.../quartz/springboot/QuartzManagementTest.java | 110 ++++++++++++++
.../springboot/QuartzManuallyTriggerJobTest.java | 111 ++++++++++++++
.../springboot/QuartzRepeatIntervalTest.java | 92 ++++++++++++
.../springboot/QuartzRouteFireNowOnlyOnceTest.java | 95 ++++++++++++
.../quartz/springboot/QuartzRouteFireNowTest.java | 96 ++++++++++++
.../quartz/springboot/QuartzRouteRestartTest.java | 108 +++++++++++++
.../quartz/springboot/QuartzRouteTest.java | 95 ++++++++++++
.../quartz/springboot/QuartzSimpleRouteTest.java | 108 +++++++++++++
.../springboot/QuartzStatefulJobRouteTest.java | 105 +++++++++++++
.../quartz/springboot/QuartzStopRouteTest.java | 112 ++++++++++++++
.../quartz/springboot/QuartzSuspendRouteTest.java | 113 ++++++++++++++
.../springboot/QuartzTriggerParametersTest.java | 103 +++++++++++++
.../RouteAutoStopFalseCronScheduledPolicyTest.java | 84 +++++++++++
.../SimpleScheduledCombinedRoutePolicyTest.java | 105 +++++++++++++
.../quartz/springboot/StatefulQuartzRouteTest.java | 109 ++++++++++++++
38 files changed, 3762 insertions(+)
diff --git a/components-starter/camel-quartz-starter/pom.xml
b/components-starter/camel-quartz-starter/pom.xml
index bf97f9ce61f..b49d37b7ae0 100644
--- a/components-starter/camel-quartz-starter/pom.xml
+++ b/components-starter/camel-quartz-starter/pom.xml
@@ -39,6 +39,18 @@
<artifactId>camel-quartz</artifactId>
<version>${camel-version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-management</artifactId>
+ <version>${camel-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-cron</artifactId>
+ <version>${camel-version}</version>
+ <scope>test</scope>
+ </dependency>
<!--START OF GENERATED CODE-->
<dependency>
<groupId>org.apache.camel.springboot</groupId>
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/BaseQuartzTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/BaseQuartzTest.java
new file mode 100644
index 00000000000..b55f64abcfe
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/BaseQuartzTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.quartz.springboot;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.api.management.JmxSystemPropertyKeys;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+import org.springframework.context.annotation.Bean;
+
+public class BaseQuartzTest {
+
+ static {
+ System.setProperty(JmxSystemPropertyKeys.DISABLED, "false");
+ }
+
+ protected boolean useJmx() {
+ return true;
+ }
+
+ @Bean
+ CamelContextConfiguration contextConfiguration() {
+ return new CamelContextConfiguration() {
+ @Override
+ public void beforeApplicationStart(CamelContext context) {
+ QuartzComponent quartz = context.getComponent("quartz",
QuartzComponent.class);
+ quartz.setEnableJmx(useJmx());
+
+ }
+
+ @Override
+ public void afterApplicationStart(CamelContext camelContext) {
+ //do nothing here
+ }
+ };
+ }
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/DelegateEndpointQuartzTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/DelegateEndpointQuartzTest.java
new file mode 100644
index 00000000000..56cb846bbdc
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/DelegateEndpointQuartzTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Consumer;
+import org.apache.camel.DelegateEndpoint;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.support.DefaultComponent;
+import org.apache.camel.support.DefaultEndpoint;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.apache.camel.util.URISupport;
+import org.quartz.JobDetail;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ DelegateEndpointQuartzTest.class,
+ DelegateEndpointQuartzTest.TestConfiguration.class
+ }
+)
+public class DelegateEndpointQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Bean("my")
+ private MyComponent getMyComponent() {
+ return new MyComponent();
+ }
+
+ class MyComponent extends DefaultComponent {
+
+ @Override
+ protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters)
+ throws Exception {
+
+ String childUri = remaining;
+ // we need to apply the params here
+ if (parameters != null && parameters.size() > 0) {
+ childUri = childUri + "?" +
URISupport.createQueryString(parameters);
+ }
+ // need to clean the parameters to avoid default component verify
parameter complain
+ parameters.clear();
+ Endpoint childEndpoint = context.getEndpoint(childUri);
+ return new MyEndpoint(uri, childEndpoint);
+ }
+
+ }
+
+ class MyEndpoint extends DefaultEndpoint implements DelegateEndpoint {
+ private final Endpoint childEndpoint;
+
+ MyEndpoint(String uri, Endpoint childEndpoint) {
+ super(uri, null);
+ this.childEndpoint = childEndpoint;
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return childEndpoint.createProducer();
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return childEndpoint.createConsumer(processor);
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+
+ @Override
+ public Endpoint getEndpoint() {
+ return childEndpoint;
+ }
+
+ @Override
+ protected String createEndpointUri() {
+ return "my:" + childEndpoint.getEndpointUri();
+ }
+
+ }
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(3);
+
+ mock.assertIsSatisfied();
+
+ JobDetail job =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertNotNull(job);
+
+ assertEquals("cron",
job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE));
+ assertEquals("0/2 * * * * ?",
job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION));
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("my:quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerRestartTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerRestartTest.java
new file mode 100644
index 00000000000..d1381bad0b9
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerRestartTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ FileConsumerQuartzSchedulerRestartTest.class,
+ FileConsumerQuartzSchedulerRestartTest.TestConfiguration.class
+ }
+)
+public class FileConsumerQuartzSchedulerRestartTest extends FromFileBase {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzSchedulerRestart() throws Exception {
+ mock.expectedMessageCount(1);
+ template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, "hello.txt");
+ context.getRouteController().startRoute("foo");
+ mock.assertIsSatisfied();
+
+ context.getRouteController().stopRoute("foo");
+ mock.reset();
+
+ mock.expectedMessageCount(1);
+ template.sendBodyAndHeader(fileUri(), "Bye World", Exchange.FILE_NAME,
"bye.txt");
+ context.getRouteController().startRoute("foo");
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(fileUri(
+
"?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?&scheduler.triggerGroup=myGroup&scheduler.triggerId=myId"))
+ .routeId("foo").noAutoStartup()
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerTest.java
new file mode 100644
index 00000000000..c6cf0f4675e
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FileConsumerQuartzSchedulerTest.java
@@ -0,0 +1,93 @@
+/*
+ * 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.quartz.springboot;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ FileConsumerQuartzSchedulerTest.class,
+ FileConsumerQuartzSchedulerTest.TestConfiguration.class
+ }
+)
+public class FileConsumerQuartzSchedulerTest extends FromFileBase {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzScheduler() throws Exception {
+ mock.expectedMessageCount(1);
+
+ template.sendBodyAndHeader(fileUri(), "Hello World",
Exchange.FILE_NAME, "hello.txt");
+
+ context.getRouteController().startRoute("foo");
+
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from(fileUri("?scheduler=quartz&scheduler.cron=0/2+*+*+*+*+?")).routeId("foo").noAutoStartup()
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileBase.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileBase.java
new file mode 100644
index 00000000000..d10217b2a11
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileBase.java
@@ -0,0 +1,73 @@
+/*
+ * 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.quartz.springboot;
+
+import static org.apache.camel.test.junit5.TestSupport.deleteDirectory;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class FromFileBase {
+
+ private boolean testDirectoryCleaned;
+
+ protected String fileUri() {
+ return "file:" + testDirectory();
+ }
+
+ protected String fileUri(String query) {
+ return "file:" + testDirectory() + (query.startsWith("?") ? "" : "/")
+ query;
+ }
+
+ protected Path testDirectory() {
+ return testDirectory(false);
+ }
+
+ protected Path testDirectory(boolean create) {
+ Class<?> testClass = getClass();
+ return testDirectory(testClass, create);
+ }
+
+
+
+ protected static Path testDirectory(Class<?> testClass, boolean create) {
+ Path dir = Paths.get("target", "data", testClass.getSimpleName());
+ if (create) {
+ try {
+ Files.createDirectories(dir);
+ } catch (IOException e) {
+ throw new IllegalStateException("Unable to create test
directory: " + dir, e);
+ }
+ }
+ return dir;
+ }
+
+ protected Path testFile(String dir) {
+ return testDirectory().resolve(dir);
+ }
+
+ public void deleteTestDirectory() {
+ if (!testDirectoryCleaned) {
+ deleteDirectory(testDirectory());
+ testDirectoryCleaned = true;
+ }
+ }
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileQuartzSchedulerTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileQuartzSchedulerTest.java
new file mode 100644
index 00000000000..c02f1dbb14c
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/FromFileQuartzSchedulerTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.io.File;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.apache.camel.util.FileUtil;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ FromFileQuartzSchedulerTest.class,
+ FromFileQuartzSchedulerTest.TestConfiguration.class
+ }
+)
+public class FromFileQuartzSchedulerTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @BeforeEach
+ public void setUp() throws Exception {
+ FileUtil.removeDir(new File("target/inbox"));
+
+ }
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+
+ resultEndpoint.expectedMessageCount(2);
+
+ template.sendBody("file:target/inbox", "Hello World");
+ template.sendBody("file:target/inbox", "Bye World");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("file:target/inbox?scheduler=quartz&scheduler.trigger.misfireInstruction=2&scheduler.cron=0/2+*+*+*+*+?")
+ .routeId("myRoute")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/MultiplePoliciesOnRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/MultiplePoliciesOnRouteTest.java
new file mode 100644
index 00000000000..d10adec0b97
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/MultiplePoliciesOnRouteTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.Date;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy;
+import org.apache.camel.spi.RoutePolicy;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.apache.camel.throttling.ThrottlingInflightRoutePolicy;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ MultiplePoliciesOnRouteTest.class
+ }
+)
+public class MultiplePoliciesOnRouteTest extends FromFileBase {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ private String url = "seda:foo?concurrentConsumers=20";
+ private int size = 100;
+
+ @Bean("startPolicy")
+ 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;
+ }
+
+ @Bean("throttlePolicy")
+ 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("quartz", QuartzComponent.class)
+
.setPropertiesFile("org/apache/camel/routepolicy/quartz/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();
+
+ assertSame(ServiceStatus.Started,
context.getRouteController().getRouteStatus("test"));
+ for (int i = 0; i < size; i++) {
+ template.sendBody(url, "Message " + i);
+ Thread.sleep(3);
+ }
+
+ context.getComponent("quartz", QuartzComponent.class).stop();
+ success.assertIsSatisfied();
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartUnderscoreTimerNameTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartUnderscoreTimerNameTest.java
new file mode 100644
index 00000000000..541435e4cde
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartUnderscoreTimerNameTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartUnderscoreTimerNameTest.class,
+ QuartUnderscoreTimerNameTest.TestConfiguration.class
+ }
+)
+public class QuartUnderscoreTimerNameTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRouteUnderscore() throws Exception {
+
+ mock.expectedMinimumMessageCount(1);
+
+ mock.assertIsSatisfied();
+ }
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://my_group?cron=0/1+*+*+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddDynamicRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddDynamicRouteTest.java
new file mode 100644
index 00000000000..c51a0f58aa0
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddDynamicRouteTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzAddDynamicRouteTest.class,
+ QuartzAddDynamicRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzAddDynamicRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testAddDynamicRoute() throws Exception {
+ resultEndpoint.expectedMessageCount(1);
+
+ template.sendBody("direct:foo", "Hello World");
+
+ resultEndpoint.assertIsSatisfied();
+
+ // reset and add a new dynamic route
+ resultEndpoint.reset();
+ resultEndpoint.expectedMessageCount(2);
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").routeId("myRoute")
+ .to("direct:foo");
+ }
+ });
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:foo").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddRoutesAfterCamelContextStartedTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddRoutesAfterCamelContextStartedTest.java
new file mode 100644
index 00000000000..53804dffebf
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAddRoutesAfterCamelContextStartedTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzAddRoutesAfterCamelContextStartedTest.class
+ }
+)
+public class QuartzAddRoutesAfterCamelContextStartedTest extends
BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testAddRoutes() throws Exception {
+ // camel context should already be started
+ assertTrue(context.getStatus().isStarted());
+
+
+ mock.expectedMessageCount(2);
+
+ // add the quartz router after CamelContext has been started
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=100&trigger.repeatCount=1").to("mock:result");
+ }
+ });
+
+ // it should also work
+ mock.assertIsSatisfied();
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAutoStartTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAutoStartTest.java
new file mode 100644
index 00000000000..f051df0d06e
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzAutoStartTest.java
@@ -0,0 +1,104 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzAutoStartTest.class,
+ QuartzAutoStartTest.TestConfiguration.class
+ }
+)
+public class QuartzAutoStartTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:one")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzAutoStart() throws Exception {
+
+ mock.expectedMessageCount(0);
+
+ QuartzComponent quartz = context.getComponent("quartz",
QuartzComponent.class);
+ assertFalse(quartz.getScheduler().isStarted(), "Should not have
started scheduler");
+
+ Thread.sleep(2000);
+
+ mock.assertIsSatisfied();
+
+ mock.reset();
+ mock.expectedMinimumMessageCount(1);
+
+ // start scheduler
+
+ quartz.getScheduler().start();
+
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?&autoStartScheduler=false").to("mock:one");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronMappingTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronMappingTest.java
new file mode 100644
index 00000000000..cb905419dc6
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronMappingTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.DelegateEndpoint;
+import org.apache.camel.Endpoint;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.Route;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronMappingTest.class
+ }
+)
+public class QuartzCronMappingTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void test5PartsCronPattern() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cron://myName?schedule=* * * * ?")
+ .id("cron")
+ .to("mock:result");
+ }
+ });
+ context.start();
+ assertEquals("0 * * * * ?",
getQuartzEndpoint(context.getRoute("cron")).getCron());
+ }
+
+ @Test
+ public void test6PartsCronPattern() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cron://myName?schedule=0/2 * * * * ?")
+ .id("cron")
+ .to("mock:result");
+ }
+ });
+ context.start();
+ assertEquals("0/2 * * * * ?",
getQuartzEndpoint(context.getRoute("cron")).getCron());
+ }
+
+ private QuartzEndpoint getQuartzEndpoint(Route route) {
+ Endpoint endpoint = route.getEndpoint();
+ while (endpoint instanceof DelegateEndpoint) {
+ endpoint = ((DelegateEndpoint) endpoint).getEndpoint();
+ }
+ return (QuartzEndpoint) endpoint;
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRoute2Test.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRoute2Test.java
new file mode 100644
index 00000000000..07efcd0ac36
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRoute2Test.java
@@ -0,0 +1,91 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronRoute2Test.class,
+ QuartzCronRoute2Test.TestConfiguration.class
+ }
+)
+public class QuartzCronRoute2Test extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testCronQuartzRoute() throws Exception {
+
+ resultEndpoint.expectedMinimumMessageCount(1);
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("cron://myName?schedule=0/1 * * * * ?")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteDurableJobTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteDurableJobTest.java
new file mode 100644
index 00000000000..609461ae296
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteDurableJobTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+
+
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronRouteDurableJobTest.class,
+ QuartzCronRouteDurableJobTest.TestConfiguration.class
+ }
+)
+public class QuartzCronRouteDurableJobTest extends QuartzCronRouteTest {
+
+
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // triggers every 1th second at precise 00,01,02,03..59
+ // notice we must use + as space when configured using URI
parameter
+
from("quartz://myGroup/myTimerName?durableJob=true&recoverableJob=true&cron=0/1+*+*+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteFireNowTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteFireNowTest.java
new file mode 100644
index 00000000000..6dbb8c999cf
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteFireNowTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronRouteFireNowTest.class,
+ QuartzCronRouteFireNowTest.TestConfiguration.class
+ }
+)
+public class QuartzCronRouteFireNowTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+
+ resultEndpoint.expectedMinimumMessageCount(1);
+ resultEndpoint.message(0).header("triggerName").isEqualTo("daily");
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // daily trigger started a day ago
+ from("quartz://daily?triggerStartDelay=" +
TimeUnit.DAYS.toMillis(-1L) + "&cron=0+0+0+*+*+?")
+ .to("log:quartz")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteTest.java
new file mode 100644
index 00000000000..530c9b8bf23
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.CamelJob;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.hamcrest.CoreMatchers;
+import org.quartz.CronTrigger;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronRouteTest.class,
+ QuartzCronRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzCronRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(3);
+
+ mock.assertIsSatisfied();
+
+ Trigger trigger =
mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
+ assertThat(trigger instanceof CronTrigger, CoreMatchers.is(true));
+
+ JobDetail detail =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertThat(detail.getJobClass().equals(CamelJob.class),
CoreMatchers.is(true));
+
+
assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE).equals("cron"),
CoreMatchers.is(true));
+
assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION).equals("0/1
* * * * ?"),
+ CoreMatchers.is(true));
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // triggers every 1th second at precise 00,01,02,03..59
+ from("quartz://myGroup/myTimerName?cron=0/1 * * * *
?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteWithSmallCacheTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteWithSmallCacheTest.java
new file mode 100644
index 00000000000..f7c2f92c899
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronRouteWithSmallCacheTest.java
@@ -0,0 +1,121 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.spring.boot.CamelContextConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronRouteWithSmallCacheTest.class,
+ QuartzCronRouteWithSmallCacheTest.TestConfiguration.class
+ }
+)
+public class QuartzCronRouteWithSmallCacheTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ private static final CountDownLatch latch = new CountDownLatch(3);
+
+ @Bean
+ CamelContextConfiguration contextConfiguration() {
+ return new CamelContextConfiguration() {
+ @Override
+ public void beforeApplicationStart(CamelContext context) {
+
context.getGlobalOptions().put(Exchange.MAXIMUM_ENDPOINT_CACHE_SIZE, "1");
+
+
+ }
+
+ @Override
+ public void afterApplicationStart(CamelContext camelContext) {
+ //do nothing here
+ }
+ };
+ }
+
+ @Test
+ public void testQuartzCronRouteWithSmallCache() throws Exception {
+ boolean wait = latch.await(10, TimeUnit.SECONDS);
+ assertTrue(wait);
+ assertTrue(latch.getCount() <= 0, "Quartz should trigger at least 3
times");
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:foo").to("log:foo");
+
+
from("quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?").process(new Processor()
{
+ @Override
+ public void process(Exchange exchange) {
+ latch.countDown();
+ template.sendBody("direct:foo", "Quartz
triggered");
+ }
+ });
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronTriggerRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronTriggerRouteTest.java
new file mode 100644
index 00000000000..bf08f96a0eb
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCronTriggerRouteTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.quartz.JobDetail;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCronTriggerRouteTest.class,
+ QuartzCronTriggerRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzCronTriggerRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(3);
+
+ mock.assertIsSatisfied();
+
+ JobDetail job =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertNotNull(job);
+
+ assertEquals("cron",
job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE));
+ assertEquals("UTC",
job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_TIMEZONE));
+ assertEquals("0/2 * * * * ?",
job.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION));
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?&trigger.timeZone=UTC").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarFireTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarFireTest.java
new file mode 100644
index 00000000000..0fd054dd53d
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarFireTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.Date;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.quartz.Calendar;
+import org.quartz.Scheduler;
+import org.quartz.impl.calendar.HolidayCalendar;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCustomCalendarFireTest.class,
+ QuartzCustomCalendarFireTest.TestConfiguration.class
+ }
+)
+public class QuartzCustomCalendarFireTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCustomCronRouteNoFire() throws Exception {
+
+ mock.expectedMinimumMessageCount(0);
+
+ QuartzComponent component = context.getComponent("quartz",
QuartzComponent.class);
+ Scheduler scheduler = component.getScheduler();
+
+ Calendar c =
scheduler.getCalendar(QuartzConstants.QUARTZ_CAMEL_CUSTOM_CALENDAR);
+ Date now = new Date();
+ java.util.Calendar tomorrow = java.util.Calendar.getInstance();
+ tomorrow.setTime(now);
+ tomorrow.add(java.util.Calendar.DAY_OF_MONTH, 1);
+ assertEquals(false, c.isTimeIncluded(tomorrow.getTimeInMillis()));
+ assertEquals(true, c.isTimeIncluded(now.getTime()));
+ mock.assertIsSatisfied();
+ }
+
+ @Bean("calendar")
+ public HolidayCalendar loadCalendar() {
+
+ HolidayCalendar cal = new HolidayCalendar();
+ java.util.Calendar tomorrow = java.util.Calendar.getInstance();
+ tomorrow.setTime(new Date());
+ tomorrow.add(java.util.Calendar.DAY_OF_MONTH, 1);
+ cal.addExcludedDate(tomorrow.getTime());
+
+ return cal;
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://MyTimer?customCalendar=#calendar&cron=05+00+00+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarNoFireTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarNoFireTest.java
new file mode 100644
index 00000000000..3222ddc2e32
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzCustomCalendarNoFireTest.java
@@ -0,0 +1,115 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.Date;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.quartz.Calendar;
+import org.quartz.Scheduler;
+import org.quartz.impl.calendar.HolidayCalendar;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzCustomCalendarNoFireTest.class,
+ QuartzCustomCalendarNoFireTest.TestConfiguration.class
+ }
+)
+public class QuartzCustomCalendarNoFireTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCustomCronRouteNoFire() throws Exception {
+
+ mock.expectedMinimumMessageCount(0);
+
+ QuartzComponent component = context.getComponent("quartz",
QuartzComponent.class);
+ Scheduler scheduler = component.getScheduler();
+
+ Calendar c =
scheduler.getCalendar(QuartzConstants.QUARTZ_CAMEL_CUSTOM_CALENDAR);
+ Date now = new Date();
+ java.util.Calendar tomorrow = java.util.Calendar.getInstance();
+ tomorrow.setTime(now);
+ tomorrow.add(java.util.Calendar.DAY_OF_MONTH, 1);
+ assertEquals(true, c.isTimeIncluded(tomorrow.getTimeInMillis()));
+ assertEquals(false, c.isTimeIncluded(now.getTime()));
+ mock.assertIsSatisfied();
+ }
+
+ @Bean("calendar")
+ public HolidayCalendar loadCalendar() {
+
+ HolidayCalendar cal = new HolidayCalendar();
+ cal.addExcludedDate(new Date());
+
+ return cal;
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://MyTimer?customCalendar=#calendar&cron=05+00+00+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzInterruptTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzInterruptTest.java
new file mode 100644
index 00000000000..9cf60077c1f
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzInterruptTest.java
@@ -0,0 +1,99 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzInterruptTest.class,
+ QuartzInterruptTest.TestConfiguration.class
+ }
+)
+public class QuartzInterruptTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testShutdown() throws Exception {
+
+ resultEndpoint.expectedMinimumMessageCount(10);
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+
+ QuartzComponent quartz = context.getComponent("quartz",
QuartzComponent.class);
+ quartz.stop();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ QuartzComponent quartz = context.getComponent("quartz",
QuartzComponent.class);
+ quartz.setInterruptJobsOnShutdown(true);
+
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=100").routeId("myRoute")
+ .delay(constant(1000))
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzJobRouteUnderscoreTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzJobRouteUnderscoreTest.java
new file mode 100644
index 00000000000..d4f4ef18e58
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzJobRouteUnderscoreTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.quartz.JobDetail;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzJobRouteUnderscoreTest.class,
+ QuartzJobRouteUnderscoreTest.TestConfiguration.class
+ }
+)
+public class QuartzJobRouteUnderscoreTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+ mock.expectedMessageCount(2);
+ mock.message(0).header("triggerGroup").isEqualTo("my_group");
+ mock.message(0).header("triggerName").isEqualTo("my_timer");
+
+ mock.assertIsSatisfied();
+
+ JobDetail detail =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertNotNull(detail);
+ assertEquals("my_job", detail.getKey().getName());
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://my_group/my_timer?trigger.repeatInterval=2&trigger.repeatCount=1&job.name=my_job")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManagementTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManagementTest.java
new file mode 100644
index 00000000000..4164ccf1907
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManagementTest.java
@@ -0,0 +1,110 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import static org.apache.camel.test.junit5.TestSupport.isPlatform;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzManagementTest.class,
+ QuartzManagementTest.TestConfiguration.class
+ }
+)
+public class QuartzManagementTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+ // JMX tests dont work well on AIX CI servers (hangs them)
+ assumeFalse(isPlatform("aix"));
+
+ mock.expectedMessageCount(2);
+
+ mock.assertIsSatisfied();
+
+ MBeanServer mbeanServer =
context.getManagementStrategy().getManagementAgent().getMBeanServer();
+
+ String name =
String.format("quartz:type=QuartzScheduler,name=DefaultQuartzScheduler-%s,instance=NON_CLUSTERED",
+ context.getManagementName());
+
+ ObjectName on = ObjectName.getInstance(name);
+ assertTrue(mbeanServer.isRegistered(on));
+
+ Boolean started = (Boolean) mbeanServer.getAttribute(on, "Started");
+ assertEquals(true, started);
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").routeId("myRoute")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManuallyTriggerJobTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManuallyTriggerJobTest.java
new file mode 100644
index 00000000000..b89c667bda3
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzManuallyTriggerJobTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.ArrayList;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.quartz.JobDataMap;
+import org.quartz.JobKey;
+import org.quartz.Scheduler;
+import org.quartz.impl.matchers.GroupMatcher;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzManuallyTriggerJobTest.class,
+ QuartzManuallyTriggerJobTest.TestConfiguration.class
+ }
+)
+public class QuartzManuallyTriggerJobTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(1);
+
+ QuartzComponent component = context.getComponent("quartz",
QuartzComponent.class);
+ Scheduler scheduler = component.getScheduler();
+
+ // collect all jobKeys of this route (ideally only one).
+ ArrayList<JobKey> jobKeys = new ArrayList<>();
+ for (String group : scheduler.getJobGroupNames()) {
+ for (JobKey jobKey :
scheduler.getJobKeys(GroupMatcher.jobGroupEquals(group))) {
+ jobKeys.add(jobKey);
+ }
+ }
+
+ JobDataMap jobDataMap =
scheduler.getJobDetail(jobKeys.get(0)).getJobDataMap();
+
+ // trigger job manually
+ scheduler.triggerJob(jobKeys.get(0), jobDataMap);
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://MyTimer?cron=05+00+00+*+*+?").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRepeatIntervalTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRepeatIntervalTest.java
new file mode 100644
index 00000000000..91490f4404f
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRepeatIntervalTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzRepeatIntervalTest.class,
+ QuartzRepeatIntervalTest.TestConfiguration.class
+ }
+)
+public class QuartzRepeatIntervalTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testRepeatInterval() throws Exception {
+
+ resultEndpoint.expectedMinimumMessageCount(5);
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=50").routeId("myRoute")
+ .to("log:result")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowOnlyOnceTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowOnlyOnceTest.java
new file mode 100644
index 00000000000..500f424eabe
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowOnlyOnceTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzRouteFireNowOnlyOnceTest.class,
+ QuartzRouteFireNowOnlyOnceTest.TestConfiguration.class
+ }
+)
+public class QuartzRouteFireNowOnlyOnceTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+ resultEndpoint.expectedMessageCount(1);
+
resultEndpoint.message(0).header("triggerName").isEqualTo("myTimerName");
+ resultEndpoint.message(0).header("triggerGroup").isEqualTo("myGroup");
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: example
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=100&trigger.repeatCount=0")
+ .to("log:quartz")
+ .to("mock:result");
+ // END SNIPPET: example
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowTest.java
new file mode 100644
index 00000000000..afcc49f23cb
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteFireNowTest.java
@@ -0,0 +1,96 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzRouteFireNowTest.class,
+ QuartzRouteFireNowTest.TestConfiguration.class
+ }
+)
+public class QuartzRouteFireNowTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+
+ resultEndpoint.expectedMinimumMessageCount(2);
+
resultEndpoint.message(0).header("triggerName").isEqualTo("myTimerName");
+ resultEndpoint.message(0).header("triggerGroup").isEqualTo("myGroup");
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: example
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=100&trigger.repeatCount=2")
+ .to("log:quartz")
+ .to("mock:result");
+ // END SNIPPET: example
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteRestartTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteRestartTest.java
new file mode 100644
index 00000000000..7227162b5f5
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteRestartTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzRouteRestartTest.class,
+ QuartzRouteRestartTest.TestConfiguration.class
+ }
+)
+public class QuartzRouteRestartTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(2);
+
+ mock.assertIsSatisfied();
+
+ // restart route
+ context.getRouteController().stopRoute("trigger");
+ mock.reset();
+ mock.expectedMessageCount(0);
+
+ // wait a bit
+ Thread.sleep(2000);
+
+ mock.assertIsSatisfied();
+
+ // start route, and we got messages again
+ mock.reset();
+ mock.expectedMinimumMessageCount(1);
+
+ context.getRouteController().startRoute("trigger");
+
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://groupName/timerName?cron=0/1+*+*+*+*+?").routeId("trigger")
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteTest.java
new file mode 100644
index 00000000000..7d9ec8b5de0
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzRouteTest.java
@@ -0,0 +1,95 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzRouteTest.class,
+ QuartzRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testQuartzRoute() throws Exception {
+
+ resultEndpoint.expectedMessageCount(2);
+
resultEndpoint.message(0).header("triggerName").isEqualTo("myTimerName");
+ resultEndpoint.message(0).header("triggerGroup").isEqualTo("myGroup");
+
+ // lets test the receive worked
+ resultEndpoint.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: example
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1").routeId("myRoute")
+ .to("mock:result");
+ // END SNIPPET: example
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSimpleRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSimpleRouteTest.java
new file mode 100644
index 00000000000..7cb9361e8e5
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSimpleRouteTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.CamelJob;
+import org.apache.camel.component.quartz.QuartzConstants;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.hamcrest.CoreMatchers;
+import org.quartz.JobDetail;
+import org.quartz.SimpleTrigger;
+import org.quartz.Trigger;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzSimpleRouteTest.class,
+ QuartzSimpleRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzSimpleRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(3);
+
+ mock.assertIsSatisfied();
+ Trigger trigger =
mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
+ assertThat(trigger instanceof SimpleTrigger, CoreMatchers.is(true));
+
+ JobDetail detail =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertThat(detail.getJobClass().equals(CamelJob.class),
CoreMatchers.is(true));
+
+
assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE).equals("simple"),
CoreMatchers.is(true));
+
assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_COUNTER).equals("-1"),
+ CoreMatchers.is(true));
+
assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_INTERVAL).equals("100"),
+ CoreMatchers.is(true));
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=100&trigger.repeatCount=-1").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStatefulJobRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStatefulJobRouteTest.java
new file mode 100644
index 00000000000..a80c1cf35a1
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStatefulJobRouteTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import static org.hamcrest.MatcherAssert.assertThat;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.StatefulCamelJob;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.hamcrest.CoreMatchers;
+import org.quartz.CronTrigger;
+import org.quartz.JobDetail;
+import org.quartz.Trigger;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzStatefulJobRouteTest.class,
+ QuartzStatefulJobRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzStatefulJobRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzCronRoute() throws Exception {
+
+ mock.expectedMinimumMessageCount(3);
+
+ mock.assertIsSatisfied();
+
+ Trigger trigger =
mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
+ assertThat(trigger instanceof CronTrigger, CoreMatchers.is(true));
+
+ JobDetail detail =
mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail",
JobDetail.class);
+ assertThat(detail.getJobClass().equals(StatefulCamelJob.class),
CoreMatchers.is(true));
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // triggers every 2th second at precise 00,02,04,06..58
+ // notice we must use + as space when configured using URI
parameter
+
from("quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?&stateful=true").to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStopRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStopRouteTest.java
new file mode 100644
index 00000000000..133d32e452b
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzStopRouteTest.java
@@ -0,0 +1,112 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzStopRouteTest.class,
+ QuartzStopRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzStopRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzSuspend() throws Exception {
+
+ mock.expectedMinimumMessageCount(1);
+
+ mock.assertIsSatisfied();
+
+ context.getRouteController().stopRoute("foo");
+
+ int size = mock.getReceivedCounter();
+ assertEquals(1, size, "Should not schedule when stopped");
+
+ mock.reset();
+
+ mock.expectedMessageCount(0);
+ mock.assertIsSatisfied(3000);
+
+ mock.reset();
+ mock.expectedMinimumMessageCount(1);
+
+ context.getRouteController().startRoute("foo");
+
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: e1
+ // triggers every second at precise 00,01,02,03..59
+ // notice we must use + as space when configured using URI
parameter
+ from("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?")
+ .routeId("foo")
+ .to("log:result", "mock:result");
+ // END SNIPPET: e1
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSuspendRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSuspendRouteTest.java
new file mode 100644
index 00000000000..8a592c5b445
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzSuspendRouteTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzSuspendRouteTest.class,
+ QuartzSuspendRouteTest.TestConfiguration.class
+ }
+)
+public class QuartzSuspendRouteTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint mock;
+
+ @Test
+ public void testQuartzSuspend() throws Exception {
+
+ mock.expectedMinimumMessageCount(1);
+
+ mock.assertIsSatisfied();
+
+ context.getRouteController().suspendRoute("foo");
+
+ int size = mock.getReceivedCounter();
+
+ mock.reset();
+
+ mock.expectedMessageCount(0);
+ mock.assertIsSatisfied(3000);
+
+ assertEquals(size, size, "Should not schedule when suspended");
+
+ mock.reset();
+ mock.expectedMinimumMessageCount(1);
+
+ context.getRouteController().resumeRoute("foo");
+
+ mock.assertIsSatisfied();
+ }
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: e1
+ // triggers every second at precise 00,01,02,03..59
+ // notice we must use + as space when configured using URI
parameter
+ from("quartz://myGroup/myTimerName?cron=0/1+*+*+*+*+?")
+ .routeId("foo")
+ .to("log:result", "mock:result");
+ // END SNIPPET: e1
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzTriggerParametersTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzTriggerParametersTest.java
new file mode 100644
index 00000000000..f83bdf10834
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/QuartzTriggerParametersTest.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.quartz.springboot;
+
+
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ QuartzTriggerParametersTest.class,
+ QuartzTriggerParametersTest.TestConfiguration.class
+ }
+)
+public class QuartzTriggerParametersTest extends BaseQuartzTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testTriggerParameters() throws Exception {
+ resultEndpoint.expectedBodiesReceived("Europe/Berlin");
+
+ resultEndpoint.assertIsSatisfied();
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ String cron =
String.format("quartz://job?cron=0+%s+%s+?+*+*&trigger.timeZone=%s&trigger.misfireInstruction=2",
+ 59, 23, "Europe/Berlin");
+
+ from(cron).to("mock:cron");
+
+ from("timer://foo?repeatCount=1")
+ .process(exchange -> {
+ QuartzEndpoint endPoint =
getContext().getEndpoint(cron, QuartzEndpoint.class);
+ Map<String, Object> triggers =
endPoint.getTriggerParameters();
+
exchange.getIn().setBody(triggers.get("timeZone"));
+ })
+ .to("mock:result");
+ }
+ };
+ }
+ }
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/RouteAutoStopFalseCronScheduledPolicyTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/RouteAutoStopFalseCronScheduledPolicyTest.java
new file mode 100644
index 00000000000..c5572109cd5
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/RouteAutoStopFalseCronScheduledPolicyTest.java
@@ -0,0 +1,84 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.routepolicy.quartz.CronScheduledRoutePolicy;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ RouteAutoStopFalseCronScheduledPolicyTest.class
+ }
+)
+public class RouteAutoStopFalseCronScheduledPolicyTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:foo")
+ MockEndpoint mock;
+
+
+ @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");
+
+ mock.expectedMessageCount(1);
+
+ final CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
+ policy.setRouteStartTime("*/5 * * * * ?");
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("seda:foo").routeId("foo").noAutoStartup()
+ .routePolicy(policy)
+ .to("mock:foo");
+ }
+ });
+
+ mock.assertIsSatisfied();
+ }
+
+
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/SimpleScheduledCombinedRoutePolicyTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/SimpleScheduledCombinedRoutePolicyTest.java
new file mode 100644
index 00000000000..b6826dc5b16
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/SimpleScheduledCombinedRoutePolicyTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.Date;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.ServiceStatus;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.direct.DirectComponent;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.quartz.QuartzComponent;
+import org.apache.camel.routepolicy.quartz.SimpleScheduledRoutePolicy;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ SimpleScheduledCombinedRoutePolicyTest.class
+ }
+)
+public class SimpleScheduledCombinedRoutePolicyTest {
+
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:success")
+ MockEndpoint success;
+
+
+
+ @Test
+ public void testScheduledStartAndStopRoutePolicy() throws Exception {
+ success.expectedMessageCount(1);
+
+ context.getComponent("direct", DirectComponent.class).setBlock(false);
+ context.getComponent("quartz", QuartzComponent.class)
+
.setPropertiesFile("org/apache/camel/routepolicy/quartz/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);
+ assertSame(ServiceStatus.Started,
context.getRouteController().getRouteStatus("test"));
+ template.sendBody("direct:start", "Ready or not, Here, I come");
+ Thread.sleep(5000);
+ assertSame(ServiceStatus.Stopped,
context.getRouteController().getRouteStatus("test"));
+
+ context.getComponent("quartz", QuartzComponent.class).stop();
+ success.assertIsSatisfied();
+ }
+
+
+}
diff --git
a/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/StatefulQuartzRouteTest.java
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/StatefulQuartzRouteTest.java
new file mode 100644
index 00000000000..f14ee58731c
--- /dev/null
+++
b/components-starter/camel-quartz-starter/src/test/java/org/apache/camel/component/quartz/springboot/StatefulQuartzRouteTest.java
@@ -0,0 +1,109 @@
+/*
+ * 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.quartz.springboot;
+
+
+
+import java.util.List;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+
+import org.junit.jupiter.api.Test;
+
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.test.annotation.DirtiesContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+@DirtiesContext
+@CamelSpringBootTest
+@SpringBootTest(
+ classes = {
+ CamelAutoConfiguration.class,
+ StatefulQuartzRouteTest.class,
+ StatefulQuartzRouteTest.TestConfiguration.class
+ }
+)
+public class StatefulQuartzRouteTest extends BaseQuartzTest {
+
+ protected final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Autowired
+ ProducerTemplate template;
+
+ @Autowired
+ CamelContext context;
+
+ @EndpointInject("mock:result")
+ MockEndpoint resultEndpoint;
+
+ @Test
+ public void testQuartz() throws Exception {
+
+ 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());
+ }
+ }
+
+
+ // *************************************
+ // Config
+ // *************************************
+
+ @Configuration
+ public class TestConfiguration {
+
+ @Bean
+ public RouteBuilder routeBuilder() {
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ // START SNIPPET: example
+
from("quartz://myGroup/myTimerName?trigger.repeatInterval=2&trigger.repeatCount=1&stateful=true")
+ .to("mock:result");
+ // END SNIPPET: example
+ }
+ };
+ }
+ }
+
+
+
+}