Class AtomicIntegerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by JSR166TestCase
              extended by AtomicIntegerTest
All Implemented Interfaces:
junit.framework.Test

public class AtomicIntegerTest
extends JSR166TestCase


Nested Class Summary
 
Nested classes/interfaces inherited from class JSR166TestCase
JSR166TestCase.AdjustablePolicy, JSR166TestCase.CallableOne, JSR166TestCase.CheckedBarrier, JSR166TestCase.CheckedCallable<T>, JSR166TestCase.CheckedInterruptedCallable<T>, JSR166TestCase.CheckedInterruptedRunnable, JSR166TestCase.CheckedRecursiveAction, JSR166TestCase.CheckedRecursiveTask<T>, JSR166TestCase.CheckedRunnable, JSR166TestCase.LongPossiblyInterruptedRunnable, JSR166TestCase.MediumInterruptedRunnable, JSR166TestCase.MediumPossiblyInterruptedRunnable, JSR166TestCase.MediumRunnable, JSR166TestCase.NoOpCallable, JSR166TestCase.NoOpREHandler, JSR166TestCase.NoOpRunnable, JSR166TestCase.NPETask, JSR166TestCase.RunnableShouldThrow, JSR166TestCase.ShortInterruptedRunnable, JSR166TestCase.ShortRunnable, JSR166TestCase.SimpleThreadFactory, JSR166TestCase.SmallCallable, JSR166TestCase.SmallPossiblyInterruptedRunnable, JSR166TestCase.SmallRunnable, JSR166TestCase.StringTask, JSR166TestCase.ThreadShouldThrow, JSR166TestCase.TrackedCallable, JSR166TestCase.TrackedLongRunnable, JSR166TestCase.TrackedMediumRunnable, JSR166TestCase.TrackedNoOpRunnable, JSR166TestCase.TrackedRunnable, JSR166TestCase.TrackedShortRunnable, JSR166TestCase.TrackedSmallRunnable
 
Field Summary
 
Fields inherited from class JSR166TestCase
eight, expensiveTests, five, four, LONG_DELAY_MS, m1, m10, m2, m3, m4, m5, m6, MEDIUM_DELAY_MS, nine, one, seven, SHORT_DELAY_MS, six, SIZE, SMALL_DELAY_MS, TEST_STRING, three, two, zero
 
Constructor Summary
AtomicIntegerTest()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static junit.framework.Test suite()
           
 void testAddAndGet()
          addAndGet adds given value to current, and returns current value
 void testCompareAndSet()
          compareAndSet succeeds in changing value if equal to expected else fails
 void testCompareAndSetInMultipleThreads()
          compareAndSet in one thread enables another waiting for value to succeed
 void testConstructor()
          constructor initializes to given value
 void testConstructor2()
          default constructed initializes to zero
 void testDecrementAndGet()
          decrementAndGet decrements and returns current value
 void testDoubleValue()
          doubleValue returns current value.
 void testFloatValue()
          floatValue returns current value.
 void testGetAndAdd()
          getAndAdd returns previous value and adds given value
 void testGetAndDecrement()
          getAndDecrement returns previous value and decrements
 void testGetAndIncrement()
          getAndIncrement returns previous value and increments
 void testGetAndSet()
          getAndSet returns previous value and sets to given value
 void testGetLazySet()
          get returns the last value lazySet in same thread
 void testGetSet()
          get returns the last value set
 void testIncrementAndGet()
          incrementAndGet increments and returns current value
 void testIntValue()
          intValue returns current value.
 void testLongValue()
          longValue returns current value.
 void testSerialization()
          a deserialized serialized atomic holds same value
 void testToString()
          toString returns current value.
 void testWeakCompareAndSet()
          repeated weakCompareAndSet succeeds in changing value when equal to expected
 
Methods inherited from class JSR166TestCase
assertThreadJoinTimesOut, awaiter, checkEmpty, delay, getShortDelay, joinPool, latchAwaitingStringTask, newTestSuite, permissivePolicy, possiblyInterruptedRunnable, runTest, runTestProfiled, runWithoutPermissions, runWithPermissions, setDelays, setUp, shouldThrow, shouldThrow, tearDown, threadAssertEquals, threadAssertEquals, threadAssertFalse, threadAssertNull, threadAssertSame, threadAssertTrue, threadFail, threadRecordFailure, threadShouldThrow, threadShouldThrow, threadUnexpectedException, trackedRunnable
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AtomicIntegerTest

public AtomicIntegerTest()
Method Detail

main

public static void main(java.lang.String[] args)

suite

public static junit.framework.Test suite()

testConstructor

public void testConstructor()
constructor initializes to given value


testConstructor2

public void testConstructor2()
default constructed initializes to zero


testGetSet

public void testGetSet()
get returns the last value set


testGetLazySet

public void testGetLazySet()
get returns the last value lazySet in same thread


testCompareAndSet

public void testCompareAndSet()
compareAndSet succeeds in changing value if equal to expected else fails


testCompareAndSetInMultipleThreads

public void testCompareAndSetInMultipleThreads()
                                        throws java.lang.Exception
compareAndSet in one thread enables another waiting for value to succeed

Throws:
java.lang.Exception

testWeakCompareAndSet

public void testWeakCompareAndSet()
repeated weakCompareAndSet succeeds in changing value when equal to expected


testGetAndSet

public void testGetAndSet()
getAndSet returns previous value and sets to given value


testGetAndAdd

public void testGetAndAdd()
getAndAdd returns previous value and adds given value


testGetAndDecrement

public void testGetAndDecrement()
getAndDecrement returns previous value and decrements


testGetAndIncrement

public void testGetAndIncrement()
getAndIncrement returns previous value and increments


testAddAndGet

public void testAddAndGet()
addAndGet adds given value to current, and returns current value


testDecrementAndGet

public void testDecrementAndGet()
decrementAndGet decrements and returns current value


testIncrementAndGet

public void testIncrementAndGet()
incrementAndGet increments and returns current value


testSerialization

public void testSerialization()
                       throws java.lang.Exception
a deserialized serialized atomic holds same value

Throws:
java.lang.Exception

testToString

public void testToString()
toString returns current value.


testIntValue

public void testIntValue()
intValue returns current value.


testLongValue

public void testLongValue()
longValue returns current value.


testFloatValue

public void testFloatValue()
floatValue returns current value.


testDoubleValue

public void testDoubleValue()
doubleValue returns current value.