DataTypeCollection extends Response { @Override public boolean writeToCache(ResponseCache.CacheIdentifier ci) { FileOutputStream filOutputStream = null; ObjectOutputStream objOutputStream = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return false; } try { try { cacheFile.createNewFile(); filOutputStream = new FileOutputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not open output stream to file {}", cacheFile.getPath(), ex); return false; } catch (IOException ex) { log.warn("Could notcreate new cache file {}", cacheFile.getPath(), ex); return false; } try { objOutputStream = new ObjectOutputStream(filOutputStream); } catch (IOException ex) { log.warn("Could not open object output stream to file {}", cacheFile.getPath(), ex); return false; } try { objOutputStream.writeObject(this); } catch (IOException ex) { log.warn("Could not write object output to output stream", ex); return false; } return true; } finally { IOUtils.closeQuietly(filOutputStream); IOUtils.closeQuietly(objOutputStream); } } DataTypeCollection();  DataTypeCollection(String type, DataTypeBean... dataTypeArray);  DataTypeCollection(String type, VariableSimpleIF... variableSimpleIFArray); @Override String toXML(); String getDataType(); void setDataType(String dataType); List<DataTypeBean> getDataTypeCollection(); void setDataTypeCollection(List<DataTypeBean> dataTypeCollection); static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci); @Override boolean writeToCache(ResponseCache.CacheIdentifier ci);  }
@Test public void testWriteToCache() { DataTypeBean dtb = new DataTypeBean(); DataTypeCollection inputBean = null; inputBean = new DataTypeCollection("test-type", dtb); ResponseCache.CacheIdentifier cacheId = null; try { cacheId = new ResponseCache.CacheIdentifier("https: boolean didWrite = inputBean.writeToCache(cacheId); assertTrue(didWrite); } finally { if (cacheId != null) { try { FileUtils.deleteQuietly(cacheId.getFile()); } catch (IOException ex) { } } } }