LimitedSizeWriter extends Writer { public static Writer from(Writer internalWriter, RenderedSizeContext context) { if (context.getMaxRenderedSize() < 0) { return internalWriter; } return new LimitedSizeWriter(internalWriter, context); } private  LimitedSizeWriter(Writer internalWriter, RenderedSizeContext context); static Writer from(Writer internalWriter, RenderedSizeContext context); @Override void write(char[] cbuf, int off, int len); @Override void flush(); @Override void close(); @Override String toString();  }
@Test void negativeMaxSizeReturnsTheOriginalWriter() { Writer internalWriter = new StringWriter(); Writer limitedSizeWriter = LimitedSizeWriter.from(internalWriter, new TestRenderedSizeContext(-1)); assertSame(internalWriter, limitedSizeWriter); }