@Test public void testCloneWithWriter2() throws Exception { Method method = FacesContext.class.getDeclaredMethod("setCurrentInstance", FacesContext.class); method.setAccessible(true); method.invoke(null, new Object[] { null }); Writer writer = new StringWriter(); HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, "text/html", "UTF-8"); Field field = responseWriter.getClass().getDeclaredField("writingCdata"); field.setAccessible(true); field.set(responseWriter, Boolean.TRUE); HtmlResponseWriter clonedWriter = (HtmlResponseWriter) responseWriter.cloneWithWriter(writer); assertTrue((Boolean) field.get(clonedWriter)); responseWriter = new HtmlResponseWriter(writer, "text/html", "UTF-8"); field.set(responseWriter, Boolean.FALSE); clonedWriter = (HtmlResponseWriter) responseWriter.cloneWithWriter(writer); assertFalse((Boolean) field.get(clonedWriter)); }
@Override public ResponseWriter cloneWithWriter(Writer writer) { try { HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, getContentType(), getCharacterEncoding(), isScriptHidingEnabled, isScriptInAttributeValueEnabled, disableUnicodeEscaping, isPartial); responseWriter.dontEscape = this.dontEscape; responseWriter.writingCdata = this.writingCdata; return responseWriter; } catch (FacesException e) { throw new IllegalStateException(); } }
HtmlResponseWriter extends ResponseWriter { @Override public ResponseWriter cloneWithWriter(Writer writer) { try { HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, getContentType(), getCharacterEncoding(), isScriptHidingEnabled, isScriptInAttributeValueEnabled, disableUnicodeEscaping, isPartial); responseWriter.dontEscape = this.dontEscape; responseWriter.writingCdata = this.writingCdata; return responseWriter; } catch (FacesException e) { throw new IllegalStateException(); } } }
HtmlResponseWriter extends ResponseWriter { @Override public ResponseWriter cloneWithWriter(Writer writer) { try { HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, getContentType(), getCharacterEncoding(), isScriptHidingEnabled, isScriptInAttributeValueEnabled, disableUnicodeEscaping, isPartial); responseWriter.dontEscape = this.dontEscape; responseWriter.writingCdata = this.writingCdata; return responseWriter; } catch (FacesException e) { throw new IllegalStateException(); } } HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding);  HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding,
                              Boolean isScriptHidingEnabled,
                              Boolean isScriptInAttributeValueEnabled,
                              WebConfiguration.DisableUnicodeEscaping disableUnicodeEscaping,
                              boolean isPartial); }
HtmlResponseWriter extends ResponseWriter { @Override public ResponseWriter cloneWithWriter(Writer writer) { try { HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, getContentType(), getCharacterEncoding(), isScriptHidingEnabled, isScriptInAttributeValueEnabled, disableUnicodeEscaping, isPartial); responseWriter.dontEscape = this.dontEscape; responseWriter.writingCdata = this.writingCdata; return responseWriter; } catch (FacesException e) { throw new IllegalStateException(); } } HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding);  HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding,
                              Boolean isScriptHidingEnabled,
                              Boolean isScriptInAttributeValueEnabled,
                              WebConfiguration.DisableUnicodeEscaping disableUnicodeEscaping,
                              boolean isPartial); @Override void close(); @Override void flush(); @Override String getContentType(); @Override ResponseWriter cloneWithWriter(Writer writer); @Override void endDocument(); @Override void endElement(String name); @Override String getCharacterEncoding(); @Override void startDocument(); @Override void startElement(String name, UIComponent componentForElement); @Override void startCDATA(); @Override void endCDATA(); @Override void write(char[] cbuf); @Override void write(int c); @Override void write(String str); @Override void write(char[] cbuf, int off, int len); @Override void write(String str, int off, int len); @Override void writeAttribute(String name, Object value,
                               String componentPropertyName); @Override void writeComment(Object comment); void writeText(char text); void writeText(char text[]); @Override void writeText(Object text, String componentPropertyName); @Override void writeText(char text[], int off, int len); @Override void writeURIAttribute(String name, Object value,
                                  String componentPropertyName); }
HtmlResponseWriter extends ResponseWriter { @Override public ResponseWriter cloneWithWriter(Writer writer) { try { HtmlResponseWriter responseWriter = new HtmlResponseWriter(writer, getContentType(), getCharacterEncoding(), isScriptHidingEnabled, isScriptInAttributeValueEnabled, disableUnicodeEscaping, isPartial); responseWriter.dontEscape = this.dontEscape; responseWriter.writingCdata = this.writingCdata; return responseWriter; } catch (FacesException e) { throw new IllegalStateException(); } } HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding);  HtmlResponseWriter(Writer writer,
                              String contentType,
                              String encoding,
                              Boolean isScriptHidingEnabled,
                              Boolean isScriptInAttributeValueEnabled,
                              WebConfiguration.DisableUnicodeEscaping disableUnicodeEscaping,
                              boolean isPartial); @Override void close(); @Override void flush(); @Override String getContentType(); @Override ResponseWriter cloneWithWriter(Writer writer); @Override void endDocument(); @Override void endElement(String name); @Override String getCharacterEncoding(); @Override void startDocument(); @Override void startElement(String name, UIComponent componentForElement); @Override void startCDATA(); @Override void endCDATA(); @Override void write(char[] cbuf); @Override void write(int c); @Override void write(String str); @Override void write(char[] cbuf, int off, int len); @Override void write(String str, int off, int len); @Override void writeAttribute(String name, Object value,
                               String componentPropertyName); @Override void writeComment(Object comment); void writeText(char text); void writeText(char text[]); @Override void writeText(Object text, String componentPropertyName); @Override void writeText(char text[], int off, int len); @Override void writeURIAttribute(String name, Object value,
                                  String componentPropertyName);  }