james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r564341 - in /james/jsieve/trunk/src: main/java/org/apache/jsieve/commands/CommandStateManager.java main/java/org/apache/jsieve/commands/ConditionManager.java test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java
Date Thu, 09 Aug 2007 19:04:51 GMT
Author: rdonkin
Date: Thu Aug  9 12:04:48 2007
New Revision: 564341

URL: http://svn.apache.org/viewvc?view=rev&rev=564341
Log:
Reset should aply only to instance in the thread and not to every thread.

Added:
    james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java
Modified:
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/CommandStateManager.java
    james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/CommandStateManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/CommandStateManager.java?view=diff&rev=564341&r1=564340&r2=564341
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/CommandStateManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/CommandStateManager.java Thu
Aug  9 12:04:48 2007
@@ -130,7 +130,7 @@
      */
     static public void resetInstance()
     {
-        fieldInstance = null;
+        setInstance(null);
     }    
     
 

Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java?view=diff&rev=564341&r1=564340&r2=564341
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/commands/ConditionManager.java Thu
Aug  9 12:04:48 2007
@@ -210,7 +210,7 @@
      */
     static public void resetInstance()
     {
-        fieldInstance = null;
+        setInstance(null);
     }    
     
 

Added: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java?view=auto&rev=564341
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java
(added)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/commands/ConcurrencyTest.java
Thu Aug  9 12:04:48 2007
@@ -0,0 +1,77 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.jsieve.junit.commands;
+
+import org.apache.jsieve.commands.CommandStateManager;
+import org.apache.jsieve.commands.ConditionManager;
+
+import junit.framework.TestCase;
+
+public class ConcurrencyTest extends TestCase {
+    
+    public void testConditionManagerReset() throws Exception {
+        ConditionManager instance = ConditionManager.getInstance();
+        assertNotNull(instance);
+        
+        class ConcurrentThread extends Thread {
+            ConditionManager one = null;
+            ConditionManager two = null;
+            public void run() {
+                one = ConditionManager.getInstance();
+                ConditionManager.resetInstance();
+                two = ConditionManager.getInstance();
+            }
+        }
+        
+        ConcurrentThread otherThread = new ConcurrentThread();
+        otherThread.start();
+        otherThread.join();
+
+        assertNotNull(otherThread.one);
+        assertNotNull(otherThread.two);
+        assertFalse(otherThread.one.equals(otherThread.two));
+        assertEquals(instance, ConditionManager.getInstance());
+    }
+    
+    public void testCommandStateManagerReset() throws Exception {
+        CommandStateManager instance = CommandStateManager.getInstance();
+        assertNotNull(instance);
+        
+        class ConcurrentThread extends Thread {
+            CommandStateManager one = null;
+            CommandStateManager two = null;
+            public void run() {
+                one = CommandStateManager.getInstance();
+                CommandStateManager.resetInstance();
+                two = CommandStateManager.getInstance();
+            }
+        }
+        
+        ConcurrentThread otherThread = new ConcurrentThread();
+        otherThread.start();
+        otherThread.join();
+
+        assertNotNull(otherThread.one);
+        assertNotNull(otherThread.two);
+        assertFalse(otherThread.one.equals(otherThread.two));
+        
+        assertEquals(instance, CommandStateManager.getInstance());
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message