debugging.
authorjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 15 Jan 2006 17:58:35 +0000 (17:58 +0000)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Sun, 15 Jan 2006 17:58:35 +0000 (17:58 +0000)
git-svn-id: https://svn.lifesci.dundee.ac.uk/svn/repository/trunk@133 be28352e-c001-0410-b1a7-c7978e42abec

src/org/vamsas/test/objects/Core.java
src/org/vamsas/test/simpleclient/ArchiveReader.java
src/org/vamsas/test/simpleclient/VamsasArchive.java

index 0bc3db5..66ac2c4 100644 (file)
@@ -57,6 +57,22 @@ public class Core {
    * @param args
    */
   public static void main(String[] args) {
+    
+    /**
+     * test constants and controlled vocab utils
+     */
+    System.out.println("VersionEntries.compare(invalid, ALPHA) returned "+VersionEntries.compare("invalid", VersionEntries.ALPHA_VERSION));
+    System.out.println("VersionEntries.compare(ALPHA, invalid) returned "+VersionEntries.compare(VersionEntries.ALPHA_VERSION, "invalid"));      
+    System.out.println("VersionEntries.compare(BETA, ALPHA) returned "+VersionEntries.compare(VersionEntries.BETA_VERSION,VersionEntries.ALPHA_VERSION));
+    System.out.println("VersionEntries.compare(ALPHA, BETA) returned "+VersionEntries.compare(VersionEntries.ALPHA_VERSION,VersionEntries.BETA_VERSION));
+    System.out.println("VersionEntries.compare(ALPHA, ALPHA) returned "+VersionEntries.compare(VersionEntries.ALPHA_VERSION,VersionEntries.ALPHA_VERSION));
+    System.out.println("VersionEntries.compare(invalid, invalid) returned "+VersionEntries.compare("invalid", "invalid"));
+    System.out.println("VersionEntries.latestVersion()="+VersionEntries.latestVersion()+
+        ", dict_aa="+SymbolDictionary.STANDARD_AA+", dict_na="+SymbolDictionary.STANDARD_NA);
+    /**
+     * Test utils and autogenerated object interfaces
+     */
+    
     VamsasDocument doc = DocumentStuff.newVamsasDocument(new VAMSAS[] { getDemoVamsas() }, 
         ProvenanceStuff.newProvenance("org.vamsas.objects.test.Core", "Created demo vamsasDocument"),
         VersionEntries.latestVersion());
index 8f461c3..f99bed8 100644 (file)
@@ -23,7 +23,7 @@ public class ArchiveReader {
       if (var.isValid()) {
         InputStreamReader vdoc = new InputStreamReader(var.getVamsasDocumentStream());
         VamsasDocument doc = VamsasDocument.unmarshal(vdoc);
-        if (ArchiveReports.reportDocument(doc, var)) {
+        if (ArchiveReports.reportDocument(doc, var, true)) {
           roots = doc.getVAMSAS();
         }
       } else {
@@ -41,7 +41,7 @@ public class ArchiveReader {
           }
         }
       }
-      if (!ArchiveReports.rootReport(roots))
+      if (!ArchiveReports.rootReport(roots, true))
         System.err.print(args[0]+" is not a valid vamsas archive.");
     } catch (Exception e) {
       e.printStackTrace(System.err);
index 53103c6..1e96cc9 100644 (file)
@@ -5,6 +5,8 @@ import java.io.File;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.vamsas.client.simpleclient.*;
 import org.vamsas.objects.core.VAMSAS;
 import org.vamsas.objects.core.VamsasDocument;
@@ -13,22 +15,41 @@ public class VamsasArchive {
   /**
    * test the org.vamsas.simpleclient.vamsasArchive class
    */
+  static Log log = LogFactory.getLog("org.vamsas.test.simpleclient.vamsasArchive");
+
   public static void main(String args[]) {
 
     try {
-      File av = new File(args[0]);
+      File av;
+      if (args.length>0)
+        av = new File(args[0]);
+      else
+        av = new File("test/vamsas.zip");
+      log.info("Opening archive "+av);
       org.vamsas.client.simpleclient.VamsasArchive varchive = new org.vamsas.client.simpleclient.VamsasArchive(av, true);
-      File backup = varchive.backupFile();
       
       VAMSAS[] roots = (VAMSAS[]) varchive.getOriginalRoots();
-      if (roots!=null)
-        ArchiveReports.rootReport(roots);
-      // do some stuff
       
+      if (roots!=null) {
+        log.info("Report on Original roots in archive:");
+        ArchiveReports.rootReport(roots, true);
+      }
+      log.info("Getting current vamsas document.");
+      VamsasDocument doc = varchive.getVamsasDocument();
+      ArchiveReports.reportDocument(doc, varchive.getOriginalArchiveReader(), true); // not modified document so references will still be valid
+      // do some stuff
+      log.info("Retrieving backup");
+      File backup = varchive.backupFile();
+      if (backup==null)
+        log.info(av+" is a New Archive.");
+      else 
+        log.info(av+" has been backed up as "+backup);
+      varchive.cancelArchive();
       if (backup!=null) {
-        System.out.println("Backup is : "+backup);
+        log.info("Backup "+backup+" is being deleted.");
+        backup.delete(); // tidy up
       }
-    } catch (Exception e) {
+      } catch (Exception e) {
       e.printStackTrace(System.err);
     }
   }