camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r991060 - in /camel/trunk/components/camel-quartz/src: main/java/org/apache/camel/component/quartz/ test/java/org/apache/camel/component/quartz/
Date Tue, 31 Aug 2010 02:31:57 GMT
Author: hadrian
Date: Tue Aug 31 02:31:57 2010
New Revision: 991060

URL: http://svn.apache.org/viewvc?rev=991060&view=rev
Log:
CAMEL-3091. Properly set job.name

Modified:
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
    camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
    camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzEndpointConfigureTest.java

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java?rev=991060&r1=991059&r2=991060&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzComponent.java
Tue Aug 31 02:31:57 2010
@@ -89,7 +89,6 @@ public class QuartzComponent extends Def
 
     @Override
     protected QuartzEndpoint createEndpoint(final String uri, final String remaining, final
Map<String, Object> parameters) throws Exception {
-        QuartzEndpoint answer = new QuartzEndpoint(uri, this);
 
         // lets split the remaining into a group/name
         URI u = new URI(uri);
@@ -126,19 +125,20 @@ public class QuartzComponent extends Def
                 }
             }
         }
-        answer.setTrigger(trigger);
 
-        trigger.setName(name);
-        trigger.setGroup(group);
+        QuartzEndpoint answer = new QuartzEndpoint(uri, this);
+        setProperties(answer.getJobDetail(), jobParameters);
 
         setProperties(trigger, triggerParameters);
-        setProperties(answer.getJobDetail(), jobParameters);
+        trigger.setName(name);
+        trigger.setGroup(group);
+        answer.setTrigger(trigger);
 
         return answer;
     }
 
     protected CronTrigger createCronTrigger(String path) throws ParseException {
-        // replace + back to space so its a cron expression
+        // replace + back to space so it's a cron expression
         path = path.replaceAll("\\+", " ");
         CronTrigger cron = new CronTrigger();
         cron.setCronExpression(path);

Modified: camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java?rev=991060&r1=991059&r2=991060&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
(original)
+++ camel/trunk/components/camel-quartz/src/main/java/org/apache/camel/component/quartz/QuartzEndpoint.java
Tue Aug 31 02:31:57 2010
@@ -53,6 +53,7 @@ public class QuartzEndpoint extends Defa
 
     public QuartzEndpoint(final String endpointUri, final QuartzComponent component) {
         super(endpointUri, component);
+        getJobDetail().setName("quartz-" + getId());
     }
 
     public void addTrigger(final Trigger trigger, final JobDetail detail) throws SchedulerException
{
@@ -144,11 +145,7 @@ public class QuartzEndpoint extends Defa
     }
 
     protected String getJobName() {
-        String jobName = getEndpointUri();
-        if (jobName.contains("?")) {
-            jobName = ObjectHelper.before(jobName, "?");
-        }
-        return jobName;
+        return getJobDetail().getName();
     }
 
     // Properties

Modified: camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzEndpointConfigureTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzEndpointConfigureTest.java?rev=991060&r1=991059&r2=991060&view=diff
==============================================================================
--- camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzEndpointConfigureTest.java
(original)
+++ camel/trunk/components/camel-quartz/src/test/java/org/apache/camel/component/quartz/QuartzEndpointConfigureTest.java
Tue Aug 31 02:31:57 2010
@@ -35,6 +35,7 @@ public class QuartzEndpointConfigureTest
         Trigger trigger = endpoint.getTrigger();
         assertEquals("getName()", "myName", trigger.getName());
         assertEquals("getGroup()", "myGroup", trigger.getGroup());
+        assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
// default job name
 
         SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
         assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
@@ -46,6 +47,7 @@ public class QuartzEndpointConfigureTest
         Trigger trigger = endpoint.getTrigger();
         assertEquals("getName()", "myName", trigger.getName());
         assertEquals("getGroup()", "Camel", trigger.getGroup());
+        assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
// default job name
     }
 
     @Test
@@ -55,6 +57,7 @@ public class QuartzEndpointConfigureTest
         assertEquals("getName()", "myTimerName", trigger.getName());
         assertEquals("getGroup()", "myGroup", trigger.getGroup());
         assertEquals("cron expression", "0 0/5 12-18 ? * MON-FRI", trigger.getCronExpression());
+        assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
// default job name
     }
 
     @Test
@@ -64,6 +67,17 @@ public class QuartzEndpointConfigureTest
         assertEquals("getName()", "myTimerName", trigger.getName());
         assertEquals("getGroup()", "myGroup", trigger.getGroup());
         assertEquals("cron expression", "0 0 * * * ?", trigger.getCronExpression());
+        assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
// default job name
+    }
+
+    @Test
+    public void testConfigureJobName() throws Exception {
+        QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myGroup/myTimerName?job.name=hadrian&cron=0+0+*+*+*+?");
+        CronTrigger trigger = assertIsInstanceOf(CronTrigger.class, endpoint.getTrigger());
+        assertEquals("getName()", "myTimerName", trigger.getName());
+        assertEquals("getGroup()", "myGroup", trigger.getGroup());
+        assertEquals("cron expression", "0 0 * * * ?", trigger.getCronExpression());
+        assertEquals("getJobName", "hadrian", endpoint.getJobName());
     }
 
     @Override



Mime
View raw message