@Test public void testBuildFromCache() { DataTypeBean dtb = new DataTypeBean(); DataTypeCollection inputBean = null; inputBean = new DataTypeCollection("test-type", dtb); inputBean.getDataTypeCollection().get(0).setDescription("TEST DESCRIPTION"); inputBean.getDataTypeCollection().get(0).setName("TEST NAME"); inputBean.getDataTypeCollection().get(0).setShape(new int[]{1,2,3,4}); inputBean.getDataTypeCollection().get(0).setRank(1024); inputBean.getDataTypeCollection().get(0).setShortname("SHORT NAME"); inputBean.getDataTypeCollection().get(0).setUnitsstring("UNITS STRING"); ResponseCache.CacheIdentifier cacheId = null; try { cacheId = new ResponseCache.CacheIdentifier("https: boolean didWrite = inputBean.writeToCache(cacheId); assertTrue(didWrite); DataTypeCollection resultBean = DataTypeCollection.buildFromCache(cacheId); assertNotNull(resultBean); assertEquals(resultBean.getDataType(), "test-type"); assertEquals(resultBean.getDataTypeCollection().get(0).getDescription(), "TEST DESCRIPTION"); assertEquals(resultBean.getDataTypeCollection().get(0).getName(), "TEST NAME"); assertEquals(resultBean.getDataTypeCollection().get(0).getShortname(), "SHORT NAME"); assertEquals(resultBean.getDataTypeCollection().get(0).getUnitsstring(), "UNITS STRING"); assertEquals(resultBean.getDataTypeCollection().get(0).getShape()[0], 1); assertEquals(resultBean.getDataTypeCollection().get(0).getShape()[1], 2); assertEquals(resultBean.getDataTypeCollection().get(0).getShape()[2], 3); assertEquals(resultBean.getDataTypeCollection().get(0).getShape()[3], 4); assertEquals(resultBean.getDataTypeCollection().get(0).getRank(), 1024); } finally { if (cacheId != null) { try { FileUtils.deleteQuietly(cacheId.getFile()); } catch (IOException ex) { } } } }
public static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci) { DataTypeCollection result; FileInputStream fileIn = null; ObjectInputStream in = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return null; } try { try { fileIn = new FileInputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not find cache file {}", cacheFile.getPath(), ex); return null; } try { in = new ObjectInputStream(fileIn); } catch (IOException ex) { log.warn("Could not read cache file {}", cacheFile.getPath(), ex); return null; } try { result = (DataTypeCollection) in.readObject(); } catch (IOException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } catch (ClassNotFoundException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(fileIn); } return result; }
DataTypeCollection extends Response { public static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci) { DataTypeCollection result; FileInputStream fileIn = null; ObjectInputStream in = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return null; } try { try { fileIn = new FileInputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not find cache file {}", cacheFile.getPath(), ex); return null; } try { in = new ObjectInputStream(fileIn); } catch (IOException ex) { log.warn("Could not read cache file {}", cacheFile.getPath(), ex); return null; } try { result = (DataTypeCollection) in.readObject(); } catch (IOException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } catch (ClassNotFoundException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(fileIn); } return result; } }
DataTypeCollection extends Response { public static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci) { DataTypeCollection result; FileInputStream fileIn = null; ObjectInputStream in = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return null; } try { try { fileIn = new FileInputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not find cache file {}", cacheFile.getPath(), ex); return null; } try { in = new ObjectInputStream(fileIn); } catch (IOException ex) { log.warn("Could not read cache file {}", cacheFile.getPath(), ex); return null; } try { result = (DataTypeCollection) in.readObject(); } catch (IOException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } catch (ClassNotFoundException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(fileIn); } return result; } DataTypeCollection();  DataTypeCollection(String type, DataTypeBean... dataTypeArray);  DataTypeCollection(String type, VariableSimpleIF... variableSimpleIFArray); }
DataTypeCollection extends Response { public static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci) { DataTypeCollection result; FileInputStream fileIn = null; ObjectInputStream in = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return null; } try { try { fileIn = new FileInputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not find cache file {}", cacheFile.getPath(), ex); return null; } try { in = new ObjectInputStream(fileIn); } catch (IOException ex) { log.warn("Could not read cache file {}", cacheFile.getPath(), ex); return null; } try { result = (DataTypeCollection) in.readObject(); } catch (IOException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } catch (ClassNotFoundException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(fileIn); } return result; } 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); }
DataTypeCollection extends Response { public static DataTypeCollection buildFromCache(ResponseCache.CacheIdentifier ci) { DataTypeCollection result; FileInputStream fileIn = null; ObjectInputStream in = null; File cacheFile; try { cacheFile = ci.getFile(); } catch (IOException ex) { log.warn("Could not create new cache file", ex); return null; } try { try { fileIn = new FileInputStream(cacheFile); } catch (FileNotFoundException ex) { log.warn("Could not find cache file {}", cacheFile.getPath(), ex); return null; } try { in = new ObjectInputStream(fileIn); } catch (IOException ex) { log.warn("Could not read cache file {}", cacheFile.getPath(), ex); return null; } try { result = (DataTypeCollection) in.readObject(); } catch (IOException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } catch (ClassNotFoundException ex) { log.warn("Could not inflate cache file {}", cacheFile.getPath(), ex); return null; } } finally { IOUtils.closeQuietly(in); IOUtils.closeQuietly(fileIn); } return result; } 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);  }