use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class FileView method setOutput.
private void setOutput(boolean needToZip, File file, HttpServletResponse response) throws IOException {
ServletOutputStream out = response.getOutputStream();
if (needToZip) {
new ZipUtil().zip(file, out, Deflater.NO_COMPRESSION);
} else {
IOUtils.copy(new FileInputStream(file), out);
}
out.flush();
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class DatabaseFixture method copyH2Db.
public void copyH2Db(String oldDb) throws IOException {
File h2DbDir = new File(tmpDb, "h2db");
if (h2DbDir.exists()) {
h2DbDir.delete();
h2DbDir.mkdirs();
}
new ZipUtil().unzip(new File(templatesDir(), oldDb), h2DbDir);
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsZipTest method setUp.
@Before
public void setUp() throws Exception {
temporaryFolder.create();
systemEnvironment = mock(SystemEnvironment.class);
File bundledPluginsDir = temporaryFolder.newFolder("plugins-bundled");
expectedZipPath = temporaryFolder.newFile("go-plugins-all.zip").getAbsolutePath();
externalPluginsDir = temporaryFolder.newFolder("plugins-external");
when(systemEnvironment.get(SystemEnvironment.PLUGIN_FRAMEWORK_ENABLED)).thenReturn(true);
when(systemEnvironment.get(PLUGIN_GO_PROVIDED_PATH)).thenReturn(bundledPluginsDir.getAbsolutePath());
when(systemEnvironment.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn(externalPluginsDir.getAbsolutePath());
when(systemEnvironment.get(ALL_PLUGINS_ZIP_PATH)).thenReturn(expectedZipPath);
pluginsZip = new PluginsZip(systemEnvironment, new ZipUtil());
FileUtils.writeStringToFile(new File(bundledPluginsDir, "bundled1.jar"), "Bundled1");
FileUtils.writeStringToFile(new File(bundledPluginsDir, "bundled2.jar"), "Bundled2");
FileUtils.writeStringToFile(new File(externalPluginsDir, "external1.jar"), "External1");
FileUtils.writeStringToFile(new File(externalPluginsDir, "external2.jar"), "External2");
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsZipTest method shouldFailGracefullyWhenExternalFileCannotBeRead.
@Test(expected = FileAccessRightsCheckException.class)
public void shouldFailGracefullyWhenExternalFileCannotBeRead() throws Exception {
File bundledPluginsDir = temporaryFolder.newFolder("plugins-bundled-ext");
SystemEnvironment systemEnvironmentFail = mock(SystemEnvironment.class);
when(systemEnvironmentFail.get(SystemEnvironment.PLUGIN_FRAMEWORK_ENABLED)).thenReturn(true);
when(systemEnvironmentFail.get(PLUGIN_GO_PROVIDED_PATH)).thenReturn(bundledPluginsDir.getAbsolutePath());
when(systemEnvironmentFail.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn("");
when(systemEnvironmentFail.get(ALL_PLUGINS_ZIP_PATH)).thenReturn("");
FileUtils.writeStringToFile(new File(bundledPluginsDir, "bundled1.jar"), "Bundled1");
PluginsZip pluginsZipFail = new PluginsZip(systemEnvironmentFail, new ZipUtil());
pluginsZipFail.create();
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PackageLevelClassWithPublicInnerClass method explodeBundleIntoDirectory.
private File explodeBundleIntoDirectory(ZipInputStream src, String destinationDir) throws IOException, URISyntaxException {
File destinationPluginBundleLocation = new File(TMP_DIR, destinationDir);
destinationPluginBundleLocation.mkdirs();
new ZipUtil().unzip(src, destinationPluginBundleLocation);
return destinationPluginBundleLocation;
}
Aggregations