Skip to content

Commit 61fc1af

Browse files
committedMay 12, 2013
Made changes to throw an exception if the dispatcher servlet is null - TRUNK-1589
Fixed javadoc - TRUNK-1589
1 parent 77fa552 commit 61fc1af

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed
 

‎web/src/main/java/org/openmrs/module/web/WebModuleUtil.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public class WebModuleUtil {
106106
* value is returned. Otherwise, false is returned
107107
*
108108
* @param mod Module to start
109-
* @param ServletContext the current ServletContext
109+
* @param servletContext the current ServletContext
110110
* @param delayContextRefresh true/false whether or not to do the context refresh
111111
* @return boolean whether or not the spring context need to be refreshed
112112
*/
@@ -948,7 +948,7 @@ public static HttpServlet getServlet(String servletName) {
948948
*/
949949
public static String getModuleWebFolder(String moduleId) {
950950
if (dispatcherServlet == null) {
951-
return null;
951+
throw new ModuleException("Dispatcher servlet must be present in the web environment");
952952
}
953953
String realPath = dispatcherServlet.getServletContext().getRealPath("");
954954
String moduleWebFolder = (realPath + "WEB-INF/view/module/" + moduleId).replace("/", File.separator);

‎web/src/test/java/org/openmrs/module/web/WebModuleUtilTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.mockito.stubbing.Answer;
2323
import org.openmrs.module.Module;
2424
import org.openmrs.module.ModuleConstants;
25+
import org.openmrs.module.ModuleException;
2526
import org.openmrs.web.DispatcherServlet;
2627
import org.powermock.api.mockito.PowerMockito;
2728
import org.powermock.core.classloader.annotations.PrepareForTest;
@@ -104,11 +105,11 @@ private Module buildModuleForMessageTest() {
104105
* @see WebModuleUtil#getModuleWebFolder(String)
105106
* @verifies return null if the dispatcher servlet is not yet set
106107
*/
107-
@Test
108+
@Test(expected = ModuleException.class)
108109
public void getModuleWebFolder_shouldReturnNullIfTheDispatcherServletIsNotYetSet() throws Exception {
109110
//We need to do this in case it is run after getModuleWebFolder_shouldReturnTheCorrectModuleFolder
110111
WebModuleUtil.setDispatcherServlet(null);
111-
assertNull(WebModuleUtil.getModuleWebFolder("basicmodule"));
112+
WebModuleUtil.getModuleWebFolder("");
112113
}
113114

114115
/**

0 commit comments

Comments
 (0)
Please sign in to comment.