added two tests to ensure a vamsasArchive is readable and accessible as a Jar File.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Sep 2007 10:01:18 +0000 (10:01 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Tue, 18 Sep 2007 10:01:18 +0000 (10:01 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@469 be28352e-c001-0410-b1a7-c7978e42abec

src/uk/ac/vamsas/test/simpleclient/VamsasArchive.java

index 7154361..52dec7e 100644 (file)
@@ -2,6 +2,8 @@ package uk.ac.vamsas.test.simpleclient;
 
 import java.io.File;
 import java.io.ObjectOutputStream;
+import java.io.RandomAccessFile;
+import java.util.jar.JarFile;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -98,6 +100,25 @@ public class VamsasArchive {
         av = new File(args[0]);
       else
         av = new File("test/vamsas.zip");
+      try {
+        RandomAccessFile raf = new RandomAccessFile(av, "r");
+        raf.readByte();
+        raf.close();
+      } catch (Exception f)
+      {
+        log.info("Couldn't random access file archive "+av, f);
+      }
+      try {
+       JarFile jf = new JarFile(av, true, JarFile.OPEN_READ);
+        if (jf.getEntry("vamsasDocument.xml")!=null)
+        {
+          log.info("Valid archive "+av);
+        }
+        jf.close();
+      } catch (Exception f)
+      {
+        log.info("Couldn't access jar archive "+av, f);
+      }
       log.info("Opening archive "+av);
       uk.ac.vamsas.client.simpleclient.VamsasArchive varchive = new uk.ac.vamsas.client.simpleclient.VamsasArchive(av, true);