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.JInternalFrame;
30 import org.testng.annotations.AfterMethod;
31 import org.testng.annotations.BeforeClass;
32 import org.testng.annotations.BeforeMethod;
33 import org.testng.annotations.Test;
35 import junit.extensions.PA;
37 public class PDBFTSPanelTest
40 @BeforeClass(alwaysRun = true)
41 public void setUpJvOptionPane()
43 JvOptionPane.setInteractiveMode(false);
44 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
47 @BeforeMethod(alwaysRun = true)
48 public void setUp() throws Exception
52 @AfterMethod(alwaysRun = true)
53 public void tearDown() throws Exception
57 @Test(groups = { "Functional" })
58 public void populateCmbSearchTargetOptionsTest()
60 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
61 assertTrue(searchPanel.getCmbSearchTarget().getItemCount() > 0);
62 searchPanel.populateCmbSearchTargetOptions();
65 @Test(groups = { "Functional" })
66 public void testDecodeSearchTerm()
68 String expectedString = "1xyz OR text:2xyz OR text:3xyz";
69 String outcome = PDBFTSPanel.decodeSearchTerm("1xyz:A;2xyz;3xyz",
71 // System.out.println("1 >>>>>>>>>>> " + outcome);
72 assertEquals(expectedString, outcome);
74 expectedString = "1xyz";
75 outcome = PDBFTSPanel.decodeSearchTerm("1xyz", "text");
76 // System.out.println("2 >>>>>>>>>>> " + outcome);
77 assertEquals(expectedString, outcome);
80 @Test(groups = { "Functional" })
81 public void testgetPDBIdwithSpecifiedChain()
84 String expectedString = "1xyz:A";
85 String outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("1xyz",
87 System.out.println("1 >>>>>>>>>>> " + outcome);
88 assertEquals(expectedString, outcome);
90 expectedString = "2xyz";
91 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz",
93 System.out.println("2 >>>>>>>>>>> " + outcome);
94 assertEquals(expectedString, outcome);
96 expectedString = "2xyz:A";
97 outcome = PDBFTSPanel.getPDBIdwithSpecifiedChain("2xyz", "2xyz:A");
98 System.out.println("3 >>>>>>>>>>> " + outcome);
99 assertEquals(expectedString, outcome);
102 @Test(groups = { "External" }, timeOut = 8000)
103 public void txt_search_ActionPerformedTest()
105 PDBFTSPanel searchPanel = new PDBFTSPanel(null);
106 JInternalFrame mainFrame = searchPanel.getMainFrame();
107 // JComboBox<String> txt_search = PA.gsearchPanel.getTxtSearch();
109 assertTrue(mainFrame.getTitle().length() == 20);
110 assertTrue(mainFrame.getTitle()
111 .equalsIgnoreCase("PDB Sequence Fetcher"));
112 PA.invokeMethod(PA.getValue(searchPanel, "txt_search"), "setSelectedItem(java.lang.String)", "ABC");
113 // txt_search.setSelectedItem("ABC");
116 // wait for web-service to handle response
118 } catch (InterruptedException e)
122 assertTrue(mainFrame.getTitle().length() > 20);
123 assertTrue(!mainFrame.getTitle().equalsIgnoreCase(
124 "PDB Sequence Fetcher"));