Search in sources :

Example 11 with ZipUtil

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());
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File) Test(org.junit.Test)

Example 12 with ZipUtil

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();
    }
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File) IOException(java.io.IOException)

Example 13 with ZipUtil

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);
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File)

Example 14 with ZipUtil

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;
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File)

Example 15 with ZipUtil

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.");
    }
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File)

Aggregations

ZipUtil (com.thoughtworks.go.util.ZipUtil)27 File (java.io.File)21 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)8 Before (org.junit.Before)7 Test (org.junit.Test)6 ZipInputStream (java.util.zip.ZipInputStream)5 ZipFile (java.util.zip.ZipFile)4 FileInputStream (java.io.FileInputStream)3 TempFiles (com.thoughtworks.go.util.TempFiles)2 IOException (java.io.IOException)2 TestStreamConsumer (com.thoughtworks.go.helper.TestStreamConsumer)1 PluginManager (com.thoughtworks.go.plugin.infra.PluginManager)1 ArtifactsDirHolder (com.thoughtworks.go.server.service.ArtifactsDirHolder)1 ServerVersion (com.thoughtworks.go.server.util.ServerVersion)1 ArtifactFolder (com.thoughtworks.go.server.web.ArtifactFolder)1 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)1 TestingClock (com.thoughtworks.go.util.TestingClock)1 URLService (com.thoughtworks.go.util.URLService)1 ChecksumValidator (com.thoughtworks.go.validation.ChecksumValidator)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1