How can I verify the content of a zip archiv?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2010
08:12 PM
03-22-2010
08:12 PM
How can I verify the content of a zip archiv?
Hi,
I need to verify the content of a zip archiv that is created by one of our applications.
I want to make sure that all files that are expected to be in the archiv are actually included.
I checked the slPacker object, but it does not support reading the content of an archiv.
Any ideas would be apprechiated.
hanks and regards,
-Carsten
I need to verify the content of a zip archiv that is created by one of our applications.
I want to make sure that all files that are expected to be in the archiv are actually included.
I checked the slPacker object, but it does not support reading the content of an archiv.
Any ideas would be apprechiated.
hanks and regards,
-Carsten
7 REPLIES 7
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2010
12:32 AM
03-23-2010
12:32 AM
One thing you could do is actually unzip the file and then use aqFileSystem, aqFile, and aqFolder to parse a list of the files in the destination directory and compare it to a known list (possibly a CSV file that you can reference using the DDT.CSVDriver). That would give you a means of checking it.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2010
04:59 AM
03-23-2010
04:59 AM
Hi Carsten,
To unzip an archive from script, you need to run the needed archiver with command-line parameters. After unzipping, you can get the contents of the archive (see the example below that uses the 7-Zip free archiver) and then analyze them.
function Test()
{
var contents = readArchive("C:\\file.zip");
for (i = 0; i < contents.length - 1; i++)
{
Log.Message(contents);
}
}
function readArchive(archive)
{
var folder = extractArchive(archive)
var list = slPacker.GetFileListFromFolder(folder);
var aFile = list.split(chr(13)+chr(10));
aqFileSystem.DeleteFolder(folder, true);
return aFile;
}
function extractArchive(archive)
{
var archiverExecutable = "\"C:\\Program Files (x86)\\7-Zip\\7z.exe\"";
var toFolder = "C:\\temp\\extracted\\";
var cmdLine = archiverExecutable + " x " + archive + " -o" + toFolder;
var WshShell = Sys.OleObject("WScript.Shell")
WshShell.Run(cmdLine, 5, true)
return toFolder;
}
-----
Alexander
Customer Care Manager
Alexander
Customer Care Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2010
01:45 AM
03-24-2010
01:45 AM
Hi Robert, hi Alex,
thanks a lot for your input!
With the code sample I was able to do the verification (I use Delphi script). Strangely, 7-zip did not like the zip file, but with WinRar I could do the same and had no problems expanding the zip.
Thanks again,
-Carsten
PS: Maybe you want to consider beefing up the spPacker object so working with zip-archives does not depend on 3rd party products.
thanks a lot for your input!
With the code sample I was able to do the verification (I use Delphi script). Strangely, 7-zip did not like the zip file, but with WinRar I could do the same and had no problems expanding the zip.
Thanks again,
-Carsten
PS: Maybe you want to consider beefing up the spPacker object so working with zip-archives does not depend on 3rd party products.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2010
09:40 PM
03-24-2010
09:40 PM
Hi Carsten,
Can you manually explore the contents of that file by using the 7-Zip file manager?
As for the slPacker object's functionality, we have an appropriate suggestion in our DB, and your post has increased its rating. Thank you.
-----
Alexander
Customer Care Manager
Alexander
Customer Care Manager
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2010
11:52 PM
03-24-2010
11:52 PM
Hello Carsten,
if you do not want to unpack the whole archive, you can also use the internal file listing of the archive. Most zip tools support creating this list (for 7-zip it is the command line switch -l). After creation, and piping it to a text file, you can parse the list or compare it to a reference listing.
You can also use a .NET Assembly for handling zip files via TestCompletes CLR Bridge, for example DotNetZip. This will offer you a lot routines for handling zip files and you do not need to handle external zip listing files.
Dirk
TC 7.52/8.70/9.20 Standard, DelphiScript
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2010
11:59 PM
03-24-2010
11:59 PM
Hi Alex,
no, the ZIP-file (created with VCL-zip from one of our apps) could not be opened by 7-zip in the explorer.
However, WinRar supports a similar command line interface and I could open the zip with WinRar without problems.
Thanks again,
- Carsten
no, the ZIP-file (created with VCL-zip from one of our apps) could not be opened by 7-zip in the explorer.
However, WinRar supports a similar command line interface and I could open the zip with WinRar without problems.
Thanks again,
- Carsten
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2010
01:05 AM
03-25-2010
01:05 AM
Hello Dirk,
thanks for your suggestion.
I try to design our tests with as little dependencies to external tools as possible. Also, I want to do as little coding in our tests as necessary and use keyword tests wherever possible. I have to explain the tests to non-developers, so the more tools and code I have the more complicated it gets.
In my optinion support for working with archives fits well into a test tool, so I hope AQA will improve on this so I don't depend on WinRar in the tests.
Also, I must admit that I am not very familiar with .Net / C# / VBScript but rather Delphi Script 😉
Thanks again for sharing your ideas,
- Carsten
thanks for your suggestion.
I try to design our tests with as little dependencies to external tools as possible. Also, I want to do as little coding in our tests as necessary and use keyword tests wherever possible. I have to explain the tests to non-developers, so the more tools and code I have the more complicated it gets.
In my optinion support for working with archives fits well into a test tool, so I hope AQA will improve on this so I don't depend on WinRar in the tests.
Also, I must admit that I am not very familiar with .Net / C# / VBScript but rather Delphi Script 😉
Thanks again for sharing your ideas,
- Carsten
