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.32 by jsr166, Wed Dec 31 21:50:25 2014 UTC vs.
Revision 1.36 by jsr166, Wed Sep 20 00:41:13 2017 UTC

# Line 13 | Line 13 | import junit.framework.TestSuite;
13  
14   public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase {
15      volatile Integer x = null;
16 +    protected volatile Integer protectedField;
17 +    private volatile Integer privateField;
18      Object z;
19      Integer w;
20      volatile int i;
21  
22      public static void main(String[] args) {
23 <        junit.textui.TestRunner.run(suite());
23 >        main(suite(), args);
24      }
25      public static Test suite() {
26          return new TestSuite(AtomicReferenceFieldUpdaterTest.class);
27      }
28  
29 <    AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> updaterFor(String fieldName) {
29 >    static AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> updaterFor(String fieldName) {
30          return AtomicReferenceFieldUpdater.newUpdater
31              (AtomicReferenceFieldUpdaterTest.class, Integer.class, fieldName);
32      }
# Line 72 | Line 74 | public class AtomicReferenceFieldUpdater
74      }
75  
76      /**
77 +     * construction using private field from subclass throws RuntimeException
78 +     */
79 +    public void testPrivateFieldInSubclass() {
80 +        new NonNestmates.AtomicReferenceFieldUpdaterTestSubclass()
81 +            .checkPrivateAccess();
82 +    }
83 +
84 +    /**
85 +     * construction from unrelated class; package access is allowed,
86 +     * private access is not
87 +     */
88 +    public void testUnrelatedClassAccess() {
89 +        new NonNestmates().checkPackageAccess(this);
90 +        new NonNestmates().checkPrivateAccess(this);
91 +    }
92 +
93 +    /**
94       * get returns the last value set or assigned
95       */
96      public void testGetSet() {
# Line 110 | Line 129 | public class AtomicReferenceFieldUpdater
129          assertTrue(a.compareAndSet(this, two, m4));
130          assertSame(m4, a.get(this));
131          assertFalse(a.compareAndSet(this, m5, seven));
132 <        assertFalse(seven == a.get(this));
132 >        assertNotSame(seven, a.get(this));
133          assertTrue(a.compareAndSet(this, m4, seven));
134          assertSame(seven, a.get(this));
135      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines