You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/03/16 09:30:32 UTC

svn commit: r1301376 - in /camel/trunk/components/camel-quartz: ./ src/test/java/org/apache/camel/component/quartz/ src/test/resources/ src/test/resources/org/apache/camel/component/quartz/

Author: davsclaus
Date: Fri Mar 16 08:30:32 2012
New Revision: 1301376

URL: http://svn.apache.org/viewvc?rev=1301376&view=rev
Log:
CAMEL-4900: Added persistent store test to camel-quartz. Thanks to Bryan for sample app.

Added:
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.java
      - copied, changed from r1301321, camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.java
    camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml
      - copied, changed from r1301321, camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.xml
    camel/trunk/components/camel-quartz/src/test/resources/tables_derby.sql
Modified:
    camel/trunk/components/camel-quartz/   (props changed)
    camel/trunk/components/camel-quartz/pom.xml

Propchange: camel/trunk/components/camel-quartz/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Mar 16 08:30:32 2012
@@ -14,3 +14,5 @@ eclipse-classes
 *.ipr
 *.iml
 *.iws
+*.idea
+derby.log

Modified: camel/trunk/components/camel-quartz/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/pom.xml?rev=1301376&r1=1301375&r2=1301376&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/pom.xml (original)
+++ camel/trunk/components/camel-quartz/pom.xml Fri Mar 16 08:30:32 2012
@@ -82,6 +82,29 @@
             <artifactId>camel-test-spring</artifactId>            
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>commons-dbcp</groupId>
+            <artifactId>commons-dbcp</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+      <!-- for persistent test -->
+      <dependency>
+        <groupId>org.apache.derby</groupId>
+        <artifactId>derby</artifactId>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-jdbc</artifactId>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.springframework</groupId>
+        <artifactId>spring-context-support</artifactId>
+        <scope>test</scope>
+      </dependency>
+
     </dependencies>
 
     <build>

Copied: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.java (from r1301321, camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.java?p2=camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.java&p1=camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.java&r1=1301321&r2=1301376&rev=1301376&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.java (original)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.java Fri Mar 16 08:30:32 2012
@@ -25,15 +25,15 @@ import org.springframework.context.suppo
 /**
  * @version 
  */
-public class SpringQuartzCronRouteTest extends CamelSpringTestSupport {
+public class SpringQuartzPersistentStoreTest extends CamelSpringTestSupport {
 
     @Override
     protected AbstractXmlApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzCronRouteTest.xml");
+        return new ClassPathXmlApplicationContext("org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml");
     }
 
     @Test
-    public void testQuartzCronRoute() throws Exception {
+    public void testQuartzPersistentStore() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMinimumMessageCount(3);
 

Copied: camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml (from r1301321, camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml?p2=camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml&p1=camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.xml&r1=1301321&r2=1301376&rev=1301376&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzCronRouteTest.xml (original)
+++ camel/trunk/components/camel-quartz/src/test/resources/org/apache/camel/component/quartz/SpringQuartzPersistentStoreTest.xml Fri Mar 16 08:30:32 2012
@@ -17,18 +17,51 @@
 -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: e1 -->
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="quartz://myGroup/myTimerName?cron=0/2+*+*+*+*+?"/>
-            <to uri="mock:result"/>
-        </route>
-    </camelContext>
-    <!-- END SNIPPET: e1 -->
+  <!-- the persistent store for quartz -->
+  <jdbc:embedded-database id="camel_quartz" type="DERBY">
+    <jdbc:script location="classpath:tables_derby.sql"/>
+  </jdbc:embedded-database>
+
+  <bean id="quartz" class="org.apache.camel.component.quartz.QuartzComponent">
+    <property name="scheduler" ref="scheduler"/>
+    <property name="autoStartScheduler" value="true"/>
+  </bean>
+
+  <!-- jdbc:initialize-database must come before this so the job store exists -->
+  <bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
+    <property name="dataSource" ref="camel_quartz"/>
+    <property name="autoStartup" value="false"/>
+    <!-- let Camel start -->
+    <property name="schedulerContextAsMap">
+      <!-- hook Camel into Quartz -->
+      <map>
+        <entry key="CamelQuartzCamelContext" value-ref="camelContext"/>
+      </map>
+    </property>
+    <property name="quartzProperties">
+      <props>
+        <prop key="org.quartz.scheduler.instanceName">myscheduler</prop>
+        <prop key="org.quartz.scheduler.instanceId">AUTO</prop>
+        <prop key="org.quartz.scheduler.skipUpdateCheck">true</prop>
+        <prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
+        <prop key="org.quartz.jobStore.isClustered">false</prop>
+      </props>
+    </property>
+  </bean>
+
+  <camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
+    <route>
+      <from uri="quartz://app/test?trigger.repeatInterval=1000&amp;trigger.repeatCount=-1&amp;stateful=true"/>
+      <to uri="log:trigger"/>
+      <to uri="mock:result"/>
+    </route>
+  </camelContext>
 
 </beans>

Added: camel/trunk/components/camel-quartz/src/test/resources/tables_derby.sql
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/resources/tables_derby.sql?rev=1301376&view=auto
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/resources/tables_derby.sql (added)
+++ camel/trunk/components/camel-quartz/src/test/resources/tables_derby.sql Fri Mar 16 08:30:32 2012
@@ -0,0 +1,152 @@
+-- ------------------------------------------------------------------------
+-- 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.
+-- ------------------------------------------------------------------------
+
+--
+-- Apache Derby scripts by Steve Stewart, updated by Ronald Pomeroy
+-- Based on Srinivas Venkatarangaiah's file for Cloudscape
+-- 
+-- In your Quartz properties file, you'll need to set
+-- org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.CloudscapeDelegate
+-- 
+-- Known to work with Apache Derby 10.0.2.1
+--
+
+create table qrtz_job_details (
+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_volatile varchar(5) not null,
+is_stateful varchar(5) not null,
+requests_recovery varchar(5) not null,
+job_data blob,
+primary key (job_name,job_group)
+);
+
+create table qrtz_job_listeners(
+job_name varchar(200) not null,
+job_group varchar(200) not null,
+job_listener varchar(200) not null,
+primary key (job_name,job_group,job_listener),
+foreign key (job_name,job_group) references qrtz_job_details(job_name,job_group)
+);
+
+create table qrtz_triggers(
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+job_name varchar(200) not null,
+job_group varchar(200) not null,
+is_volatile varchar(5) 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 (trigger_name,trigger_group),
+foreign key (job_name,job_group) references qrtz_job_details(job_name,job_group)
+);
+
+create table qrtz_simple_triggers(
+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 (trigger_name,trigger_group),
+foreign key (trigger_name,trigger_group) references qrtz_triggers(trigger_name,trigger_group)
+);
+
+create table qrtz_cron_triggers(
+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 (trigger_name,trigger_group),
+foreign key (trigger_name,trigger_group) references qrtz_triggers(trigger_name,trigger_group)
+);
+
+create table qrtz_blob_triggers(
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+blob_data blob,
+primary key (trigger_name,trigger_group),
+foreign key (trigger_name,trigger_group) references qrtz_triggers(trigger_name,trigger_group)
+);
+
+create table qrtz_trigger_listeners(
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+trigger_listener varchar(200) not null,
+primary key (trigger_name,trigger_group,trigger_listener),
+foreign key (trigger_name,trigger_group) references qrtz_triggers(trigger_name,trigger_group)
+);
+
+create table qrtz_calendars(
+calendar_name varchar(200) not null,
+calendar blob not null,
+primary key (calendar_name)
+);
+
+create table qrtz_paused_trigger_grps
+  (
+    trigger_group varchar(200) not null,
+primary key (trigger_group)
+);
+
+create table qrtz_fired_triggers(
+entry_id varchar(95) not null,
+trigger_name varchar(200) not null,
+trigger_group varchar(200) not null,
+is_volatile varchar(5) not null,
+instance_name varchar(200) not null,
+fired_time bigint not null,
+priority integer not null,
+state varchar(16) not null,
+job_name varchar(200),
+job_group varchar(200),
+is_stateful varchar(5),
+requests_recovery varchar(5),
+primary key (entry_id)
+);
+
+create table qrtz_scheduler_state
+  (
+    instance_name varchar(200) not null,
+    last_checkin_time bigint not null,
+    checkin_interval bigint not null,
+primary key (instance_name)
+);
+
+create table qrtz_locks
+  (
+    lock_name varchar(40) not null,
+primary key (lock_name)
+);
+
+insert into qrtz_locks values('TRIGGER_ACCESS');
+insert into qrtz_locks values('JOB_ACCESS');
+insert into qrtz_locks values('CALENDAR_ACCESS');
+insert into qrtz_locks values('STATE_ACCESS');
+insert into qrtz_locks values('MISFIRE_ACCESS');
+