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

Comparing jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java (file contents):
Revision 1.4 by dl, Thu Sep 25 11:02:41 2003 UTC vs.
Revision 1.7 by dl, Mon Dec 29 19:05:40 2003 UTC

# Line 1 | Line 1
1   /*
2 < * Written by members of JCP JSR-166 Expert Group and released to the
3 < * public domain. Use, modify, and redistribute this code in any way
4 < * without acknowledgement. Other contributors include Andrew Wright,
5 < * Jeffrey Hayes, Pat Fischer, Mike Judd.
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
5 > * Other contributors include Andrew Wright, Jeffrey Hayes,
6 > * Pat Fisher, Mike Judd.
7   */
8  
9   import java.util.concurrent.atomic.*;
# Line 22 | Line 23 | public class AtomicReferenceFieldUpdater
23      }
24  
25      /**
26 <     * Contruction with non-existent field throws RuntimeException
26 >     * Construction with non-existent field throws RuntimeException
27       */
28      public void testConstructor(){
29          try{
30              AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
31                  a = AtomicReferenceFieldUpdater.newUpdater
32 <                (getClass(), Integer.class, "y");
32 >                (AtomicReferenceFieldUpdaterTest.class, Integer.class, "y");
33              shouldThrow();
34          }
35          catch (RuntimeException rt) {}
# Line 42 | Line 43 | public class AtomicReferenceFieldUpdater
43          try{
44              AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
45                  a = AtomicReferenceFieldUpdater.newUpdater
46 <                (getClass(), Integer.class, "z");
46 >                (AtomicReferenceFieldUpdaterTest.class, Integer.class, "z");
47              shouldThrow();
48          }
49          catch (RuntimeException rt) {}
# Line 55 | Line 56 | public class AtomicReferenceFieldUpdater
56          try{
57              AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>
58                  a = AtomicReferenceFieldUpdater.newUpdater
59 <                (getClass(), Integer.class, "w");
59 >                (AtomicReferenceFieldUpdaterTest.class, Integer.class, "w");
60              shouldThrow();
61          }
62          catch (RuntimeException rt) {}
# Line 65 | Line 66 | public class AtomicReferenceFieldUpdater
66       *  get returns the last value set or assigned
67       */
68      public void testGetSet(){
69 <        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(getClass(), Integer.class, "x");
69 >        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
70          x = one;
71          assertEquals(one,a.get(this));
72          a.set(this,two);
# Line 78 | Line 79 | public class AtomicReferenceFieldUpdater
79       * compareAndSet succeeds in changing value if equal to expected else fails
80       */
81      public void testCompareAndSet(){
82 <        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(getClass(), Integer.class, "x");
82 >        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
83          x = one;
84          assertTrue(a.compareAndSet(this,one,two));
85          assertTrue(a.compareAndSet(this,two,m4));
# Line 95 | Line 96 | public class AtomicReferenceFieldUpdater
96       */
97      public void testCompareAndSetInMultipleThreads() {
98          x = one;
99 <        final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(getClass(), Integer.class, "x");
99 >        final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
100  
101          Thread t = new Thread(new Runnable() {
102                  public void run() {
# Line 118 | Line 119 | public class AtomicReferenceFieldUpdater
119       * to expected
120       */
121      public void testWeakCompareAndSet(){
122 <        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(getClass(), Integer.class, "x");
122 >        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
123          x = one;
124          while(!a.weakCompareAndSet(this,one,two));
125          while(!a.weakCompareAndSet(this,two,m4));
# Line 131 | Line 132 | public class AtomicReferenceFieldUpdater
132       * getAndSet returns previous value and sets to given value
133       */
134      public void testGetAndSet(){
135 <        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(getClass(), Integer.class, "x");
135 >        AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x");
136          x = one;
137          assertEquals(one,a.getAndSet(this, zero));
138          assertEquals(zero,a.getAndSet(this,m10));

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines