Skip to content

Commit

Permalink
[resolves #1138] Add support for spring-context-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Basovnik authored and Thomas Diesler committed Mar 14, 2016
1 parent b8cff5b commit 543797f
Show file tree
Hide file tree
Showing 14 changed files with 389 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<include path="META-INF" />
</exports>
</module>
<module name="org.springframework.context" export="true">
<module name="org.springframework.spring" export="true">
<imports>
<include path="META-INF" />
</imports>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.springframework.context-support">
<properties>
<property name="jboss.api" value="private" />
</properties>
<resources>
<artifact name="${org.springframework:spring-context-support}" />
</resources>
<dependencies>
<module name="javax.api" />
<module name="org.apache.commons.logging" />
<module name="org.springframework.tx" optional="true" />
<module name="org.springframework.jdbc" optional="true" />
<module name="org.quartz" optional="true" />
<module name="org.springframework.beans" />
<module name="org.springframework.context" />
<module name="org.springframework.core" />
</dependencies>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<include path="META-INF" />
</exports>
</module>
<module name="org.springframework.context-support" export="true" />
<module name="org.springframework.core" export="true">
<imports>
<include path="META-INF" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* #%L
* Wildfly Camel :: Testsuite
* %%
* Copyright (C) 2013 - 2014 RedHat
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/

package org.wildfly.camel.test.quartz;

import org.apache.camel.CamelContext;
import org.apache.camel.component.mock.MockEndpoint;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.extension.camel.CamelAware;
import org.wildfly.extension.camel.CamelConstants;
import org.wildfly.extension.camel.CamelContextRegistry;

@CamelAware
@RunWith(Arquillian.class)
public class QuartzPersistentStoreTest {

@ArquillianResource
CamelContextRegistry contextRegistry;

@Deployment
public static JavaArchive deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "quartz-tests");
archive.addAsManifestResource("quartz/quartz-camel-context.xml", CamelConstants.CAMEL_CONTEXT_FILE_NAME);
archive.addAsResource("quartz/sql/db-schema.sql", "db-schema.sql");
return archive;
}

@Test
public void restartRouteTest() throws Exception {
CamelContext camelctx = contextRegistry.getCamelContext("quartz-context");
Assert.assertNotNull(camelctx);

MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mockEndpoint.expectedMinimumMessageCount(2);

mockEndpoint.assertIsSatisfied();

// restart route
camelctx.stopRoute("myRoute");
mockEndpoint.reset();
mockEndpoint.expectedMessageCount(0);

// wait a bit
Thread.sleep(2000);

mockEndpoint.assertIsSatisfied();

// start route, and we got messages again
mockEndpoint.reset();
mockEndpoint.expectedMinimumMessageCount(2);

camelctx.startRoute("myRoute");

mockEndpoint.assertIsSatisfied();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
#%L
Wildfly Camel :: Testsuite
%%
Copyright (C) 2013 - 2015 RedHat
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
#L%
-->
<beans xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.1.xsd">

<jdbc:embedded-database id="quartzDataSource" type="H2">
<jdbc:script location="db-schema.sql"/>
</jdbc:embedded-database>

<bean id="myScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="dataSource" ref="quartzDataSource"/>
<property name="autoStartup" value="false"/>
<property name="schedulerContextAsMap">
<!-- hook Camel into Quartz -->
<map>
<entry key="CamelQuartzCamelContext-camelContext" value-ref="quartz-context"/>
</map>
</property>
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceName">myscheduler</prop>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
<prop key="org.terracotta.quartz.skipUpdateCheck">true</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
<prop key="org.quartz.jobStore.isClustered">false</prop>
</props>
</property>
</bean>

<bean id="quartz2" class="org.apache.camel.component.quartz2.QuartzComponent">
<property name="scheduler" ref="myScheduler"/>
</bean>

<camelContext id="quartz-context" xmlns="http://camel.apache.org/schema/spring">
<route id="myRoute">
<from uri="quartz2://app/test?trigger.repeatInterval=1000&amp;trigger.repeatCount=-1&amp;stateful=true"/>
<log message="Fired: ${header.CamelCreatedTimestamp}"/>
<to uri="mock:result"/>
</route>
</camelContext>

</beans>
130 changes: 130 additions & 0 deletions itests/standalone/basic/src/main/resources/quartz/sql/db-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
-- Tables for Quartz

create table if not exists qrtz_job_details (
sched_name varchar(120) not null,
job_name varchar(200) not null,
job_group varchar(200) not null,
description varchar(250) ,
job_class_name varchar(250) not null,
is_durable varchar(5) not null,
is_nonconcurrent varchar(5) not null,
is_update_data varchar(5) not null,
requests_recovery varchar(5) not null,
job_data blob,
primary key (sched_name,job_name,job_group)
);

create table if not exists qrtz_triggers (
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
job_name varchar(200) not null,
job_group varchar(200) not null,
description varchar(250),
next_fire_time bigint,
prev_fire_time bigint,
priority integer,
trigger_state varchar(16) not null,
trigger_type varchar(8) not null,
start_time bigint not null,
end_time bigint,
calendar_name varchar(200),
misfire_instr smallint,
job_data blob,
primary key (sched_name,trigger_name,trigger_group),
foreign key (sched_name,job_name,job_group) references qrtz_job_details(sched_name,job_name,job_group)
);

create table if not exists qrtz_simple_triggers (
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
repeat_count bigint not null,
repeat_interval bigint not null,
times_triggered bigint not null,
primary key (sched_name,trigger_name,trigger_group),
foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group)
);

