Utils { static void downloadAndInstallAuxdata(Path targetDir, URL remoteZipFileUrl) throws L2AuxDataException { final URL fileUrl; try { fileUrl = remoteZipFileUrl; final URLConnection urlConnection; if (System.getProperty("http.proxyHost") == null || System.getProperty("http.proxyPort") == null) { urlConnection = fileUrl.openConnection(); } else { urlConnection = fileUrl.openConnection(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(System.getProperty("http.proxyHost"), Integer.parseInt(System.getProperty("http.proxyPort"))))); } InputStream inputStream = urlConnection.getInputStream(); ZipInputStream zis = new ZipInputStream(inputStream); ZipEntry entry; while((entry = zis.getNextEntry()) != null) { Path filepath = targetDir.resolve(entry.getName()); if (!entry.isDirectory()) { Files.copy(zis, filepath); } else { Files.createDirectories(filepath); } } } catch (IOException e) { throw new L2AuxDataException("Not able to download auxiliary data from " + remoteZipFileUrl, e); } } private  Utils(); static double computeSeasonalFactor(double daysSince2000, double sunEarthDistanceSquare); static boolean isProductRR(Product product); static boolean isProductFR(Product product);  }
@Test public void testDownloadAndInstall() throws Exception { FileSystem fs = Jimfs.newFileSystem(); Path target = fs.getPath("target"); Utils.downloadAndInstallAuxdata(target, UtilsTest.class.getResource("zip.zip")); Path zipDir = target.resolve("zip"); assertTrue(Files.isDirectory(zipDir)); Path imageFile = zipDir.resolve("image.png"); assertTrue(Files.isRegularFile(imageFile)); assertEquals(45088, Files.size(imageFile)); Path textFile = zipDir.resolve("folder").resolve("text.txt"); assertTrue(Files.isRegularFile(textFile)); assertEquals(1710, Files.size(textFile)); fs.close(); }