Class FakeZipFactory
- java.lang.Object
-
- jetbrains.buildServer.serverSide.util.FakeZipFactory
-
- All Implemented Interfaces:
ZipFactory
public class FakeZipFactory extends Object implements ZipFactory
ZipFactory
implementation that stores only metrics of written data instead of data itsels. It can be useful for tests working with big data sets.- Author:
- Leonid Bushuev from JetBrains
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FakeZipFactory.FileInfo
-
Constructor Summary
Constructors Constructor Description FakeZipFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZipWriter
createZipArchive(String name)
Creates a zip archive.Map<String,FakeZipFactory.FileInfo>
getFiles()
boolean
isFileExist(String name)
Checks whether the file exists.ZipReader
openZipArchive(String name)
Opens an existent zip archive to read.void
rename(String sourceName, String targetName)
Renames or moves the file.void
setLevel(int level)
Sets the compression level for entries which areZipEntry.DEFLATED
.
-
-
-
Method Detail
-
createZipArchive
@NotNull public ZipWriter createZipArchive(@NotNull String name)
Description copied from interface:ZipFactory
Creates a zip archive.- Specified by:
createZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip writer.
-
openZipArchive
public ZipReader openZipArchive(String name)
Description copied from interface:ZipFactory
Opens an existent zip archive to read.- Specified by:
openZipArchive
in interfaceZipFactory
- Parameters:
name
- path and name of a zip file to create.- Returns:
- zip reader.
-
getFiles
public Map<String,FakeZipFactory.FileInfo> getFiles()
-
isFileExist
public boolean isFileExist(String name)
Description copied from interface:ZipFactory
Checks whether the file exists.- Specified by:
isFileExist
in interfaceZipFactory
- Parameters:
name
- file path and name.- Returns:
- exists.
-
rename
public void rename(String sourceName, String targetName) throws IOException
Description copied from interface:ZipFactory
Renames or moves the file.- Specified by:
rename
in interfaceZipFactory
- Parameters:
sourceName
- an existent file path and name to rename.targetName
- new path and name.- Throws:
IOException
- when couldn't rename.
-
setLevel
public void setLevel(int level)
Sets the compression level for entries which are
ZipEntry.DEFLATED
. The default setting isDeflater.DEFAULT_COMPRESSION
.This method only affects
ZipFactory.createZipArchive(String)
behaviour.- Specified by:
setLevel
in interfaceZipFactory
- Parameters:
level
- the compression level (0-9).- See Also:
ZipFactory.setLevel(int)
-
-