2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
21 package jalview.fts.service.pdb;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.gui.JvOptionPane;
28 import javax.swing.JComboBox;
29 import javax.swing.JInternalFrame;
31 import org.testng.annotations.AfterMethod;
32 import org.testng.annotations.BeforeClass;
33 import org.testng.annotations.BeforeMethod;
34 import org.testng.annotations.Test;
36 public class PDBFTSPanelTest
39 @BeforeClass(alwaysRun = true)
40 public void setUpJvOptionPane()
42 JvOptionPane.setInteractiveMode(false);
43 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
46 @BeforeMethod(alwaysRun = true)
47 public void setUp() throws Exception
51 @AfterMethod(alwaysRun = true)
52 public void tearDown() throws Exception
56 @Test(groups = { "Functional" })
57 public void populateCmbSearchTargetOptionsTest()
59 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
60 assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
61 searchPanel.populateCmbSearchTargetOptions();
64 @Test(groups = { "Functional" })
65 public void testDecodeSearchTerm()
67 String expectedString = "1xyz OR text:2xyz OR text:3xyz";
68 String outcome = PDBFTSPanel.decodeSearchTerm("1xyz:A;2xyz;3xyz",
70 // System.out.println("1 >>>>>>>>>>> " + outcome);
71 assertEquals(expectedString, outcome);
73 expectedString = "1xyz";
74 outcome = PDBFTSPanel.decodeSearchTerm("1xyz", "text");
75 // System.out.println("2 >>>>>>>>>>> " + outcome);
76 assertEquals(expectedString, outcome);
79 @Test(groups = { "Functional" })
80 public void testgetPDBIdwithSpecifiedChain()
83 String expectedString = "1xyz:A";
84 String outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("1xyz",
86 System.out.println("1 >>>>>>>>>>> " + outcome);
87 assertEquals(expectedString, outcome);
89 expectedString = "2xyz";
90 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz",
92 System.out.println("2 >>>>>>>>>>> " + outcome);
93 assertEquals(expectedString, outcome);
95 expectedString = "2xyz:A";
96 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz", "2xyz:A");
97 System.out.println("3 >>>>>>>>>>> " + outcome);
98 assertEquals(expectedString, outcome);
101 @Test(groups = { "External" }, timeOut = 8000)
102 public void txt_search_ActionPerformedTest()
104 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
105 JInternalFrame mainFrame = searchPanel.getMainFrame();
106 JComboBox<String> txt_search = searchPanel.getTxtSearch();
108 assertTrue(mainFrame.getTitle().length() == 20);
109 assertTrue(mainFrame.getTitle()
110 .equalsIgnoreCase("PDB Sequence Fetcher"));
111 txt_search.setSelectedItem("ABC");
114 // wait for web-service to handle response
116 } catch (InterruptedException e)
120 assertTrue(mainFrame.getTitle().length() > 20);
121 assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
122 "PDB Sequence Fetcher"));