Cleanup deprecations in test run.

* Silence deprecations when testing that something is deprecated.
* Refactor to not trigger deprecation warnings if not testing something
  that was deprecated (i.e. old tests that just happened to use
  deprecated behaviors).
Merge pull request #9343 from rwjblue/squelch-deprecation-warnings-in-tests

Cleanup deprecations in test run.