[jboss-cvs] JBossAS SVN: r99182 - in branches/JBPAPP_5_0_JBPAPP-3235: 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
Sat Jan 9 12:41:26 EST 2010


Author: jiwils
Date: 2010-01-09 12:41:25 -0500 (Sat, 09 Jan 2010)
New Revision: 99182

Modified:
   branches/JBPAPP_5_0_JBPAPP-3235/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
   branches/JBPAPP_5_0_JBPAPP-3235/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java
Log:
Fix for JBPAPP-3235.  Deployment scanner's start method is a noop if ScanEnabled is false.

Modified: branches/JBPAPP_5_0_JBPAPP-3235/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java
===================================================================
--- branches/JBPAPP_5_0_JBPAPP-3235/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2010-01-09 17:36:41 UTC (rev 99181)
+++ branches/JBPAPP_5_0_JBPAPP-3235/system/src/main/org/jboss/system/server/profileservice/hotdeploy/HDScanner.java	2010-01-09 17:41:25 UTC (rev 99182)
@@ -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: branches/JBPAPP_5_0_JBPAPP-3235/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java
===================================================================
--- branches/JBPAPP_5_0_JBPAPP-3235/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java	2010-01-09 17:36:41 UTC (rev 99181)
+++ branches/JBPAPP_5_0_JBPAPP-3235/testsuite/src/main/org/jboss/test/profileservice/test/HDScannerTestCase.java	2010-01-09 17:41:25 UTC (rev 99182)
@@ -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