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