From 74d80d8a0a48038556001a997da5f2aba29b841b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 25 Sep 2013 16:34:55 +0100 Subject: [PATCH] formatting --- test/jalview/ws/jabaws/RNAStructExportImport.java | 85 ++++++++++++++++++++- 1 file changed, 84 insertions(+), 1 deletion(-) diff --git a/test/jalview/ws/jabaws/RNAStructExportImport.java b/test/jalview/ws/jabaws/RNAStructExportImport.java index 4e407af..a2c361b 100644 --- a/test/jalview/ws/jabaws/RNAStructExportImport.java +++ b/test/jalview/ws/jabaws/RNAStructExportImport.java @@ -2,28 +2,38 @@ package jalview.ws.jabaws; import static org.junit.Assert.*; +import java.awt.Component; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Vector; +import javax.swing.JMenu; +import javax.swing.JMenuItem; + import jalview.api.AlignCalcManagerI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.gui.Jalview2XML; import jalview.io.AnnotationFile; import jalview.io.FormatAdapter; import jalview.io.StockholmFileTest; import jalview.ws.jws2.AADisorderClient; import jalview.ws.jws2.Jws2Discoverer; import jalview.ws.jws2.RNAalifoldClient; +import jalview.ws.jws2.SequenceAnnotationWSClient; +import jalview.ws.jws2.dm.JabaOption; import jalview.ws.jws2.jabaws2.Jws2Instance; +import jalview.ws.params.AutoCalcSetting; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; -public class RNAStructExportImport +import compbio.metadata.WrongParameterException; + +public class RNAStructExportImport { public static String testseqs = "examples/unfolded_RF00031.aln"; @@ -150,4 +160,77 @@ public class RNAStructExportImport + "\nCouldn't complete Annotation file roundtrip input/output/input test."); } + @Test + public void testRnaalifoldSettingsRecovery() + { + List opts = new ArrayList(); + for (compbio.metadata.Argument rg : (List) rnaalifoldws + .getRunnerConfig().getArguments()) + { + if (rg.getDescription().contains("emperature")) + { + try + { + rg.setValue("292"); + } catch (WrongParameterException q) + { + fail("Couldn't set the temperature parameter " + + q.getStackTrace()); + } + opts.add(rg); + } + if (rg.getDescription().contains("max")) + { + opts.add(rg); + } + } + alifoldClient = new RNAalifoldClient(rnaalifoldws, af, null, opts); + + af.getViewport().getCalcManager().startWorker(alifoldClient); + + do + { + try + { + Thread.sleep(50); + } catch (InterruptedException x) + { + } + ; + } while (af.getViewport().getCalcManager().isWorking()); + AutoCalcSetting oldacs = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId()); + String oldsettings = oldacs.getWsParamFile(); + // write out parameters + jalview.gui.AlignFrame nalf=null; + assertTrue("Couldn't write out the Jar file",new Jalview2XML(false).SaveAlignment(af, "testRnalifold_param.jar","trial parameter writeout")); + assertTrue("Couldn't read back the Jar file",(nalf = new Jalview2XML(false).LoadJalviewAlign("testRnalifold_param.jar"))!=null); + if (nalf!=null) + { + AutoCalcSetting acs = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId()); + assertTrue("Calc ID settings not recovered from viewport stash", acs.equals(oldacs)); + assertTrue("Serialised Calc ID settings not identical to those recovered from viewport stash", acs.getWsParamFile().equals(oldsettings)); + JMenu nmenu=new JMenu(); + new SequenceAnnotationWSClient().attachWSMenuEntry(nmenu, rnaalifoldws, af); + assertTrue("Couldn't get menu entry for service",nmenu.getItemCount()>0); + for (Component itm: nmenu.getMenuComponents()) + { + if (itm instanceof JMenuItem) + { + JMenuItem i = (JMenuItem) itm; + if (i.getText().equals(rnaalifoldws.getAlignAnalysisUI().getAAconToggle())) + { + i.doClick(); + break; + } + } + } + while (af.getViewport().isCalcInProgress()) + { + try { Thread.sleep(200); + } catch (Exception x) {}; + } + AutoCalcSetting acs2 = af.getViewport().getCalcIdSettingsFor(alifoldClient.getCalcId()); + assertTrue("Calc ID settings after recalculation has not been recovered.", acs2.getWsParamFile().equals(oldsettings)); + } + } } -- 1.7.10.2