Commit e310757e authored by Roman Shevchenko's avatar Roman Shevchenko
Browse files

[tests] migrating to Compressor API

parent 975c5ce4
Showing with 5 additions and 23 deletions
+5 -23
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.io.impl
import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.vfs.CharsetToolkit
import com.intellij.util.io.Compressor
import com.intellij.util.io.DirectoryContentBuilder
import com.intellij.util.io.DirectoryContentSpec
import com.intellij.util.io.ZipUtil
import org.junit.Assert.*
import java.io.BufferedOutputStream
import java.io.File
import java.io.IOException
import java.util.*
import java.util.zip.ZipOutputStream
/**
* @author nik
*/
sealed class DirectoryContentSpecImpl : DirectoryContentSpec {
}
sealed class DirectoryContentSpecImpl : DirectoryContentSpec
abstract class DirectorySpecBase : DirectoryContentSpecImpl() {
protected val children: LinkedHashMap<String, DirectoryContentSpecImpl> = LinkedHashMap<String, DirectoryContentSpecImpl>()
protected val children: LinkedHashMap<String, DirectoryContentSpecImpl> = LinkedHashMap()
fun addChild(name: String, spec: DirectoryContentSpecImpl) {
if (name in children) {
......@@ -77,9 +61,7 @@ class ZipSpec : DirectorySpecBase() {
val contentDir = FileUtil.createTempDirectory("zip-content", null, false)
try {
generateInDirectory(contentDir)
ZipOutputStream(BufferedOutputStream(target.outputStream())).use {
ZipUtil.addDirToZipRecursively(it, null, contentDir, "", null, null)
}
Compressor.Zip(target).use { it.addDirectory(contentDir) }
}
finally {
FileUtil.delete(contentDir)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment