Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit Test and Source Code for Java classes

Tags:

java

I am curious to understand how Java tests its APIs. Let's say,I am interested in the class ConcurrentHashMap, will there be any unit tests for this class? If so, is it available for public?

like image 221
dhanu05 Avatar asked Jul 30 '15 23:07

dhanu05


1 Answers

When you say "Java" you probably mean the Java Development Kit (JDK), which comes as OracleJDK and OpenJDK (OracleJDK is essentially OpenJDK with a few extras). OpenJDK is open-source; and the source code for all of its projects can be found here:

http://hg.openjdk.java.net/

In particular, here is a browsable version of the jdk7 project directory.


I am curious to understand how Java tests its APIs. Let's say,I am interested in the class ConcurrentHashMap, will there be any unit tests for this class? If so, is it available for public?

Yes, for a list of all jdk7 tests look in jdk7/jdk/test.

If you are interested in ConcurrentHashMap tests, look in jdk7/jdk/test/java/util/concurrent/ConcurrentHashMap:


NOTE: The JDK tests may look a bit awkward because it does not use JUnit, it uses JTreg.

like image 169
bcorso Avatar answered Sep 30 '22 03:09

bcorso