### Question:
RegionWidgetTag extends AbstractContextAwareSingletonBeanDependentTag<RenderService> { @Override public int doStartTag() throws JspException { if (regionWidget == null) { throw new JspException("RegionWidget not set: " + regionWidget); } if (widget != null && getBean().getSupportedWidgetTypes().contains(widget.getType()) ) { if ( widget.isDisableRendering() ) { ScriptManager scriptManager = getBeanFromContext(ScriptManager.class); String widgetScript = String.format(DISABLED_SCRIPT_BLOCK, regionWidget.getRegion().getId(), regionWidget.getId(), StringEscapeUtils.escapeEcmaScript(widget.getDisableRenderingMessage()), regionWidget.isCollapsed(), widget.getId()); String key = REGISTER_DISABLED_WIDGET_KEY + "-" + widget.getId(); scriptManager.registerScriptBlock(key, widgetScript, ScriptLocation.AFTER_RAVE, RenderScope.CURRENT_REQUEST, getContext()); } else { writeString(getBean().render(new RegionWidgetWrapper(widget, regionWidget), getContext())); } } else { throw new JspException("Unsupported regionWidget type: " + regionWidget); } regionWidget = null; widget = null; return EVAL_BODY_INCLUDE; } RegionWidgetTag(); RegionWidget getRegionWidget(); void setRegionWidget(RegionWidget regionWidget); Widget getWidget(); void setWidget(Widget widget); @Override int doStartTag();  }### Answer:
@Test(expected = JspException.class) public void doStartTag_nullWidget() throws JspException { replay(pageContext); tag.doStartTag(); }
@Test(expected = JspException.class) public void doStartTag_IOException() throws JspException, IOException { RegionWidget regionWidget = new RegionWidgetImpl(); WidgetImpl widget = new WidgetImpl("8"); regionWidget.setWidgetId(widget.getId()); widget.setType("INVALID"); Set<String> strings = new HashSet<String>(); strings.add(WIDGET_TYPE); expect(service.getSupportedWidgetTypes()).andReturn(strings); replay(service); JspWriter writer = createNiceMock(JspWriter.class); writer.print(RENDERED); expectLastCall().andThrow(new IOException()); replay(writer); replay(pageContext); tag.doStartTag(); tag.doStartTag(); }