### Question:
HtmlMessageRenderer extends HtmlMessageRendererBase { @Override public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException { super.encodeEnd(facesContext, component); if (component instanceof ClientBehaviorHolder) { Map<String, List<ClientBehavior>> behaviors = ((ClientBehaviorHolder) component).getClientBehaviors(); if (!behaviors.isEmpty()) { ResourceUtils.renderDefaultJsfJsInlineIfNecessary(facesContext, facesContext.getResponseWriter()); } } renderMessage(facesContext, component, false, true); }  @Override void encodeEnd(FacesContext facesContext, UIComponent component);  }### Answer:
@Test public void testRenderSpanOnlyWhenNecessary() throws Exception { facesContext.addMessage(inputText.getClientId(), new FacesMessage(FacesMessage.SEVERITY_WARN, "warnSumary", "detailWarnSummary")); message.setFor("myInputId"); message.encodeEnd(facesContext); facesContext.renderResponse(); String output = writer.getWriter().toString(); System.out.println(output); }