Make ResourceTest a JUnit TestRule

TestRules are much more flexible. They can be run at either the class or the test level, and can be combined with other TestRules for more complex behaviour.