ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java
(Generate patch)

Comparing jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java (file contents):
Revision 1.15 by jsr166, Sat Nov 21 02:07:26 2009 UTC vs.
Revision 1.21 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
7   */
8  
9 import java.util.concurrent.atomic.*;
9   import junit.framework.*;
10 < import java.util.*;
10 > import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
11  
12   public class AtomicIntegerFieldUpdaterTest extends JSR166TestCase {
13      volatile int x = 0;
# Line 30 | Line 29 | public class AtomicIntegerFieldUpdaterTe
29                  a = AtomicIntegerFieldUpdater.newUpdater
30                  (AtomicIntegerFieldUpdaterTest.class, "y");
31              shouldThrow();
32 <        }
34 <        catch (RuntimeException rt) {}
32 >        } catch (RuntimeException success) {}
33      }
34  
35      /**
# Line 43 | Line 41 | public class AtomicIntegerFieldUpdaterTe
41                  a = AtomicIntegerFieldUpdater.newUpdater
42                  (AtomicIntegerFieldUpdaterTest.class, "z");
43              shouldThrow();
44 <        }
47 <        catch (RuntimeException rt) {}
44 >        } catch (RuntimeException success) {}
45      }
46  
47      /**
# Line 56 | Line 53 | public class AtomicIntegerFieldUpdaterTe
53                  a = AtomicIntegerFieldUpdater.newUpdater
54                  (AtomicIntegerFieldUpdaterTest.class, "w");
55              shouldThrow();
56 <        }
60 <        catch (RuntimeException rt) {}
56 >        } catch (RuntimeException success) {}
57      }
58  
59      /**
60 <     *  get returns the last value set or assigned
60 >     * get returns the last value set or assigned
61       */
62      public void testGetSet() {
63          AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
# Line 76 | Line 72 | public class AtomicIntegerFieldUpdaterTe
72          assertEquals(2,a.get(this));
73          a.set(this,-3);
74          assertEquals(-3,a.get(this));
79
75      }
76  
77      /**
78 <     *  get returns the last value lazySet by same thread
78 >     * get returns the last value lazySet by same thread
79       */
80      public void testGetLazySet() {
81          AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;
# Line 95 | Line 90 | public class AtomicIntegerFieldUpdaterTe
90          assertEquals(2,a.get(this));
91          a.lazySet(this,-3);
92          assertEquals(-3,a.get(this));
98
93      }
94  
95      /**
# Line 113 | Line 107 | public class AtomicIntegerFieldUpdaterTe
107          assertTrue(a.compareAndSet(this,2,-4));
108          assertEquals(-4,a.get(this));
109          assertFalse(a.compareAndSet(this,-5,7));
110 <        assertFalse((7 == a.get(this)));
110 >        assertEquals(-4,a.get(this));
111          assertTrue(a.compareAndSet(this,-4,7));
112          assertEquals(7,a.get(this));
113      }
114  
121
115      /**
116       * compareAndSet in one thread enables another waiting for value
117       * to succeed
# Line 165 | Line 158 | public class AtomicIntegerFieldUpdaterTe
158      }
159  
160      /**
161 <     *  getAndSet returns previous value and sets to given value
161 >     * getAndSet returns previous value and sets to given value
162       */
163      public void testGetAndSet() {
164          AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest> a;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines