cc3a3db5295f6c4de7f1ab5ddf260d8a1fe635cc
[jalview.git] / test / jalview / ext / ensembl / EnsemblRestClientTest.java
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.ext.ensembl;
22
23 import static org.testng.Assert.assertTrue;
24
25 import jalview.datamodel.AlignmentI;
26
27 import java.net.MalformedURLException;
28 import java.net.URL;
29 import java.util.List;
30
31 import org.testng.annotations.BeforeMethod;
32 import org.testng.annotations.Test;
33
34 public class EnsemblRestClientTest
35 {
36   private EnsemblRestClient sf;
37
38   @Test(suiteName = "live")
39   public void testIsEnsemblAvailable()
40   {
41     boolean isAvailable = sf.isEnsemblAvailable();
42     if (isAvailable)
43     {
44       System.out.println("Ensembl is UP!");
45     }
46     else
47     {
48       System.err
49               .println("Ensembl is DOWN or unreachable ******************* BAD!");
50     }
51   }
52
53   @BeforeMethod(alwaysRun = true)
54   protected void setUp()
55   {
56     sf = new EnsemblRestClient()
57     {
58
59       @Override
60       public String getDbName()
61       {
62         return null;
63       }
64
65       @Override
66       public AlignmentI getSequenceRecords(String queries) throws Exception
67       {
68         return null;
69       }
70
71       @Override
72       protected URL getUrl(List<String> ids) throws MalformedURLException
73       {
74         return null;
75       }
76
77       @Override
78       protected boolean useGetRequest()
79       {
80         return false;
81       }
82
83       @Override
84       protected String getRequestMimeType(boolean b)
85       {
86         return null;
87       }
88
89       @Override
90       protected String getResponseMimeType()
91       {
92         return null;
93       }
94
95     };
96   }
97
98   @Test(groups = "Network")
99   public void testCheckEnsembl_overload()
100   {
101     for (int i = 0; i < 20; i++)
102     {
103       assertTrue(sf.checkEnsembl(), "Error on " + (i + 1) + "th ping");
104     }
105   }
106 }