X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fws%2FSequenceFetcherTest.java;h=32afd5f7ab3beaa5a328e576e31fcdac3f676fc8;hb=58962a97c9819d186ce347072e8750dbcae16f0f;hp=d7058d022e99f821a5d7cc2e209937d7d55d17fd;hpb=3e16aae83055354f09b0f9560686d035a5f2e5aa;p=jalview.git
diff --git a/test/jalview/ws/SequenceFetcherTest.java b/test/jalview/ws/SequenceFetcherTest.java
index d7058d0..32afd5f 100644
--- a/test/jalview/ws/SequenceFetcherTest.java
+++ b/test/jalview/ws/SequenceFetcherTest.java
@@ -1,20 +1,50 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.ws;
+import jalview.analysis.CrossRef;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.SequenceI;
+import jalview.gui.JvOptionPane;
import jalview.ws.seqfetcher.ASequenceFetcher;
import jalview.ws.seqfetcher.DbSourceProxy;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
+import org.testng.annotations.BeforeClass;
+
public class SequenceFetcherTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
/**
* simple run method to test dbsources.
*
@@ -25,8 +55,6 @@ public class SequenceFetcherTest
// TODO: extracted from SequenceFetcher - convert to proper unit test with
// assertions
- AlignmentI ds = null;
- Vector noProds = new Vector();
String usage = "SequenceFetcher.main [-nodas] [ []]\n"
+ "With no arguments, all DbSources will be queried with their test Accession number.\n"
+ "With one argument, the argument will be resolved to one or more db sources and each will be queried with their test accession only.\n"
@@ -45,7 +73,7 @@ public class SequenceFetcherTest
{
List sps = new SequenceFetcher(withDas)
.getSourceProxy(argv[0]);
-
+
if (sps != null)
{
for (DbSourceProxy sp : sps)
@@ -53,8 +81,8 @@ public class SequenceFetcherTest
AlignmentI al = null;
try
{
- al = sp.getSequenceRecords(argv.length > 1 ? argv[1] : sp
- .getTestQuery());
+ testRetrieval(argv[0], sp,
+ argv.length > 1 ? argv[1] : sp.getTestQuery());
} catch (Exception e)
{
e.printStackTrace();
@@ -62,16 +90,6 @@ public class SequenceFetcherTest
+ (argv.length > 1 ? argv[1] : sp.getTestQuery())
+ " from " + argv[0] + "\nUsage: " + usage);
}
- SequenceI[] prod = al.getSequencesArray();
- if (al != null)
- {
- for (int p = 0; p < prod.length; p++)
- {
- System.out.println("Prod " + p + ": "
- + prod[p].getDisplayId(true) + " : "
- + prod[p].getDescription());
- }
- }
}
return;
}
@@ -96,139 +114,135 @@ public class SequenceFetcherTest
}
for (DbSourceProxy sp : sfetcher.getSourceProxy(db))
{
- System.out.println("Source: " + sp.getDbName() + " (" + db
- + "): retrieving test:" + sp.getTestQuery());
- AlignmentI al = null;
- try
+ testRetrieval(db, sp, sp.getTestQuery());
+ }
+ }
+
+ }
+
+ private static void testRetrieval(String db, DbSourceProxy sp,
+ String testQuery)
+ {
+ AlignmentI ds = null;
+ Vector