Reduce warning messages in unit tests.
We get a warning on any attempt to use anything that may be affected by DeveloperSettings, because DeveloperSetting tries to use ConfigurationProperties to find its properties file. We could avoid this by requiring the use of a ConfigurationPropertiesStub, but it seems to make more sense to routinely create a DeveloperSettingsStub on each ServletContextStub.
This commit is contained in:
parent
0b43a44097
commit
70298026ea
3 changed files with 42 additions and 2 deletions
|
@ -21,6 +21,8 @@ import javax.servlet.ServletException;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import stubs.edu.cornell.mannlib.vitro.webapp.utils.developer.DeveloperSettingsStub;
|
||||
|
||||
/**
|
||||
* A simple stand-in for the {@link ServletContext}, for use in unit tests.
|
||||
*/
|
||||
|
@ -36,6 +38,11 @@ public class ServletContextStub implements ServletContext {
|
|||
private final Map<String, String> mockResources = new HashMap<String, String>();
|
||||
private final Map<String, String> realPaths = new HashMap<String, String>();
|
||||
|
||||
public ServletContextStub() {
|
||||
// Assume that unit tests won't want to use Developer mode.
|
||||
DeveloperSettingsStub.set(this);
|
||||
}
|
||||
|
||||
public void setContextPath(String contextPath) {
|
||||
if (contextPath == null) {
|
||||
throw new NullPointerException("contextPath may not be null.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue