@Test public void shouldZipExternalResources_HierarchicalFolderCase() { ResourceFolder uploadFolder = new ResourceFolder("hierarchy"); File file = uploadFolder.toZip(); File tempDir = Files.createTempDir(); ZipUtil.unpack(file, tempDir); verifyFilesInZip(tempDir, "hierarchy/level0.txt", "hierarchy/level1", "hierarchy/level1/level1.txt", "hierarchy/level1/level2", "hierarchy/level1/level2/level2.txt", "hierarchy/level1.1/level1.1.txt", "hierarchy/level1.1/level2.2", "hierarchy/level1.1/level2.2/level2.2.txt"); }
public File toZip() { LOGGER.debug("Zipping resource folder " + path); try { URL dirURL = Resources.getResource(path); if (dirURL == null) { throw new ResourcePackagingException("Failed to get resource at " + path); } File destZip = File.createTempFile("resources_", ".zip"); LOGGER.debug("Created temporary zip at " + destZip.getAbsolutePath()); LOGGER.debug("Resource protocol is " + dirURL.getProtocol()); if ("file".equals(dirURL.getProtocol())) { mapFolderFromResources(dirURL, destZip); } else { mapFolderFromJar(dirURL, destZip); } return destZip; } catch (Exception e) { throw new ResourcePackagingException(e); } }
ResourceFolder { public File toZip() { LOGGER.debug("Zipping resource folder " + path); try { URL dirURL = Resources.getResource(path); if (dirURL == null) { throw new ResourcePackagingException("Failed to get resource at " + path); } File destZip = File.createTempFile("resources_", ".zip"); LOGGER.debug("Created temporary zip at " + destZip.getAbsolutePath()); LOGGER.debug("Resource protocol is " + dirURL.getProtocol()); if ("file".equals(dirURL.getProtocol())) { mapFolderFromResources(dirURL, destZip); } else { mapFolderFromJar(dirURL, destZip); } return destZip; } catch (Exception e) { throw new ResourcePackagingException(e); } } }
ResourceFolder { public File toZip() { LOGGER.debug("Zipping resource folder " + path); try { URL dirURL = Resources.getResource(path); if (dirURL == null) { throw new ResourcePackagingException("Failed to get resource at " + path); } File destZip = File.createTempFile("resources_", ".zip"); LOGGER.debug("Created temporary zip at " + destZip.getAbsolutePath()); LOGGER.debug("Resource protocol is " + dirURL.getProtocol()); if ("file".equals(dirURL.getProtocol())) { mapFolderFromResources(dirURL, destZip); } else { mapFolderFromJar(dirURL, destZip); } return destZip; } catch (Exception e) { throw new ResourcePackagingException(e); } } ResourceFolder(String path); }
ResourceFolder { public File toZip() { LOGGER.debug("Zipping resource folder " + path); try { URL dirURL = Resources.getResource(path); if (dirURL == null) { throw new ResourcePackagingException("Failed to get resource at " + path); } File destZip = File.createTempFile("resources_", ".zip"); LOGGER.debug("Created temporary zip at " + destZip.getAbsolutePath()); LOGGER.debug("Resource protocol is " + dirURL.getProtocol()); if ("file".equals(dirURL.getProtocol())) { mapFolderFromResources(dirURL, destZip); } else { mapFolderFromJar(dirURL, destZip); } return destZip; } catch (Exception e) { throw new ResourcePackagingException(e); } } ResourceFolder(String path); File toZip(); }
ResourceFolder { public File toZip() { LOGGER.debug("Zipping resource folder " + path); try { URL dirURL = Resources.getResource(path); if (dirURL == null) { throw new ResourcePackagingException("Failed to get resource at " + path); } File destZip = File.createTempFile("resources_", ".zip"); LOGGER.debug("Created temporary zip at " + destZip.getAbsolutePath()); LOGGER.debug("Resource protocol is " + dirURL.getProtocol()); if ("file".equals(dirURL.getProtocol())) { mapFolderFromResources(dirURL, destZip); } else { mapFolderFromJar(dirURL, destZip); } return destZip; } catch (Exception e) { throw new ResourcePackagingException(e); } } ResourceFolder(String path); File toZip(); static final Logger LOGGER; }