* @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());
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 {
}
}
}
- 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);
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;
/**
* 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);
}
}