incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1042649 - in /sling/trunk/contrib/extensions/bgservlets/src: main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java
Date Mon, 06 Dec 2010 14:07:09 GMT
Author: bdelacretaz
Date: Mon Dec  6 14:07:08 2010
New Revision: 1042649

URL: http://svn.apache.org/viewvc?rev=1042649&view=rev
Log:
SLING-1884 - fix SuspendableOutputStream QUEUED to RUNNING state transition

Modified:
    sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
    sling/trunk/contrib/extensions/bgservlets/src/test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java

Modified: sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java?rev=1042649&r1=1042648&r2=1042649&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/main/java/org/apache/sling/bgservlets/impl/SuspendableOutputStream.java
Mon Dec  6 14:07:08 2010
@@ -137,7 +137,9 @@ public class SuspendableOutputStream ext
             }
 
         } else if (s == State.RUNNING) {
-            if (state == State.SUSPEND_REQUESTED || state == State.SUSPENDED) {
+            if (state == State.QUEUED 
+                    || state == State.SUSPEND_REQUESTED 
+                    || state == State.SUSPENDED) {
                 state = State.RUNNING;
                 notify();
             }

Modified: sling/trunk/contrib/extensions/bgservlets/src/test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/bgservlets/src/test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java?rev=1042649&r1=1042648&r2=1042649&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/bgservlets/src/test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java
(original)
+++ sling/trunk/contrib/extensions/bgservlets/src/test/java/org/apache/sling/bgservlets/impl/SuspendableOutputStreamTest.java
Mon Dec  6 14:07:08 2010
@@ -174,4 +174,15 @@ public class SuspendableOutputStreamTest
         assertEquals("Expecting DONE state (3)", JobStatus.State.DONE, f
                 .getState());
     }
+    
+    @Test
+    public void testCreationToRunningState() {
+        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        final SuspendableOutputStream f = new SuspendableOutputStream(bos);
+        assertEquals("Expecting NEW state initially", JobStatus.State.NEW, f.getState());
+        f.requestStateChange(JobStatus.State.QUEUED);
+        assertEquals("Expecting QUEUED state as requests", JobStatus.State.QUEUED, f.getState());
+        f.requestStateChange(JobStatus.State.RUNNING);
+        assertEquals("Expecting RUNNING state as requested", JobStatus.State.RUNNING, f.getState());
+    }
 }



Mime
View raw message