use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class UrlBasedArtifactsRepositoryTest method setUp.
@Before
public void setUp() throws Exception {
artifactFolder = TestFileUtil.createTempFolder("artifact_folder");
tempFile = TestFileUtil.createTestFile(artifactFolder, "file.txt");
console = new TestStreamConsumer();
artifactsRepository = new UrlBasedArtifactsRepository(httpService, "http://baseurl/artifacts/", "http://baseurl/properties/", new ZipUtil());
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class DownloadDirCommandExecutorTest method downloadDirWithChecksum.
@Test
public void downloadDirWithChecksum() throws Exception {
File folder = TestFileUtil.createTempFolder("log");
Files.write(Paths.get(folder.getPath(), "a"), "content for a".getBytes());
Files.write(Paths.get(folder.getPath(), "b"), "content for b".getBytes());
File zip = new ZipUtil().zip(folder, TestFileUtil.createUniqueTempFile(folder.getName()), Deflater.NO_COMPRESSION);
httpService.setupDownload("http://far.far.away/log.zip", zip);
httpService.setupDownload("http://far.far.away/log.zip.md5", "s/log/a=524ebd45bd7de3616317127f6e639bd6\ns/log/b=83c0aa3048df233340203c74e8a93d7d");
runBuild(downloadDir(map("url", "http://far.far.away/log.zip", "dest", "dest", "src", "s/log", "checksumUrl", "http://far.far.away/log.zip.md5")), Passed);
File dest = new File(sandbox, "dest");
assertThat(console.output(), containsString(String.format("Saved artifact to [%s] after verifying the integrity of its contents", dest.getPath())));
assertThat(FileUtil.readContentFromFile(new File(dest, "log/a")), is("content for a"));
assertThat(FileUtil.readContentFromFile(new File(dest, "log/b")), is("content for b"));
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class FetchArtifactBuilderTest method setUp.
@Before
public void setUp() throws Exception {
File folder = TestFileUtil.createTempFolder("log");
File consolelog = new File(folder, "console.log");
folder.mkdirs();
consolelog.createNewFile();
zip = new ZipUtil().zip(folder, TestFileUtil.createUniqueTempFile(folder.getName()), Deflater.NO_COMPRESSION);
toClean.add(folder);
toClean.add(zip);
dest = new File("dest");
dest.mkdirs();
toClean.add(dest);
clock = new TestingClock();
publisher = new StubGoPublisher();
checksumFileHandler = mock(ChecksumFileHandler.class);
urlService = mock(URLService.class);
downloadAction = mock(DownloadAction.class);
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class DefaultPluginJarChangeListener method explodePluginJarToBundleDir.
void explodePluginJarToBundleDir(File file, File location) {
try {
wipePluginBundleDirectory(location);
ZipUtil zipUtil = new ZipUtil();
zipUtil.unzip(file, location);
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to copy plugin jar %s to bundle location %s", file, location), e);
}
}
use of com.thoughtworks.go.util.ZipUtil in project gocd by gocd.
the class PluginsZipTest method shouldFailGracefullyWhenBundledFileCannotBeRead.
@Test(expected = FileAccessRightsCheckException.class)
public void shouldFailGracefullyWhenBundledFileCannotBeRead() throws Exception {
SystemEnvironment systemEnvironmentFail = mock(SystemEnvironment.class);
when(systemEnvironmentFail.get(SystemEnvironment.PLUGIN_FRAMEWORK_ENABLED)).thenReturn(true);
when(systemEnvironmentFail.get(PLUGIN_GO_PROVIDED_PATH)).thenReturn("");
when(systemEnvironmentFail.get(PLUGIN_EXTERNAL_PROVIDED_PATH)).thenReturn(externalPluginsDir.getAbsolutePath());
when(systemEnvironmentFail.get(ALL_PLUGINS_ZIP_PATH)).thenReturn("");
FileUtils.writeStringToFile(new File(externalPluginsDir, "external1.jar"), "External1");
PluginsZip pluginsZipFail = new PluginsZip(systemEnvironmentFail, new ZipUtil());
pluginsZipFail.create();
}
Aggregations