added Junit test to help fixing bug #7058

As you can see from the Travis failure, the test case is exposing a StackOverflow as well as a NullPointerException - all via legal API calls IMHO.