21 |
|
/** |
22 |
|
* constructor initializes to given value |
23 |
|
*/ |
24 |
< |
public void testConstructor(){ |
24 |
> |
public void testConstructor() { |
25 |
|
AtomicReference ai = new AtomicReference(one); |
26 |
|
assertEquals(one,ai.get()); |
27 |
|
} |
29 |
|
/** |
30 |
|
* default constructed initializes to null |
31 |
|
*/ |
32 |
< |
public void testConstructor2(){ |
32 |
> |
public void testConstructor2() { |
33 |
|
AtomicReference ai = new AtomicReference(); |
34 |
|
assertNull(ai.get()); |
35 |
|
} |
37 |
|
/** |
38 |
|
* get returns the last value set |
39 |
|
*/ |
40 |
< |
public void testGetSet(){ |
40 |
> |
public void testGetSet() { |
41 |
|
AtomicReference ai = new AtomicReference(one); |
42 |
|
assertEquals(one,ai.get()); |
43 |
|
ai.set(two); |
49 |
|
/** |
50 |
|
* get returns the last value lazySet in same thread |
51 |
|
*/ |
52 |
< |
public void testGetLazySet(){ |
52 |
> |
public void testGetLazySet() { |
53 |
|
AtomicReference ai = new AtomicReference(one); |
54 |
|
assertEquals(one,ai.get()); |
55 |
|
ai.lazySet(two); |
61 |
|
/** |
62 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
63 |
|
*/ |
64 |
< |
public void testCompareAndSet(){ |
64 |
> |
public void testCompareAndSet() { |
65 |
|
AtomicReference ai = new AtomicReference(one); |
66 |
|
assertTrue(ai.compareAndSet(one,two)); |
67 |
|
assertTrue(ai.compareAndSet(two,m4)); |
98 |
|
* repeated weakCompareAndSet succeeds in changing value when equal |
99 |
|
* to expected |
100 |
|
*/ |
101 |
< |
public void testWeakCompareAndSet(){ |
101 |
> |
public void testWeakCompareAndSet() { |
102 |
|
AtomicReference ai = new AtomicReference(one); |
103 |
|
while (!ai.weakCompareAndSet(one,two)); |
104 |
|
while (!ai.weakCompareAndSet(two,m4)); |
110 |
|
/** |
111 |
|
* getAndSet returns previous value and sets to given value |
112 |
|
*/ |
113 |
< |
public void testGetAndSet(){ |
113 |
> |
public void testGetAndSet() { |
114 |
|
AtomicReference ai = new AtomicReference(one); |
115 |
|
assertEquals(one,ai.getAndSet(zero)); |
116 |
|
assertEquals(zero,ai.getAndSet(m10)); |
134 |
|
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
135 |
|
AtomicReference r = (AtomicReference) in.readObject(); |
136 |
|
assertEquals(l.get(), r.get()); |
137 |
< |
} catch (Exception e){ |
137 |
> |
} catch (Exception e) { |
138 |
|
unexpectedException(); |
139 |
|
} |
140 |
|
} |