本文整理了Java中com.thoughtworks.go.util.ZipUtil.<init>()
方法的一些代码示例,展示了ZipUtil.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil.<init>()
方法的具体详情如下:
包路径:com.thoughtworks.go.util.ZipUtil
类名称:ZipUtil
方法名:<init>
暂无
代码示例来源:origin: gocd/gocd
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();
}
代码示例来源:origin: gocd/gocd
@Autowired
public AnalyticsPluginAssetsService(AnalyticsExtension analyticsExtension, AnalyticsMetadataLoader metadataLoader) {
this.zipUtil = new ZipUtil();
this.analyticsExtension = analyticsExtension;
this.pluginAssetPaths = new HashMap<>();
metadataLoader.registerListeners(this);
metadataStore = AnalyticsMetadataStore.instance();
}
代码示例来源:origin: gocd/gocd
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);
}
}
代码示例来源:origin: gocd/gocd
public void handle(InputStream stream) throws IOException {
ZipInputStream zipInputStream = new ZipInputStream(stream);
LOG.info("[Agent Fetch Artifact] Downloading from '{}' to '{}'. Will read from Socket stream to compute MD5 and write to file", srcFile, destOnAgent.getAbsolutePath());
long before = System.currentTimeMillis();
new ZipUtil((entry, stream1) -> {
LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Handling the entry: '{}'", srcFile, destOnAgent.getAbsolutePath(), entry.getName());
new ChecksumValidator(artifactMd5Checksums).validate(getSrcFilePath(entry), md5Hex(stream1), checksumValidationPublisher);
}).unzip(zipInputStream, destOnAgent);
LOG.info("[Agent Fetch Artifact] Downloading a directory from '{}' to '{}'. Took: {}ms", srcFile, destOnAgent.getAbsolutePath(), System.currentTimeMillis() - before);
}
代码示例来源:origin: gocd/gocd
private File createZip(String subDirectoryName) throws IOException {
File first = new File(artifactDest, "first");
FileUtils.writeStringToFile(first, "First File", UTF_8);
File second = new File(artifactDest, subDirectoryName + "/second");
FileUtils.writeStringToFile(second, "Second File", UTF_8);
new ZipUtil().zip(artifactDest, zip, 0);
return zip;
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(List<Property> properties, List<String> consoleOuts, HttpService service) {
super(service, new URLService(), new ZipUtil());
this.properties = properties;
this.consoleOuts = consoleOuts;
}
代码示例来源:origin: gocd/gocd
private File createPluginBundle(String bundleName) throws IOException, URISyntaxException {
File destinationPluginBundleLocation = new File(tmpDir, bundleName);
destinationPluginBundleLocation.mkdirs();
URL resource = getClass().getClassLoader().getResource("defaultFiles/descriptor-aware-test-plugin.jar");
new ZipUtil().unzip(new File(resource.toURI()), destinationPluginBundleLocation);
return destinationPluginBundleLocation;
}
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(HttpService service) {
super(service, new URLService(), new ZipUtil());
properties = new ArrayList<>();
consoleOuts = new ArrayList<>();
}
代码示例来源:origin: gocd/gocd
private File explodeBundleIntoDirectory(ZipInputStream src, String destinationDir) throws IOException {
File destinationPluginBundleLocation = new File(tmpDir, destinationDir);
destinationPluginBundleLocation.mkdirs();
new ZipUtil().unzip(src, destinationPluginBundleLocation);
return destinationPluginBundleLocation;
}
代码示例来源:origin: gocd/gocd
@Before
public void setUp() throws Exception {
File folder = temporaryFolder.newFolder("log");
File consolelog = new File(folder, "console.log");
folder.mkdirs();
consolelog.createNewFile();
File uniqueTempFile = new File(folder, UUID.randomUUID().toString());
uniqueTempFile.createNewFile();
zip = new ZipUtil().zip(folder, uniqueTempFile, Deflater.NO_COMPRESSION);
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub() {
super(new HttpServiceStub(), new URLService(), new ZipUtil());
properties = new ArrayList<>();
consoleOuts = new ArrayList<>();
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(List<String> consoleOuts) {
super(new HttpServiceStub(), new URLService(), new ZipUtil());
this.properties = new ArrayList<>();
this.consoleOuts = consoleOuts;
}
代码示例来源:origin: gocd/gocd
@Before
public void setUp() throws Exception {
agentPluginsInitializer = new AgentPluginsInitializer(pluginManager, pluginJarLocationMonitor, new ZipUtil(), systemEnvironment);
directoryForUnzippedPlugins = setupUnzippedPluginsDirectoryStructure();
when(systemEnvironment.get(SystemEnvironment.AGENT_PLUGINS_PATH)).thenReturn(directoryForUnzippedPlugins.getAbsolutePath());
}
代码示例来源:origin: gocd/gocd
@Before
public void setUp() throws Exception {
temporaryFolder.create();
srcDir = temporaryFolder.newFolder("_test1");
destDir = temporaryFolder.newFolder("_test2");
emptyDir = new File(srcDir, "_emptyDir");
emptyDir.mkdir();
childDir1 = new File(srcDir, "_child1");
childDir1.mkdir();
file1 = new File(srcDir, "_file1");
FileUtils.writeStringToFile(file1, "_file1", UTF_8);
file2 = new File(childDir1, "_file2");
FileUtils.writeStringToFile(file2, "_file2", UTF_8);
zipUtil = new ZipUtil();
}
代码示例来源:origin: gocd/gocd
public GoArtifactsManipulatorStub(List<Property> properties, List<String> consoleOuts) {
super(new HttpServiceStub(), new URLService(), new ZipUtil());
this.properties = properties;
this.consoleOuts = consoleOuts;
}
代码示例来源:origin: gocd/gocd
private File explodeBundleIntoDirectory(ZipInputStream src, String destinationDir) throws IOException, URISyntaxException {
File destinationPluginBundleLocation = temporaryFolder.newFolder(destinationDir);
new ZipUtil().unzip(src, destinationPluginBundleLocation);
return destinationPluginBundleLocation;
}
}
代码示例来源:origin: gocd/gocd
@Before
public void setUp() throws Exception {
File folder = temporaryFolder.newFolder("log");
File consolelog = new File(folder, "console.log");
folder.mkdirs();
consolelog.createNewFile();
File uniqueTempFile = new File(folder, UUID.randomUUID().toString());
uniqueTempFile.createNewFile();
zip = new ZipUtil().zip(folder, uniqueTempFile, 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);
}
代码示例来源:origin: gocd/gocd
@Before
public void setUp() throws Exception {
artifactFolder = temporaryFolder.newFolder("artifact_folder");
tempFile = temporaryFolder.newFile("artifact_folder/file.txt");
FileUtils.writeStringToFile(tempFile, "some-random-junk", UTF_8);
console = new TestStreamConsumer();
artifactsRepository = new UrlBasedArtifactsRepository(httpService, "http://baseurl/artifacts/", "http://baseurl/properties/", new ZipUtil());
}
代码示例来源:origin: gocd/gocd
@Test
public void downloadDirWithChecksum() throws Exception {
File folder = temporaryFolder.newFolder("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, temporaryFolder.newFile("log.zip"), 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(FileUtils.readFileToString(new File(dest, "log/a"), UTF_8), is("content for a"));
assertThat(FileUtils.readFileToString(new File(dest, "log/b"), UTF_8), is("content for b"));
}
代码示例来源:origin: gocd/gocd
public SetupOfAgentPluginsFile(File pluginsZipFile) throws IOException {
this.pluginsZipFile = pluginsZipFile;
this.bundledPluginsDir = temporaryFolder.newFolder("bundled");
this.externalPluginsDir = temporaryFolder.newFolder("external");
this.dummyFileSoZipFileIsNotEmpty = temporaryFolder.newFile("dummy.txt");
this.zipUtil = new ZipUtil();
}
内容来源于网络,如有侵权,请联系作者删除!