Refactor testing logic for only running under certain JDK versions

We had several tests designed to only run if the JDK version was at
least some specified version. This commit refactors that common logic
into DirectTest.