/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.ws.gui;
-import static org.junit.Assert.*;
+import java.util.Locale;
+
+import jalview.bin.Cache;
+import jalview.bin.Console;
+import jalview.gui.JvOptionPane;
import jalview.gui.WsJobParameters;
+import jalview.util.MessageManager;
import jalview.ws.jabaws.JalviewJabawsTestUtils;
import jalview.ws.jws2.JabaPreset;
import jalview.ws.jws2.Jws2Discoverer;
import jalview.ws.jws2.jabaws2.Jws2Instance;
import java.awt.BorderLayout;
+import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
-import java.awt.event.WindowListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.swing.JFrame;
import javax.swing.JPanel;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
-import compbio.metadata.Option;
-import compbio.metadata.Parameter;
import compbio.metadata.Preset;
import compbio.metadata.PresetManager;
public class Jws2ParamView
{
+
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
/**
* which services to test
*/
public static List<String> presetTests = new ArrayList<String>();
static
{
- serviceTests.add("AAConWS".toLowerCase());
+ serviceTests.add("AAConWS".toLowerCase(Locale.ROOT));
}
public static Jws2Discoverer disc = null;
- @BeforeClass
+ @BeforeClass(alwaysRun = true)
public static void setUpBeforeClass() throws Exception
{
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
+ Console.initLogger();
disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
-
}
- @Test
+ /**
+ * This test marked Interactive as it appears to need user action to complete
+ * rather than hang
+ */
+
+ @Test(groups = { "Interactive" }, enabled = true)
public void testJws2Gui()
{
- Jws2Instance lastserv = null;
Iterator<String> presetEnum = presetTests.iterator();
for (Jws2Instance service : disc.getServices())
{
- lastserv = service;
- if (serviceTests.size() == 0
- || serviceTests.contains(service.serviceType.toLowerCase()))
+ if (serviceTests.size() == 0 || serviceTests
+ .contains(service.serviceType.toLowerCase(Locale.ROOT)))
{
- if (lastserv != null)
+ List<Preset> prl = null;
+ Preset pr = null;
+ if (presetEnum.hasNext())
{
- List<Preset> prl = null;
- Preset pr = null;
- if (presetEnum.hasNext())
+ PresetManager prman = service.getPresets();
+ if (prman != null)
{
- PresetManager prman = lastserv.getPresets();
- if (prman != null)
+ pr = prman.getPresetByName(presetEnum.next());
+ if (pr == null)
{
- pr = prman.getPresetByName(presetEnum.next());
- if (pr == null)
- {
- // just grab the last preset.
- prl = prman.getPresets();
- }
+ // just grab the last preset.
+ prl = prman.getPresets();
}
}
- else
+ }
+ else
+ {
+ PresetManager prman = service.getPresets();
+ if (prman != null)
{
- PresetManager prman = lastserv.getPresets();
- if (prman != null)
- {
- prl = prman.getPresets();
- }
+ prl = prman.getPresets();
}
- Iterator<Preset> en = (prl == null) ? null : prl.iterator();
- while (en != null && en.hasNext())
+ }
+ Iterator<Preset> en = (prl == null) ? null : prl.iterator();
+ while (en != null && en.hasNext())
+ {
+ if (en != null)
{
- if (en != null)
+ if (!en.hasNext())
{
- if (!en.hasNext())
- {
- en = prl.iterator();
- }
- pr = en.next();
- }
- {
- System.out.println("Testing opts dupes for "
- + lastserv.getUri() + " : "
- + lastserv.getActionText() + ":" + pr.getName());
- List<Option> rg = lastserv.getRunnerConfig().getOptions();
- for (Option o : rg)
- {
- try
- {
- Option cpy = jalview.ws.jws2.ParameterUtils.copyOption(o);
- } catch (Exception e)
- {
- System.err.println("Failed to copy " + o.getName());
- e.printStackTrace();
- } catch (Error e)
- {
- System.err.println("Failed to copy " + o.getName());
- e.printStackTrace();
- }
- }
- }
- {
- System.out.println("Testing param dupes:");
- List<Parameter> rg = lastserv.getRunnerConfig()
- .getParameters();
- for (Parameter o : rg)
- {
- try
- {
- Parameter cpy = jalview.ws.jws2.ParameterUtils
- .copyParameter(o);
- } catch (Exception e)
- {
- System.err.println("Failed to copy " + o.getName());
- e.printStackTrace();
- } catch (Error e)
- {
- System.err.println("Failed to copy " + o.getName());
- e.printStackTrace();
- }
- }
+ en = prl.iterator();
}
+ pr = en.next();
+ }
+ WsJobParameters pgui = new WsJobParameters(service,
+ new JabaPreset(service, pr));
+ JFrame jf = new JFrame(MessageManager
+ .formatMessage("label.ws_parameters_for", new String[]
+ { service.getActionText() }));
+ jf.setSize(700, 800);
+ JPanel cont = new JPanel(new BorderLayout());
+ pgui.validate();
+ cont.setPreferredSize(pgui.getPreferredSize());
+ cont.add(pgui, BorderLayout.CENTER);
+ jf.setLayout(new BorderLayout());
+ jf.add(cont, BorderLayout.CENTER);
+ jf.validate();
+
+ final Thread thr = Thread.currentThread();
+
+ /*
+ * This seems to need a user to manually inspect / test / close the
+ * GUI for each service tested. Not standalone JUnit.
+ */
+ jf.addWindowListener(new WindowAdapter()
+ {
+ @Override
+ public void windowClosing(WindowEvent e)
{
- System.out.println("Testing param write:");
- List<String> writeparam = null, readparam = null;
- try
- {
- writeparam = jalview.ws.jws2.ParameterUtils
- .writeParameterSet(
- pr.getArguments(lastserv.getRunnerConfig()),
- " ");
- System.out.println("Testing param read :");
- List<Option> pset = jalview.ws.jws2.ParameterUtils
- .processParameters(writeparam,
- lastserv.getRunnerConfig(), " ");
- readparam = jalview.ws.jws2.ParameterUtils
- .writeParameterSet(pset, " ");
- Iterator<String> o = pr.getOptions().iterator(), s = writeparam
- .iterator(), t = readparam.iterator();
- boolean failed = false;
- while (s.hasNext() && t.hasNext())
- {
- String on = o.next(), sn = s.next(), st = t.next();
- if (!sn.equals(st))
- {
- System.out.println("Original was " + on
- + " Phase 1 wrote " + sn + "\tPhase 2 wrote "
- + st);
- failed = true;
- }
- }
- if (failed)
- {
- System.out.println("Original parameters:\n"
- + pr.getOptions());
- System.out.println("Wrote parameters in first set:\n"
- + writeparam);
- System.out.println("Wrote parameters in second set:\n"
- + readparam);
-
- }
- } catch (Exception e)
- {
- e.printStackTrace();
- }
+ thr.interrupt();
}
- WsJobParameters pgui = new WsJobParameters(lastserv,
- new JabaPreset(lastserv, pr));
- JFrame jf = new JFrame("Parameters for "
- + lastserv.getActionText());
- JPanel cont = new JPanel(new BorderLayout());
- pgui.validate();
- cont.setPreferredSize(pgui.getPreferredSize());
- cont.add(pgui, BorderLayout.CENTER);
- jf.setLayout(new BorderLayout());
- jf.add(cont, BorderLayout.CENTER);
- jf.validate();
- final Thread thr = Thread.currentThread();
- jf.addWindowListener(new WindowListener()
+ });
+ jf.setVisible(true);
+ boolean inter = false;
+ while (!inter)
+ {
+ try
{
-
- public void windowActivated(WindowEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void windowClosed(WindowEvent e)
- {
- }
-
- public void windowClosing(WindowEvent e)
- {
- thr.interrupt();
-
- }
-
- public void windowDeactivated(WindowEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void windowDeiconified(WindowEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void windowIconified(WindowEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- public void windowOpened(WindowEvent e)
- {
- // TODO Auto-generated method stub
-
- }
-
- });
- jf.setVisible(true);
- boolean inter = false;
- while (!inter)
+ Thread.sleep(10 * 1000);
+ } catch (InterruptedException e)
{
- try
- {
- Thread.sleep(10000);
- } catch (Exception e)
- {
- inter = true;
- }
- ;
+ inter = true;
}
- jf.dispose();
}
+ jf.dispose();
}
}
}