Search in sources :

Example 21 with ZipUtil

use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.

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

Example 22 with ZipUtil

use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.

the class DirHandler method handle.

public void handle(InputStream stream) throws IOException {
    ZipInputStream zipInputStream = new ZipInputStream(stream);
    LOG.info(format("[Agent Fetch Artifact] Downloading from '%s' to '%s'. Will read from Socket stream to compute MD5 and write to file", srcFile, destOnAgent.getAbsolutePath()));
    long before = System.currentTimeMillis();
    new ZipUtil(new ZipUtil.ZipEntryHandler() {

        public void handleEntry(ZipEntry entry, InputStream stream) throws IOException {
            LOG.info(format("[Agent Fetch Artifact] Downloading a directory from '%s' to '%s'. Handling the entry: '%s'", srcFile, destOnAgent.getAbsolutePath(), entry.getName()));
            new ChecksumValidator(artifactMd5Checksums).validate(getSrcFilePath(entry), md5Hex(stream), checksumValidationPublisher);
        }
    }).unzip(zipInputStream, destOnAgent);
    LOG.info(format("[Agent Fetch Artifact] Downloading a directory from '%s' to '%s'. Took: %sms", srcFile, destOnAgent.getAbsolutePath(), System.currentTimeMillis() - before));
}
Also used : ZipInputStream(java.util.zip.ZipInputStream) ZipUtil(com.thoughtworks.go.util.ZipUtil) ZipInputStream(java.util.zip.ZipInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) ChecksumValidator(com.thoughtworks.go.validation.ChecksumValidator)

Example 23 with ZipUtil

use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.

the class LocalhostWithLargeDataSets method unzipDatabaseFile.

private static File unzipDatabaseFile(File dbDir) throws IOException {
    ZipUtil unzipUtil = new ZipUtil();
    String dataFileName = "5000pipelinesx4stagesx5buildplans.script";
    File srcZip = new File(dbDir, dataFileName + ".zip");
    unzipUtil.unzip(srcZip, dbDir);
    File unzipped = new File(dbDir, dataFileName);
    return unzipped;
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File)

Example 24 with ZipUtil

use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.

the class CommandRepositoryInitializerIntegrationTest method getZippedCommandRepo.

private File getZippedCommandRepo(final String versionText) throws Exception {
    File dir = TestFileUtil.createTempFolder("default");
    File versionFile = TestFileUtil.createTestFile(dir, "version.txt");
    FileUtils.writeStringToFile(versionFile, versionText);
    TestFileUtil.createTestFile(dir, "snippet.xml");
    File zipFile = TestFileUtil.createTempFile("defaultCommandSnippets.zip");
    new ZipUtil().zipFolderContents(dir, zipFile);
    return zipFile;
}
Also used : ZipUtil(com.thoughtworks.go.util.ZipUtil) File(java.io.File)

Example 25 with ZipUtil

use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.

the class CommandRepositoryInitializerIntegrationTest method setUp.

@Before
public void setUp() {
    tempFiles = new TempFiles();
    initializer = new CommandRepositoryInitializer(new SystemEnvironment(), new ZipUtil(), null);
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ZipUtil(com.thoughtworks.go.util.ZipUtil) TempFiles(com.thoughtworks.go.util.TempFiles) Before(org.junit.Before)

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