### Question:
ServletParamUtils { public static String getParameterValue(String paramName, ServletConfig config) { String configParam = null; if (paramName == null) { throw new IllegalArgumentException( "null 'paramName' paramater in method call."); } else if (paramName.trim().equals("")) { throw new IllegalArgumentException( "empty 'paramName' paramater in method call."); } else if (config == null) { throw new IllegalArgumentException( "null 'config' paramater in method call."); } configParam = config.getInitParameter(paramName); if (configParam == null) { configParam = config.getServletContext() .getInitParameter(paramName); } return configParam; }  static String getParameterValue(String paramName,
			ServletConfig config); static String getParameterValue(String paramName,
			ServletConfig config, String defaultVal);  }### Answer:
@Test public void testGetResource_exceptions() { try { ServletParamUtils.getParameterValue(null, null); fail("no IllegalArgumentException on null 'paramName' param"); } catch (IllegalArgumentException e) { } try { ServletParamUtils.getParameterValue("", null); fail("no IllegalArgumentException on empty 'paramName' param"); } catch (IllegalArgumentException e) { } try { ServletParamUtils.getParameterValue(" ", null); fail("no IllegalArgumentException on whitespace 'paramName' param"); } catch (IllegalArgumentException e) { } try { ServletParamUtils.getParameterValue("paramName", null); fail("no IllegalStateException on null 'config' param"); } catch (IllegalArgumentException e) { } }
@Test public void testGetResource_initparam() { MockServletConfig config = getServletConfig(); config.setInitParameter("paraX", "paraX-config"); ((MockServletContext) config.getServletContext()).setInitParameter( "paraX", "paraX-context"); try { assertEquals("paraX-config", ServletParamUtils.getParameterValue( "paraX", config)); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void testGetResource_contextparam() { MockServletConfig config = getServletConfig(); ((MockServletContext) config.getServletContext()).setInitParameter( "paraX", "paraX-context"); try { assertEquals("paraX-context", ServletParamUtils.getParameterValue( "paraX", config)); } catch (Exception e) { fail(e.getMessage()); } }