Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ws.gui

File Jws2ParamView.java

 

Coverage histogram

../../../img/srcFileCovDistChart1.png
53% of files have more coverage

Code metrics

20
46
5
1
175
125
18
0.39
9.2
5
3.6

Classes

Class Line # Actions
Jws2ParamView 48 46 18 69
0.0281690142.8%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ws.gui;
22   
23    import jalview.bin.Cache;
24    import jalview.gui.JvOptionPane;
25    import jalview.gui.WsJobParameters;
26    import jalview.util.MessageManager;
27    import jalview.ws.jabaws.JalviewJabawsTestUtils;
28    import jalview.ws.jws2.JabaPreset;
29    import jalview.ws.jws2.Jws2Discoverer;
30    import jalview.ws.jws2.jabaws2.Jws2Instance;
31   
32    import java.awt.BorderLayout;
33    import java.awt.event.WindowAdapter;
34    import java.awt.event.WindowEvent;
35    import java.util.ArrayList;
36    import java.util.Iterator;
37    import java.util.List;
38   
39    import javax.swing.JFrame;
40    import javax.swing.JPanel;
41   
42    import org.testng.annotations.BeforeClass;
43    import org.testng.annotations.Test;
44   
45    import compbio.metadata.Preset;
46    import compbio.metadata.PresetManager;
47   
 
48    public class Jws2ParamView
49    {
50   
 
51  0 toggle @BeforeClass(alwaysRun = true)
52    public void setUpJvOptionPane()
53    {
54  0 JvOptionPane.setInteractiveMode(false);
55  0 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
56    }
57   
58    /**
59    * which services to test
60    */
61    public static List<String> serviceTests = new ArrayList<String>();
62   
63    /**
64    * which presets to test for services
65    */
66    public static List<String> presetTests = new ArrayList<String>();
 
67  1 toggle static
68    {
69  1 serviceTests.add("AAConWS".toLowerCase());
70    }
71   
72    public static Jws2Discoverer disc = null;
73   
 
74  0 toggle @BeforeClass(alwaysRun = true)
75    public static void setUpBeforeClass() throws Exception
76    {
77  0 Cache.loadProperties("test/jalview/io/testProps.jvprops");
78  0 Cache.initLogger();
79  0 disc = JalviewJabawsTestUtils.getJabawsDiscoverer();
80    }
81   
82    /**
83    * This test marked Interactive as it appears to need user action to complete
84    * rather than hang
85    */
86   
 
87  0 toggle @Test(groups = { "Interactive" }, enabled = true)
88    public void testJws2Gui()
89    {
90  0 Iterator<String> presetEnum = presetTests.iterator();
91  0 for (Jws2Instance service : disc.getServices())
92    {
93  0 if (serviceTests.size() == 0
94    || serviceTests.contains(service.serviceType.toLowerCase()))
95    {
96  0 List<Preset> prl = null;
97  0 Preset pr = null;
98  0 if (presetEnum.hasNext())
99    {
100  0 PresetManager prman = service.getPresets();
101  0 if (prman != null)
102    {
103  0 pr = prman.getPresetByName(presetEnum.next());
104  0 if (pr == null)
105    {
106    // just grab the last preset.
107  0 prl = prman.getPresets();
108    }
109    }
110    }
111    else
112    {
113  0 PresetManager prman = service.getPresets();
114  0 if (prman != null)
115    {
116  0 prl = prman.getPresets();
117    }
118    }
119  0 Iterator<Preset> en = (prl == null) ? null : prl.iterator();
120  0 while (en != null && en.hasNext())
121    {
122  0 if (en != null)
123    {
124  0 if (!en.hasNext())
125    {
126  0 en = prl.iterator();
127    }
128  0 pr = en.next();
129    }
130  0 WsJobParameters pgui = new WsJobParameters(service,
131    new JabaPreset(service, pr));
132  0 JFrame jf = new JFrame(MessageManager.formatMessage(
133    "label.ws_parameters_for",
134    new String[] { service.getActionText() }));
135  0 jf.setSize(700, 800);
136  0 JPanel cont = new JPanel(new BorderLayout());
137  0 pgui.validate();
138  0 cont.setPreferredSize(pgui.getPreferredSize());
139  0 cont.add(pgui, BorderLayout.CENTER);
140  0 jf.setLayout(new BorderLayout());
141  0 jf.add(cont, BorderLayout.CENTER);
142  0 jf.validate();
143   
144  0 final Thread thr = Thread.currentThread();
145   
146    /*
147    * This seems to need a user to manually inspect / test / close the
148    * GUI for each service tested. Not standalone JUnit.
149    */
150  0 jf.addWindowListener(new WindowAdapter()
151    {
 
152  0 toggle @Override
153    public void windowClosing(WindowEvent e)
154    {
155  0 thr.interrupt();
156    }
157    });
158  0 jf.setVisible(true);
159  0 boolean inter = false;
160  0 while (!inter)
161    {
162  0 try
163    {
164  0 Thread.sleep(10 * 1000);
165    } catch (InterruptedException e)
166    {
167  0 inter = true;
168    }
169    }
170  0 jf.dispose();
171    }
172    }
173    }
174    }
175    }