[jboss-cvs] JBossAS SVN: r99184 - in trunk: testsuite/src/main/org/jboss/test/profileservice/test and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jan 10 00:56:32 EST 2010


Author: jiwils
Date: 2010-01-10 00:56:31 -0500 (Sun, 10 Jan 2010)
New Revision: 99184

Modified:
   trunk/system/src/main/java/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java
Log:
Fix for JBAS-7604. Deployment scanner's start method is now a noop if scanEnabled is false; added additional test.

Modified: trunk/system/src/main/java/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- trunk/system/src/main/java/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2010-01-09 20:13:21 UTC (rev 99183)
+++ trunk/system/src/main/java/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2010-01-10 05:56:31 UTC (rev 99184)
@@ -41,6 +41,12 @@
 import org.jboss.profileservice.spi.ProfileService;
 import org.jboss.system.server.profileservice.repository.MainDeployerAdapter;
 
+// ************************************************************************
+// NOTE: Direct tests for this class are located in
+// org.jboss.test.profileservice.test.HDScannerTestCase in the same package
+// as other indirect tests of the scanner.
+// ************************************************************************
+
 /**
  * A DeploymentScanner built on the ProfileService and MainDeployer. This
  * is really just a simple ExecutorService Runnable that knows nothing
@@ -99,6 +105,12 @@
     */
    private boolean suspended;
 
+   /**
+    * Whether or not scanning has been enabled via the scanEnabled attribute
+    * (default is <code>true</code>).
+    */
+   private boolean scanEnabled = true;
+
    public void setDeployer(MainDeployerAdapter deployer)
    {
       this.deployer = deployer;
@@ -158,15 +170,36 @@
    }
 
    /**
-    * Are deployment scans enabled.
+    * Is there a deployment scanner currently scheduled?  A scheduled scan is
+    * not necessarily active.
     *
-    * @return whether scan is enabled
+    * This method, while similar to {@link isScanEnabled}, may return a
+    * different value.  Since the {@link start} and {@link stop} methods
+    * may be called independently of {@link setScanEnabled}.
+    *
+    * @return <code>true</code> if there is a deployment scanner currently
+    * scheduled; <code>false</code> otherwise.
     */
-   public boolean isScanEnabled()
+   public boolean isScanScheduled()
    {
       return activeScan != null;
    }
 
+   /**
+    * Are deployment scans enabled?
+    *
+    * This method, while similar to {@link isScanScheduled}, may return a
+    * different value.  Since the {@link start} and {@link stop} methods
+    * may be called independently of {@link setScanEnabled}.
+    *
+    * @return <code>true</code> if scans are enabled; <code>false</code>
+    * otherwise.
+    */
+   public boolean isScanEnabled()
+   {
+      return scanEnabled;
+   }
+
    public synchronized int getScanCount()
    {
       return scanCount;
@@ -192,6 +225,8 @@
       {
          stop();
       }
+
+      this.scanEnabled = scanEnabled;
    }
 
    public boolean isCreatedScanExecutor()
@@ -219,7 +254,10 @@
 
    public void start()
    {
-      activeScan = scanExecutor.scheduleWithFixedDelay(this, 0, scanPeriod, TimeUnit.MILLISECONDS);
+      if (scanEnabled)
+      {
+         activeScan = scanExecutor.scheduleWithFixedDelay(this, 0, scanPeriod, TimeUnit.MILLISECONDS);
+      }
    }
 
    public synchronized void stop()

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java	2010-01-09 20:13:21 UTC (rev 99183)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java	2010-01-10 05:56:31 UTC (rev 99184)
@@ -41,9 +41,10 @@
     * Test for JBAS-7528.
     *
     * Setting the scanEnabled attribute to true via XML led to
-    * NullPointerExceptions in previous releases.
+    * NullPointerExceptions in previous releases, so no thrown exception equals
+    * a pass.
     */
-   public void testSettingScanEnabled()
+   public void testSettingScanEnabledToTrueDoesNotCauseNPE()
    {
       HDScanner hdScanner = new HDScanner();
 
@@ -51,4 +52,24 @@
       // when set via XML.
       hdScanner.setScanEnabled(true);
    }
+
+   /**
+    * Test for JBAS-7604.
+    *
+    * Setting the scanEnabled attribute to false via XML did not stop the start
+    * method from executing/scheduling scanner in previous releases.
+    */
+    public void testSettingScanEnabledToFalseDoesNotCauseActiveScan()
+    throws Exception
+    {
+      HDScanner hdScanner = new HDScanner();
+      hdScanner.setScanEnabled(false);
+      hdScanner.create();
+      hdScanner.start();
+
+      // Does starting the HDScanner cause a scan to be scheduled?  It shouldn't when
+      // ScanEnabled is false.
+      assertFalse("HDScanner had a scheduled scan when ScanEnabled was false",
+                  hdScanner.isScanScheduled());
+    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list