### Question:
CachedOutputStream extends OutputStream { public void close() throws IOException { currentStream.flush(); outputLocked = true; if (null != callbacks) { for (CachedOutputStreamCallback cb : callbacks) { cb.onClose(this); } } doClose(); currentStream.close(); if (ciphers != null) { ciphers.clean(); } if (!maybeDeleteTempFile(currentStream)) { postClose(); } } CachedOutputStream();  CachedOutputStream(long threshold); void holdTempFile(); void releaseTempFileHold(); void registerCallback(CachedOutputStreamCallback cb); void deregisterCallback(CachedOutputStreamCallback cb); List<CachedOutputStreamCallback> getCallbacks(); void flush(); void lockOutputStream(); void close(); boolean equals(Object obj); void resetOut(OutputStream out, boolean copyOldContent); static void copyStream(InputStream in, OutputStream out, int bufferSize); long size(); byte[] getBytes(); void writeCacheTo(OutputStream out); void writeCacheTo(StringBuilder out, long limit); void writeCacheTo(StringBuilder out, String charsetName, long limit); void writeCacheTo(StringBuilder out); void writeCacheTo(StringBuilder out, String charsetName); OutputStream getOut(); int hashCode(); String toString(); void write(byte[] b, int off, int len); void write(byte[] b); void write(int b); File getTempFile(); InputStream getInputStream(); void setOutputDir(File outputDir); long getThreshold(); void setThreshold(long threshold); void setMaxSize(long maxSize); void setCipherTransformation(String cipherTransformation); static void setDefaultMaxSize(long l); static void setDefaultThreshold(int i); static boolean isThresholdSysPropSet(); static void setDefaultCipherTransformation(String n);  }### Answer:
@Test public void testUseSysPropsWithAttachmentDeserializer() throws Exception { String old = System.getProperty(CachedConstants.THRESHOLD_SYS_PROP); try { System.clearProperty(CachedConstants.THRESHOLD_SYS_PROP); reloadDefaultProperties(); CachedOutputStream cache = new CachedOutputStream(); Message message = new MessageImpl(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); File tmpfile = getTmpFile("Hello World!", cache); assertNull("expects no tmp file", tmpfile); cache.close(); System.setProperty(CachedConstants.THRESHOLD_SYS_PROP, "4"); reloadDefaultProperties(); cache = new CachedOutputStream(); AttachmentUtil.setStreamedAttachmentProperties(message, cache); tmpfile = getTmpFile("Hello World!", cache); assertNotNull("expects a tmp file", tmpfile); assertTrue("expects a tmp file", tmpfile.exists()); cache.close(); assertFalse("expects no tmp file", tmpfile.exists()); } finally { System.clearProperty(CachedConstants.THRESHOLD_SYS_PROP); if (old != null) { System.setProperty(CachedConstants.THRESHOLD_SYS_PROP, old); } } }