I'm trying to test a function by JUnit test.
public void create() {
Locale locale = new Locale("en");
persist(PersistAction.CREATE, ResourceBundle.getBundle("/bundle", locale).getString("UserCreated"));
if (!JsfUtil.isValidationFailed()) {
items = null; // Invalidate list of items to trigger re-query.
}
}
But I face this error when getBundle()
. It's weird since it could get when Run project
Can't find bundle for base name /bundle, locale en
java.util.MissingResourceException
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:845)
...
I have already added these bundles in src/test/resources, which copied from src/main/resources:
bundle_en.properties
bundle_ja.properties
Please look at this image for structure https://gyazo.com/297091ef4120a6161bef31c9ead761ef