Created
January 31, 2014 10:35
-
-
Save jpcaruana/8729800 to your computer and use it in GitHub Desktop.
set your Locale in your tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.barreverte.test; | |
import org.junit.rules.ExternalResource; | |
import java.util.Locale; | |
public class LocaleRule extends ExternalResource { | |
private final Locale toRestore; | |
private final Locale forTest; | |
public LocaleRule(Locale forTest) { | |
this.toRestore = Locale.getDefault(); | |
this.forTest = forTest; | |
} | |
@Override | |
protected void before() throws Throwable { | |
Locale.setDefault(forTest); | |
} | |
@Override | |
protected void after() { | |
Locale.setDefault(toRestore); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment