1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.gui; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import jalview.bin.Cache; |
26 |
|
import jalview.bin.Console; |
27 |
|
import jalview.gui.JvOptionPane; |
28 |
|
import jalview.gui.WsJobParameters; |
29 |
|
import jalview.util.MessageManager; |
30 |
|
import jalview.ws.jabaws.JalviewJabawsTestUtils; |
31 |
|
import jalview.ws.jws2.JabaPreset; |
32 |
|
import jalview.ws.jws2.Jws2Discoverer; |
33 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
34 |
|
|
35 |
|
import java.awt.BorderLayout; |
36 |
|
import java.awt.event.WindowAdapter; |
37 |
|
import java.awt.event.WindowEvent; |
38 |
|
import java.util.ArrayList; |
39 |
|
import java.util.Iterator; |
40 |
|
import java.util.List; |
41 |
|
|
42 |
|
import javax.swing.JFrame; |
43 |
|
import javax.swing.JPanel; |
44 |
|
|
45 |
|
import org.testng.annotations.BeforeClass; |
46 |
|
import org.testng.annotations.Test; |
47 |
|
|
48 |
|
import compbio.metadata.Preset; |
49 |
|
import compbio.metadata.PresetManager; |
50 |
|
|
|
|
| 2.8% |
Uncovered Elements: 69 (71) |
Complexity: 18 |
Complexity Density: 0.39 |
|
51 |
|
public class Jws2ParamView |
52 |
|
{ |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
54 |
0 |
@BeforeClass(alwaysRun = true)... |
55 |
|
public void setUpJvOptionPane() |
56 |
|
{ |
57 |
0 |
JvOptionPane.setInteractiveMode(false); |
58 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
59 |
|
} |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
|
public static List<String> serviceTests = new ArrayList<String>(); |
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
public static List<String> presetTests = new ArrayList<String>(); |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
1 |
static... |
71 |
|
{ |
72 |
1 |
serviceTests.add("AAConWS".toLowerCase(Locale.ROOT)); |
73 |
|
} |
74 |
|
|
75 |
|
public static Jws2Discoverer disc = null; |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
77 |
0 |
@BeforeClass(alwaysRun = true)... |
78 |
|
public static void setUpBeforeClass() throws Exception |
79 |
|
{ |
80 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
81 |
0 |
Console.initLogger(); |
82 |
0 |
disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
|
|
| 0% |
Uncovered Elements: 59 (59) |
Complexity: 14 |
Complexity Density: 0.36 |
|
90 |
0 |
@Test(groups = { "Interactive" }, enabled = true)... |
91 |
|
public void testJws2Gui() |
92 |
|
{ |
93 |
0 |
Iterator<String> presetEnum = presetTests.iterator(); |
94 |
0 |
for (Jws2Instance service : disc.getServices()) |
95 |
|
{ |
96 |
0 |
if (serviceTests.size() == 0 || serviceTests |
97 |
|
.contains(service.serviceType.toLowerCase(Locale.ROOT))) |
98 |
|
{ |
99 |
0 |
List<Preset> prl = null; |
100 |
0 |
Preset pr = null; |
101 |
0 |
if (presetEnum.hasNext()) |
102 |
|
{ |
103 |
0 |
PresetManager prman = service.getPresets(); |
104 |
0 |
if (prman != null) |
105 |
|
{ |
106 |
0 |
pr = prman.getPresetByName(presetEnum.next()); |
107 |
0 |
if (pr == null) |
108 |
|
{ |
109 |
|
|
110 |
0 |
prl = prman.getPresets(); |
111 |
|
} |
112 |
|
} |
113 |
|
} |
114 |
|
else |
115 |
|
{ |
116 |
0 |
PresetManager prman = service.getPresets(); |
117 |
0 |
if (prman != null) |
118 |
|
{ |
119 |
0 |
prl = prman.getPresets(); |
120 |
|
} |
121 |
|
} |
122 |
0 |
Iterator<Preset> en = (prl == null) ? null : prl.iterator(); |
123 |
0 |
while (en != null && en.hasNext()) |
124 |
|
{ |
125 |
0 |
if (en != null) |
126 |
|
{ |
127 |
0 |
if (!en.hasNext()) |
128 |
|
{ |
129 |
0 |
en = prl.iterator(); |
130 |
|
} |
131 |
0 |
pr = en.next(); |
132 |
|
} |
133 |
0 |
WsJobParameters pgui = new WsJobParameters(service, |
134 |
|
new JabaPreset(service, pr)); |
135 |
0 |
JFrame jf = new JFrame(MessageManager |
136 |
|
.formatMessage("label.ws_parameters_for", new String[] |
137 |
|
{ service.getActionText() })); |
138 |
0 |
jf.setSize(700, 800); |
139 |
0 |
JPanel cont = new JPanel(new BorderLayout()); |
140 |
0 |
pgui.validate(); |
141 |
0 |
cont.setPreferredSize(pgui.getPreferredSize()); |
142 |
0 |
cont.add(pgui, BorderLayout.CENTER); |
143 |
0 |
jf.setLayout(new BorderLayout()); |
144 |
0 |
jf.add(cont, BorderLayout.CENTER); |
145 |
0 |
jf.validate(); |
146 |
|
|
147 |
0 |
final Thread thr = Thread.currentThread(); |
148 |
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
0 |
jf.addWindowListener(new WindowAdapter() |
154 |
|
{ |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
155 |
0 |
@Override... |
156 |
|
public void windowClosing(WindowEvent e) |
157 |
|
{ |
158 |
0 |
thr.interrupt(); |
159 |
|
} |
160 |
|
}); |
161 |
0 |
jf.setVisible(true); |
162 |
0 |
boolean inter = false; |
163 |
0 |
while (!inter) |
164 |
|
{ |
165 |
0 |
try |
166 |
|
{ |
167 |
0 |
Thread.sleep(10 * 1000); |
168 |
|
} catch (InterruptedException e) |
169 |
|
{ |
170 |
0 |
inter = true; |
171 |
|
} |
172 |
|
} |
173 |
0 |
jf.dispose(); |
174 |
|
} |
175 |
|
} |
176 |
|
} |
177 |
|
} |
178 |
|
} |