create table if not exists qrtz_cron_triggers (
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
cron_expression varchar(120) not null,
time_zone_id varchar(80),
primary key (sched_name,trigger_name,trigger_group),
foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group)
);

create table if not exists qrtz_simprop_triggers (
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
str_prop_1 varchar(512),
str_prop_2 varchar(512),
str_prop_3 varchar(512),
int_prop_1 int,
int_prop_2 int,
long_prop_1 bigint,
long_prop_2 bigint,
dec_prop_1 numeric(13,4),
dec_prop_2 numeric(13,4),
bool_prop_1 varchar(5),
bool_prop_2 varchar(5),
primary key (sched_name,trigger_name,trigger_group),
foreign key (sched_name,trigger_name,trigger_group)
references qrtz_triggers(sched_name,trigger_name,trigger_group)
);

create table if not exists qrtz_blob_triggers (
sched_name varchar(120) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
blob_data blob,
primary key (sched_name,trigger_name,trigger_group),
foreign key (sched_name,trigger_name,trigger_group) references qrtz_triggers(sched_name,trigger_name,trigger_group)
);

create table if not exists qrtz_calendars (
sched_name varchar(120) not null,
calendar_name varchar(200) not null,
calendar blob not null,
primary key (sched_name,calendar_name)
);

create table if not exists qrtz_paused_trigger_grps (
sched_name varchar(120) not null,
trigger_group varchar(200) not null,
primary key (sched_name,trigger_group)
);

create table if not exists qrtz_fired_triggers (
sched_name varchar(120) not null,
entry_id varchar(95) not null,
trigger_name varchar(200) not null,
trigger_group varchar(200) not null,
instance_name varchar(200) not null,
fired_time bigint not null,
sched_time bigint not null,
priority integer not null,
state varchar(16) not null,
job_name varchar(200),
job_group varchar(200),
is_nonconcurrent varchar(5),
requests_recovery varchar(5),
primary key (sched_name,entry_id)
);

create table if not exists qrtz_scheduler_state (
sched_name varchar(120) not null,
instance_name varchar(200) not null,
last_checkin_time bigint not null,
checkin_interval bigint not null,
primary key (sched_name,instance_name)
);

create table if not exists qrtz_locks (
sched_name varchar(120) not null,
lock_name varchar(40) not null,
primary key (sched_name,lock_name)
);

0 comments on commit 543797f

Please sign in to comment.