JAL-1270 JUnit to TestNG refactoring
[jalview.git] / test / jalview / ws / rest / RestClientTest.java
1 package jalview.ws.rest;
2
3 import static org.testng.AssertJUnit.assertEquals;
4 import org.testng.annotations.Test;
5 import java.util.Vector;
6
7 import jalview.bin.Cache;
8
9 public class RestClientTest
10 {
11   /**
12    * Refactored 'as is' from main method
13    */
14   @Test
15   public void testGetRestClient()
16   {
17     /*
18      * Load test properties file (readonly) so as not to overwrite the real one
19      */
20     Cache.loadProperties("test/src/jalview/io/testProps.jvprops");
21
22     RestClient[] clients = RestClient.getRestClients();
23     System.out.println("Got " + clients.length + " clients.");
24     int i = 0;
25     Vector<String> urls = new Vector<String>();
26     for (RestClient cl : clients)
27     {
28       System.out.println("" + (++i) + ": " + cl.service.toString());
29       urls.add(cl.service.toString());
30     }
31     RestClient.setRsbsServices(urls);
32
33     RestClient[] restClients = RestClient.getRestClients();
34     assertEquals("", clients.length, restClients.length);
35
36     /*
37      * Check the two lists hold 'equal' (albeit different) objects. Ordering
38      * should be the same as getRestClients returns the list in the same order
39      * as setRsbsServices sets it.
40      */
41     for (i = 0; i < clients.length; i++)
42     {
43       /*
44        * RestServiceDescription.equals() compares numerous fields
45        */
46       assertEquals(clients[i].getRestDescription(),
47               restClients[i].getRestDescription());
48     }
49   }
50 }