[concurrency-interest] CopyOnWrite wrappers Part 2 - now renamed

Martin Buchholz martinrb at google.com
Sat Dec 18 02:18:44 EST 2010


On Fri, Dec 17, 2010 at 12:43, Morgan Conrad <morganconrad at yahoo.com> wrote:

> I modified the JSR 166 Unit Tests to test my code, and have a couple of suggestions for improvements in them.
>
> 1) The code is currently highly specific to the class to be tested.  For example, ConcurrentHashMapTest always refers to a ConcurrentHashMap, when, most of the time, it could refer to a Map or ConcurrentMap.  For example, in testClear(), the first line could be changed
>
> public void testClear() {
>   Map map = map5();  // WAS ConcurrentHashMap
>   map.clear();
>   assertEquals(map.size(), 0);
> }
>
> This would make it easier to extend these tests to other implementations (like mine!).

I agree there are a number of improvements - refactorings and changes
such as yours that would make maintenance of the src/test/tck tests
easier.  You can see a start with BlockingQueueTest.java.  But it
would be a big project, and junit 3 is not providing any help.

> 2) I didn't see where the tests did much actual testing of concurrency.  Did I miss something - is this done elsewhere?  I realize that writing such test code is difficult.  My CISWrapperTest makes modest efforts.

There are different types of tests, with different provenance, in
src/test/{tck,jtreg,loops}
Real concurrency tests often involve long-running loops that attempt
to elicit race conditions, and some of those can be found in
src/test/jtreg and src/test/loops.

 $ find -name '*.java' | xargs grep -l ConcurrentHashMap
./jtreg/util/Collection/BiggernYours.java
./jtreg/util/Collection/IteratorAtEnd.java
./jtreg/util/Collection/MOAT.java
./jtreg/util/Collections/RacingCollections.java
./jtreg/util/Hashtable/SelfRef.java
./jtreg/util/Map/LockStep.java
./jtreg/util/Map/Get.java
./jtreg/util/concurrent/ConcurrentHashMap/MapCheck.java
./jtreg/util/concurrent/ConcurrentHashMap/MapLoops.java
./jtreg/util/concurrent/ConcurrentHashMap/toArray.java
./jtreg/util/concurrent/ConcurrentMap/ConcurrentModification.java
./jtreg/util/concurrent/ConcurrentQueues/GCRetention.java
./jtreg/util/concurrent/ConcurrentQueues/RemovePollRace.java
./jtreg/util/concurrent/ThreadPoolExecutor/ThrowingTasks.java
./jtreg/util/concurrent/locks/ReentrantReadWriteLock/MapLoops.java
./loops/ConcurrentHashSet.java
./loops/IntMapCheck.java
./loops/MapCheck.java
./loops/MapLoops.java
./loops/RLJBar.java
./loops/StringMapLoops.java
./tck/ConcurrentHashMapTest.java
./tck/JSR166TestCase.java



More information about the Concurrency-interest mailing list