View Javadoc

1   package it.com.atlassian.rest.restart;
2   
3   import com.atlassian.rest.jersey.client.WebResourceFactory;
4   import com.sun.jersey.api.client.UniformInterfaceException;
5   import org.junit.Test;
6   
7   import static com.atlassian.rest.jersey.client.WebResourceFactory.LATEST;
8   import static com.atlassian.rest.jersey.client.WebResourceFactory.REST_VERSION;
9   import static com.atlassian.rest.jersey.client.WebResourceFactory.REST_VERSION_2;
10  import static javax.ws.rs.core.Response.Status.UNAUTHORIZED;
11  import static org.junit.Assert.assertEquals;
12  
13  public class RestartPluginTest
14  {
15      @Test
16      public void testGetAnonymousHelloWorldWhenNotAuthenticated()
17      {
18          assertGetAnonymousHelloWorldWhenNotAuthenticated(REST_VERSION, "Hello Anonymous World");
19          assertGetAnonymousHelloWorldWhenNotAuthenticated(REST_VERSION_2, "Goodbye Anonymous World");
20          WebResourceFactory.anonymous(REST_VERSION).path("restart").post();
21          assertGetAnonymousHelloWorldWhenNotAuthenticated(REST_VERSION, "Hello Anonymous World");
22          assertGetAnonymousHelloWorldWhenNotAuthenticated(REST_VERSION_2, "Goodbye Anonymous World");
23          assertGetAnonymousHelloWorldWhenNotAuthenticated(LATEST, "Goodbye Anonymous World");
24      }
25  
26      private void assertGetAnonymousHelloWorldWhenNotAuthenticated(final String version, final String expected)
27      {
28          assertEquals(expected, WebResourceFactory.anonymous(version).path("helloworld").path("anonymous").get(String.class));
29      }
30  
31  
32  }