我正在尝试通过JUnit测试来测试函数。
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.
}
}
但是getBundle()
时我遇到了这个错误。这很奇怪,因为它可以在运行项目
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)
...
我已经在src / test / resources中添加了这些bundle,它们是从src / main / resources复制的:
bundle_en.properties
bundle_ja.properties
请查看此图片以查看结构https://gyazo.com/297091ef4120a6161bef31c9ead761ef