### Question:
AbstractContextAwareSingletonBeanDependentTag extends TagSupport { protected void writeString(String output) throws JspException { try { this.pageContext.getOut().print(output); } catch (IOException e) { throw new JspException("Failed to render", e); } } protected  AbstractContextAwareSingletonBeanDependentTag(Class<T> clazz);   }### Answer:
@Test public void validWrite() throws IOException, JspException { JspWriter outStream = createNiceMock(JspWriter.class); expect(pageContext.getOut()).andReturn(outStream).once(); replay(pageContext); outStream.print(TEST_STRING); expectLastCall().once(); replay(outStream); tag.writeString(TEST_STRING); verify(outStream); }
@Test(expected = JspException.class) public void invalidWrite_io() throws IOException, JspException { JspWriter outStream = createNiceMock(JspWriter.class); expect(pageContext.getOut()).andReturn(outStream).once(); replay(pageContext); outStream.print(TEST_STRING); expectLastCall().andThrow(new IOException()); replay(outStream); tag.writeString(TEST_STRING); }