@Test public void testTimeWriteToCache() { String[] input = new String[]{"2001-07-01T01:01:01Z", "2002-07-15T01:01:01Z"}; Time bean = null; try { bean = new Time(input); } catch (ParseException ex) { fail(ex.getMessage()); } CacheIdentifier cacheId = null; try { cacheId = new ResponseCache.CacheIdentifier("https: boolean didWrite = bean.writeToCache(cacheId); assertTrue(didWrite); } finally { if (cacheId != null) { try { FileUtils.deleteQuietly(cacheId.getFile()); } catch (IOException ex) { } } } }
@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); } }
Time 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); } } }
Time 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); } } Time();  Time(String[] dateRange); }
Time 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); } } Time();  Time(String[] dateRange); void setTime(String[] time); String[] getTime(); void setStarttime(TimeBreakdown starttime); TimeBreakdown getStarttime(); void setEndtime(TimeBreakdown endtime); TimeBreakdown getEndtime(); @Override String toXML(); @Override String toString(); static Time buildFromCache(ResponseCache.CacheIdentifier ci); @Override boolean writeToCache(ResponseCache.CacheIdentifier ci); }
Time 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); } } Time();  Time(String[] dateRange); void setTime(String[] time); String[] getTime(); void setStarttime(TimeBreakdown starttime); TimeBreakdown getStarttime(); void setEndtime(TimeBreakdown endtime); TimeBreakdown getEndtime(); @Override String toXML(); @Override String toString(); static Time buildFromCache(ResponseCache.CacheIdentifier ci); @Override boolean writeToCache(ResponseCache.CacheIdentifier ci);  }