Commit 61fc1af 1 parent 77fa552 commit 61fc1af Copy full SHA for 61fc1af
File tree 2 files changed +5
-4
lines changed
main/java/org/openmrs/module/web
test/java/org/openmrs/module/web
2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ public class WebModuleUtil {
106
106
* value is returned. Otherwise, false is returned
107
107
*
108
108
* @param mod Module to start
109
- * @param ServletContext the current ServletContext
109
+ * @param servletContext the current ServletContext
110
110
* @param delayContextRefresh true/false whether or not to do the context refresh
111
111
* @return boolean whether or not the spring context need to be refreshed
112
112
*/
@@ -948,7 +948,7 @@ public static HttpServlet getServlet(String servletName) {
948
948
*/
949
949
public static String getModuleWebFolder (String moduleId ) {
950
950
if (dispatcherServlet == null ) {
951
- return null ;
951
+ throw new ModuleException ( "Dispatcher servlet must be present in the web environment" ) ;
952
952
}
953
953
String realPath = dispatcherServlet .getServletContext ().getRealPath ("" );
954
954
String moduleWebFolder = (realPath + "WEB-INF/view/module/" + moduleId ).replace ("/" , File .separator );
Original file line number Diff line number Diff line change 22
22
import org .mockito .stubbing .Answer ;
23
23
import org .openmrs .module .Module ;
24
24
import org .openmrs .module .ModuleConstants ;
25
+ import org .openmrs .module .ModuleException ;
25
26
import org .openmrs .web .DispatcherServlet ;
26
27
import org .powermock .api .mockito .PowerMockito ;
27
28
import org .powermock .core .classloader .annotations .PrepareForTest ;
@@ -104,11 +105,11 @@ private Module buildModuleForMessageTest() {
104
105
* @see WebModuleUtil#getModuleWebFolder(String)
105
106
* @verifies return null if the dispatcher servlet is not yet set
106
107
*/
107
- @ Test
108
+ @ Test ( expected = ModuleException . class )
108
109
public void getModuleWebFolder_shouldReturnNullIfTheDispatcherServletIsNotYetSet () throws Exception {
109
110
//We need to do this in case it is run after getModuleWebFolder_shouldReturnTheCorrectModuleFolder
110
111
WebModuleUtil .setDispatcherServlet (null );
111
- assertNull ( WebModuleUtil .getModuleWebFolder ("basicmodule" ) );
112
+ WebModuleUtil .getModuleWebFolder ("" );
112
113
}
113
114
114
115
/**
You can’t perform that action at this time.
0 commit comments