[jira] [Updated] (CAMEL-7276) camel-quartz - use of management name to provide default scheduler name breaks context isolation

2014-03-08 Thread Claus Ibsen (JIRA)

 [ 
https://issues.apache.org/jira/browse/CAMEL-7276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-7276:
---

Fix Version/s: 2.13.0
   2.12.4

 camel-quartz - use of management name to provide default scheduler name 
 breaks context isolation
 

 Key: CAMEL-7276
 URL: https://issues.apache.org/jira/browse/CAMEL-7276
 Project: Camel
  Issue Type: Bug
  Components: camel-quartz
Affects Versions: 2.12.3
Reporter: Bob Browning
Assignee: Claus Ibsen
Priority: Minor
 Fix For: 2.12.4, 2.13.0


 When using the camel-quartz component in an unmanged context with multiple 
 camel contexts, for example in a JUnit test case, causes the scheduler to be 
 created with the instance name DefaultQuartzScheduler which is then shared 
 across all camel context's within the same jvm.
 This is in contradiction of the previous behaviour that uses 
 `getCamelContext.getName()` which isolates the scheduler by denoting that the 
 default instance is specific to the camel context.
 {code}
 package org.apache.camel.component.quartz;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.management.JmxSystemPropertyKeys;
 import org.junit.Test;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
 /**
  * Test regression of camel-context isolation of default scheduler instance 
 introduced in CAMEL-7034.
  */
 public class QuartzComponentCamelContextSchedulerIsolationTest {
   @Test
   public void testSchedulerIsolation_unmanaged() throws Exception {
 disableJMX();
 testSchedulerIsolation();
   }
   @Test
   public void testSchedulerIsolation_managed() throws Exception {
 enableJMX();
 testSchedulerIsolation();
   }
   private void testSchedulerIsolation() throws Exception {
 CamelContext context = createCamelContext();
 context.start();
 CamelContext anotherContext = createCamelContext();
 assertNotEquals(anotherContext.getName(), context.getName());
 assertNotEquals(anotherContext, context);
 assertNotSame(getDefaultScheduler(context), 
 getDefaultScheduler(anotherContext));
   }
   /**
* Create a new camel context instance.
*/
   private DefaultCamelContext createCamelContext() {
 return new DefaultCamelContext();
   }
   /**
* Get the quartz component for the provided camel context.
*/
   private QuartzComponent getQuartzComponent(CamelContext context) {
 return context.getComponent(quartz, QuartzComponent.class);
   }
   /**
* Get the default scheduler for the provided camel context.
*/
   private Scheduler getDefaultScheduler(CamelContext context) throws 
 SchedulerException {
 return getQuartzComponent(context).getFactory().getScheduler();
   }
   /**
* Disables the JMX agent.
*/
   private void disableJMX() {
 System.setProperty(JmxSystemPropertyKeys.DISABLED, true);
   }
   /**
* Enables the JMX agent.
*/
   private void enableJMX() {
 System.setProperty(JmxSystemPropertyKeys.DISABLED, false);
   }
 }
 {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Updated] (CAMEL-7276) camel-quartz - use of management name to provide default scheduler name breaks context isolation

2014-03-08 Thread Claus Ibsen (JIRA)

 [ 
https://issues.apache.org/jira/browse/CAMEL-7276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-7276:
---

Priority: Minor  (was: Major)

 camel-quartz - use of management name to provide default scheduler name 
 breaks context isolation
 

 Key: CAMEL-7276
 URL: https://issues.apache.org/jira/browse/CAMEL-7276
 Project: Camel
  Issue Type: Bug
  Components: camel-quartz
Affects Versions: 2.12.3
Reporter: Bob Browning
Assignee: Claus Ibsen
Priority: Minor
 Fix For: 2.12.4, 2.13.0


 When using the camel-quartz component in an unmanged context with multiple 
 camel contexts, for example in a JUnit test case, causes the scheduler to be 
 created with the instance name DefaultQuartzScheduler which is then shared 
 across all camel context's within the same jvm.
 This is in contradiction of the previous behaviour that uses 
 `getCamelContext.getName()` which isolates the scheduler by denoting that the 
 default instance is specific to the camel context.
 {code}
 package org.apache.camel.component.quartz;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.management.JmxSystemPropertyKeys;
 import org.junit.Test;
 import org.quartz.Scheduler;
 import org.quartz.SchedulerException;
 import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotSame;
 /**
  * Test regression of camel-context isolation of default scheduler instance 
 introduced in CAMEL-7034.
  */
 public class QuartzComponentCamelContextSchedulerIsolationTest {
   @Test
   public void testSchedulerIsolation_unmanaged() throws Exception {
 disableJMX();
 testSchedulerIsolation();
   }
   @Test
   public void testSchedulerIsolation_managed() throws Exception {
 enableJMX();
 testSchedulerIsolation();
   }
   private void testSchedulerIsolation() throws Exception {
 CamelContext context = createCamelContext();
 context.start();
 CamelContext anotherContext = createCamelContext();
 assertNotEquals(anotherContext.getName(), context.getName());
 assertNotEquals(anotherContext, context);
 assertNotSame(getDefaultScheduler(context), 
 getDefaultScheduler(anotherContext));
   }
   /**
* Create a new camel context instance.
*/
   private DefaultCamelContext createCamelContext() {
 return new DefaultCamelContext();
   }
   /**
* Get the quartz component for the provided camel context.
*/
   private QuartzComponent getQuartzComponent(CamelContext context) {
 return context.getComponent(quartz, QuartzComponent.class);
   }
   /**
* Get the default scheduler for the provided camel context.
*/
   private Scheduler getDefaultScheduler(CamelContext context) throws 
 SchedulerException {
 return getQuartzComponent(context).getFactory().getScheduler();
   }
   /**
* Disables the JMX agent.
*/
   private void disableJMX() {
 System.setProperty(JmxSystemPropertyKeys.DISABLED, true);
   }
   /**
* Enables the JMX agent.
*/
   private void enableJMX() {
 System.setProperty(JmxSystemPropertyKeys.DISABLED, false);
   }
 }
 {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)


[jira] [Updated] (CAMEL-7276) camel-quartz - use of management name to provide default scheduler name breaks context isolation

2014-03-06 Thread Bob Browning (JIRA)

 [ 
https://issues.apache.org/jira/browse/CAMEL-7276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bob Browning updated CAMEL-7276:


Description: 
When using the camel-quartz component in an unmanged context with multiple 
camel contexts, for example in a JUnit test case, causes the scheduler to be 
created with the instance name DefaultQuartzScheduler which is then shared 
across all camel context's within the same jvm.

This is in contradiction of the previous behaviour that uses 
`getCamelContext.getName()` which isolates the scheduler by denoting that the 
default instance is specific to the camel context.

{code}
package org.apache.camel.component.quartz;

import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.management.JmxSystemPropertyKeys;
import org.junit.Test;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;

import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;

/**
 * Test regression of camel-context isolation of default scheduler instance 
introduced in CAMEL-7034.
 */
public class QuartzComponentCamelContextSchedulerIsolationTest {

  @Test
  public void testSchedulerIsolation_unmanaged() throws Exception {
disableJMX();
testSchedulerIsolation();
  }

  @Test
  public void testSchedulerIsolation_managed() throws Exception {
enableJMX();
testSchedulerIsolation();
  }

  private void testSchedulerIsolation() throws Exception {
CamelContext context = createCamelContext();
context.start();

CamelContext anotherContext = createCamelContext();
assertNotEquals(anotherContext.getName(), context.getName());
assertNotEquals(anotherContext, context);

assertNotSame(getDefaultScheduler(context), 
getDefaultScheduler(anotherContext));
  }

  /**
   * Create a new camel context instance.
   */
  private DefaultCamelContext createCamelContext() {
return new DefaultCamelContext();
  }

  /**
   * Get the quartz component for the provided camel context.
   */
  private QuartzComponent getQuartzComponent(CamelContext context) {
return context.getComponent(quartz, QuartzComponent.class);
  }

  /**
   * Get the default scheduler for the provided camel context.
   */
  private Scheduler getDefaultScheduler(CamelContext context) throws 
SchedulerException {
return getQuartzComponent(context).getFactory().getScheduler();
  }

  /**
   * Disables the JMX agent.
   */
  private void disableJMX() {
System.setProperty(JmxSystemPropertyKeys.DISABLED, true);
  }

  /**
   * Enables the JMX agent.
   */
  private void enableJMX() {
System.setProperty(JmxSystemPropertyKeys.DISABLED, false);
  }

}
{code}

  was:
When using the camel-quartz component in an unmanged context with multiple 
camel contexts, for example in a JUnit test case, causes the scheduler to be 
created with the instance name DefaultQuartzScheduler which is then shared 
across all camel context's within the same jvm.

This is in contradiction of the previous behaviour that uses 
`getCamelContext.getName()` which isolates the scheduler by denoting that the 
default instance is specific to the camel context.

{code}
package org.apache.camel.component.quartz;

import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.management.JmxSystemPropertyKeys;
import org.junit.Test;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;

import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotSame;

/**
 * Test regression of camel-context isolation of default scheduler instance 
introduced in CAMEL-7034.
 *
 * @author Bob Browning bob.brown...@pressassociation.com
 */
public class QuartzComponentCamelContextSchedulerIsolationTest {

  @Test
  public void testSchedulerIsolation_unmanaged() throws Exception {
disableJMX();
testSchedulerIsolation();
  }

  @Test
  public void testSchedulerIsolation_managed() throws Exception {
enableJMX();
testSchedulerIsolation();
  }

  private void testSchedulerIsolation() throws Exception {
CamelContext context = createCamelContext();
context.start();

CamelContext anotherContext = createCamelContext();
assertNotEquals(anotherContext.getName(), context.getName());
assertNotEquals(anotherContext, context);

assertNotSame(getDefaultScheduler(context), 
getDefaultScheduler(anotherContext));
  }

  /**
   * Create a new camel context instance.
   */
  private DefaultCamelContext createCamelContext() {
return new DefaultCamelContext();
  }

  /**
   * Get the quartz component for the provided camel context.
   */
  private QuartzComponent getQuartzComponent(CamelContext context) {
return context.getComponent(quartz, QuartzComponent.class);
  }

  /**
   * Get the default scheduler for the provided camel context.
   */
  private Scheduler