< prev index next >

test/java/util/concurrent/tck/AtomicReferenceFieldUpdaterTest.java

Print this page




 137     public void testConstructor3() {
 138         try {
 139             updaterFor("w");
 140             shouldThrow();
 141         } catch (IllegalArgumentException success) {}
 142     }
 143 
 144     /**
 145      * Constructor with non-reference field throws ClassCastException
 146      */
 147     public void testConstructor4() {
 148         try {
 149             updaterFor("i");
 150             shouldThrow();
 151         } catch (ClassCastException success) {}
 152     }
 153 
 154     /**
 155      * construction using private field from subclass throws RuntimeException
 156      */
 157     public void testPrivateFieldInSubclass() {
 158         AtomicReferenceFieldUpdaterTestSubclass s =
 159             new AtomicReferenceFieldUpdaterTestSubclass();
 160         s.checkPrivateAccess();
 161     }
 162 
 163     /**
 164      * construction from unrelated class; package access is allowed,
 165      * private access is not
 166      */
 167     public void testUnrelatedClassAccess() {
 168         new UnrelatedClass().checkPackageAccess(this);
 169         new UnrelatedClass().checkPrivateAccess(this);
 170     }
 171 
 172     /**
 173      * get returns the last value set or assigned
 174      */
 175     public void testGetSet() {
 176         AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a;
 177         a = updaterFor("x");
 178         x = one;
 179         assertSame(one, a.get(this));
 180         a.set(this, two);
 181         assertSame(two, a.get(this));
 182         a.set(this, m3);
 183         assertSame(m3, a.get(this));
 184     }
 185 
 186     /**
 187      * get returns the last value lazySet by same thread




 137     public void testConstructor3() {
 138         try {
 139             updaterFor("w");
 140             shouldThrow();
 141         } catch (IllegalArgumentException success) {}
 142     }
 143 
 144     /**
 145      * Constructor with non-reference field throws ClassCastException
 146      */
 147     public void testConstructor4() {
 148         try {
 149             updaterFor("i");
 150             shouldThrow();
 151         } catch (ClassCastException success) {}
 152     }
 153 
 154     /**
 155      * construction using private field from subclass throws RuntimeException
 156      */
 157     public void exclude_8187607_testPrivateFieldInSubclass() {
 158         AtomicReferenceFieldUpdaterTestSubclass s =
 159             new AtomicReferenceFieldUpdaterTestSubclass();
 160         s.checkPrivateAccess();
 161     }
 162 
 163     /**
 164      * construction from unrelated class; package access is allowed,
 165      * private access is not
 166      */
 167     public void exclude_8187607_testUnrelatedClassAccess() {
 168         new UnrelatedClass().checkPackageAccess(this);
 169         new UnrelatedClass().checkPrivateAccess(this);
 170     }
 171 
 172     /**
 173      * get returns the last value set or assigned
 174      */
 175     public void testGetSet() {
 176         AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> a;
 177         a = updaterFor("x");
 178         x = one;
 179         assertSame(one, a.get(this));
 180         a.set(this, two);
 181         assertSame(two, a.get(this));
 182         a.set(this, m3);
 183         assertSame(m3, a.get(this));
 184     }
 185 
 186     /**
 187      * get returns the last value lazySet by same thread


< prev index next >