Implement UnderFileSystemFactoryRegistryRule


In unit tests, you may see code patterns like this (e.g., in tests/src/test/java/alluxio/master/file/

This purpose of this code block is to register a Factory before the test, and remove it after the tests. UnderFileSystemFactoryRegistry is a singleton and requires developers to be extra careful to setup and tear down. Otherwise, the state will be carried over to the next test.

This JIRA aims to make it cleaner by following the pattern of alluxio.LoginUserRule (core/common/src/test/java/alluxio/, which is better / recommended way in Java unit tests to set and restore a static global value during this tests.
This JIRA proposes to create UnderFileSystemFactoryRegistryRule like LoginUserRule that add a new factory, and later on remove this factory.

The implementation of UnderFileSystemFactoryRegistryRule should be similar to


Your pinned fields
Click on the next to a field label to start pinning.


Mingdi Mao


Bin Fan