Reputation: 439
I have the next block of code:
public void init() {
facultyList = new ArrayList<>();
localeFile = new Properties();
try {
localeFile.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(loadFileName()));
} catch (IOException | NullPointerException e) {
LOG.error("Host: " + ((HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemoteHost()
+ " | Error in constructing of LocaleModel. More: " + e);
}
}
Any possible solutions to mock Thread.currentThread().getContextClassLoader()
or how can I test this catch
block?
Upvotes: 3
Views: 2683
Reputation: 6306
You can set a custom context class loader. It is important to keep track of the original context class loader and put it back into context when your test is done.
Upvotes: 4