com.atlassian.crowd.acceptance.tests.rest.service
Class RestCrowdServiceAcceptanceTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by com.atlassian.crowd.acceptance.tests.rest.service.RestCrowdServiceAcceptanceTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AuthenticationResourceTest, GroupsResourceTest, SearchResourceTest, TokenResourceTest, UsersResourceTest

public abstract class RestCrowdServiceAcceptanceTestCase
extends junit.framework.TestCase

All REST acceptance tests should subclass this class.


Field Summary
protected static String APPLICATION_NAME
           
protected static String APPLICATION_PASSWORD
           
protected static String ATTRIBUTES_RESOURCE
           
protected static String AUTHENTICATION_RESOURCE
           
protected static String GROUPS_RESOURCE
           
protected static String REST_SERVICE_NAME
           
protected static String SESSION_RESOURCE
           
protected static String USERS_RESOURCE
           
 
Constructor Summary
protected RestCrowdServiceAcceptanceTestCase(String name)
          Constructs a test case with the given name.
protected RestCrowdServiceAcceptanceTestCase(String name, RestServer restServer)
          Constructs a test case with the given name, using the given RestServer.
 
Method Summary
protected  UserEntity authenticateUser(String username, String password)
          Authenticate a user with the specified username and password.
protected  javax.ws.rs.core.UriBuilder getBaseUriBuilder()
          Returns the base URI of the REST service.
protected  com.sun.jersey.api.client.WebResource getRootWebResource(String applicationName, String password)
          Returns the "root" WebResource.
protected  com.sun.jersey.api.client.WebResource getWebResource(String applicationName, String password, URI uri)
          Returns the WebResource with the specified URI.
 void setRestServer(RestServer restServer)
          Sets the RestServer instance to test against.
 void setUp()
           
protected static String statusToString(javax.ws.rs.core.Response.Status status)
          Nicely formats a Status.
 void tearDown()
           
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

APPLICATION_NAME

protected static final String APPLICATION_NAME
See Also:
Constant Field Values

APPLICATION_PASSWORD

protected static final String APPLICATION_PASSWORD
See Also:
Constant Field Values

GROUPS_RESOURCE

protected static final String GROUPS_RESOURCE
See Also:
Constant Field Values

ATTRIBUTES_RESOURCE

protected static final String ATTRIBUTES_RESOURCE
See Also:
Constant Field Values

USERS_RESOURCE

protected static final String USERS_RESOURCE
See Also:
Constant Field Values

AUTHENTICATION_RESOURCE

protected static final String AUTHENTICATION_RESOURCE
See Also:
Constant Field Values

SESSION_RESOURCE

protected static final String SESSION_RESOURCE
See Also:
Constant Field Values

REST_SERVICE_NAME

protected static final String REST_SERVICE_NAME
See Also:
Constant Field Values
Constructor Detail

RestCrowdServiceAcceptanceTestCase

protected RestCrowdServiceAcceptanceTestCase(String name)
Constructs a test case with the given name.

Parameters:
name - the test name

RestCrowdServiceAcceptanceTestCase

protected RestCrowdServiceAcceptanceTestCase(String name,
                                             RestServer restServer)
Constructs a test case with the given name, using the given RestServer.

Parameters:
name - the test name
restServer - the RestServer
Method Detail

setUp

public void setUp()
           throws Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

setRestServer

public final void setRestServer(RestServer restServer)
Sets the RestServer instance to test against.

Parameters:
restServer - a RestServer

getBaseUriBuilder

protected javax.ws.rs.core.UriBuilder getBaseUriBuilder()
Returns the base URI of the REST service.

Returns:
UriBuilder

getRootWebResource

protected com.sun.jersey.api.client.WebResource getRootWebResource(String applicationName,
                                                                   String password)
Returns the "root" WebResource. This is the resource that's at the / of the crowd-rest-plugin plugin namespace.

Parameters:
applicationName - name of the application
password - password of the application
Returns:
root WebResource

getWebResource

protected com.sun.jersey.api.client.WebResource getWebResource(String applicationName,
                                                               String password,
                                                               URI uri)
Returns the WebResource with the specified URI.

Parameters:
applicationName - name of the application
password - password of the application
uri - URI of the resource
Returns:
WebResource

statusToString

protected static String statusToString(javax.ws.rs.core.Response.Status status)
Nicely formats a Status.

Parameters:
status - Status
Returns:
formatted string

authenticateUser

protected UserEntity authenticateUser(String username,
                                      String password)
Authenticate a user with the specified username and password.

Parameters:
username - username
password - password
Returns:
UserEntity
Throws:
com.sun.jersey.api.client.UniformInterfaceException - if the status of the HTTP response is greater than or equal to 300.


Copyright © 2012 Atlassian. All Rights Reserved.