The attached patch adds a JUnit test (StalePlansTest) which tests the same things as lang/staleplans.sql. The patch does not remove the old test.
One thing that puzzled me with the original test, was that three of the calls to SYSCS_GETRUNTIMESTATISTICS() had comments which said they expected table scans, but the query plans in the master file showed that index scans were used. For now, I left the comments which said we expected table scans and added a note saying that we actually get index scans.
For those interested, we get the unexpected query plans on the first, second and fourth call to SYSCS_GETRUNTIMESTATISTICS() in the old staleplans.sql test. In the new JUnit test, all the queries with unexpected query plans are found in testStalePlansOnSmallTable(). I would say it is reasonable to expect a table scan in these cases since the table only contains one row, but I don't know enough about this area to say whether it's a bug. If someone thinks it's a bug, I will file a JIRA for it.