use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class ZipArtifactCacheTest method shouldRecoverFromOldZipTmpFile.
@Test
public void shouldRecoverFromOldZipTmpFile() throws Exception {
File cacheDir = new File(folder, "cache/artifacts/" + JOB_FOLDERS);
cacheDir.mkdirs();
TestFileUtil.createTestFile(cacheDir, "dir.zip.tmp");
waitForCacheCreated();
assertThat(new File(cacheDir, "dir.zip.tmp"), not(exists()));
new ZipUtil().unzip(new File(cacheDir, "dir.zip"), cacheDir);
assertThat(new File(cacheDir, "dir/file1"), exists());
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class DevelopmentServer method main.
public static void main(String[] args) throws Exception {
copyDbFiles();
PropertyConfigurator.configureAndWatch(DevelopmentServer.class.getClassLoader().getResource("log4j.properties").getFile());
File webApp = new File("webapp");
if (!webApp.exists()) {
throw new RuntimeException("No webapp found in " + webApp.getAbsolutePath());
}
copyActivatorJarToClassPath();
SystemEnvironment systemEnvironment = new SystemEnvironment();
String chosenAppServer = System.getProperty(SystemEnvironment.APP_SERVER.propertyName());
if (chosenAppServer == null || chosenAppServer.trim().isEmpty()) {
systemEnvironment.set(SystemEnvironment.APP_SERVER, SystemEnvironment.JETTY9);
}
systemEnvironment.setProperty(GENERATE_STATISTICS, "true");
systemEnvironment.setProperty(SystemEnvironment.PARENT_LOADER_PRIORITY, "true");
systemEnvironment.setProperty(SystemEnvironment.CRUISE_SERVER_WAR_PROPERTY, webApp.getAbsolutePath());
systemEnvironment.set(SystemEnvironment.PLUGIN_LOCATION_MONITOR_INTERVAL_IN_SECONDS, 5);
systemEnvironment.set(SystemEnvironment.DEFAULT_PLUGINS_ZIP, "/plugins.zip");
//0 means reload when stale
systemEnvironment.setProperty(GoConstants.I18N_CACHE_LIFE, "0");
systemEnvironment.set(SystemEnvironment.GO_SERVER_MODE, "development");
setupPeriodicGC(systemEnvironment);
PropertyConfigurator.configureAndWatch("./properties/src/log4j.properties", 100L);
File pluginsDist = new File("../tw-go-plugins/dist/");
if (!pluginsDist.exists()) {
pluginsDist.mkdirs();
}
new ZipUtil().zipFolderContents(pluginsDist, new File(classpath(), "plugins.zip"));
GoServer server = new GoServer();
systemEnvironment.setProperty(GoConstants.USE_COMPRESSED_JAVASCRIPT, Boolean.toString(false));
try {
server.startServer();
String hostName = systemEnvironment.getListenHost();
if (hostName == null) {
hostName = "localhost";
}
System.out.println("Go server dashboard started on http://" + hostName + ":" + systemEnvironment.getServerPort());
System.out.println("* credentials: \"admin\" / \"badger\"");
} catch (Exception e) {
System.err.println("Failed to start Go server. Exception:");
e.printStackTrace();
}
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class MigrateHsqldbToH2 method backupOldDb.
private void backupOldDb(File dbDirectory, File oldHsql) throws IOException {
File backupFile = new File(dbDirectory, "hsqldb-upgrade-backup-" + dateString() + ".zip");
if (backupFile.exists()) {
bomb(BACKUP_ALREADY_EXISTS);
}
new ZipUtil().zip(oldHsql, backupFile, Deflater.DEFAULT_COMPRESSION);
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class DirHandlerTest method createZip.
private File createZip(String subDirectoryName) throws IOException {
File first = new File(artifactDest, "first");
FileUtils.writeStringToFile(first, "First File");
File second = new File(artifactDest, subDirectoryName + "/second");
FileUtils.writeStringToFile(second, "Second File");
new ZipUtil().zip(artifactDest, zip, 0);
return zip;
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class MigrateHsqldbToH2 method backupNewTemplateDb.
private void backupNewTemplateDb(File dbDirectory, File newDb) throws IOException {
File backup = new File(dbDirectory, "h2db-template-backup-" + dateString() + ".zip");
new ZipUtil().zip(newDb, backup, Deflater.DEFAULT_COMPRESSION);
deleteDirectory(newDb);
if (newDb.exists()) {
bomb("Database " + newDb + " could not be deleted.");
}
}
Aggregations