com.silverpeas.web
Class ResourceGettingTest<T extends TestResources>

java.lang.Object
  extended by com.sun.jersey.test.framework.JerseyTest
      extended by com.silverpeas.web.RESTWebServiceTest<T>
          extended by com.silverpeas.web.ResourceGettingTest<T>
Type Parameters:
T -
All Implemented Interfaces:
WebResourceTesting

public abstract class ResourceGettingTest<T extends TestResources>
extends RESTWebServiceTest<T>
implements WebResourceTesting

Unit tests on the getting of a resource in Silverpeas through a REST web service. This class is an abstract one and it implements some tests that are redondant over all web resources in Silverpeas (about authorization failure, authentication failure, ...)


Field Summary
 
Fields inherited from class com.silverpeas.web.RESTWebServiceTest
CONTEXT_NAME
 
Fields inherited from interface com.silverpeas.web.WebResourceTesting
HTTP_SESSIONKEY
 
Constructor Summary
ResourceGettingTest(String webServicePackage, String springContext)
           
 
Method Summary
static javax.ws.rs.core.MediaType asMediaType(javax.ws.rs.core.MediaType mediaType)
           
<C> C
getAt(String uri, Class<C> c)
          Gets the web resource at the specified URI as an instance of the specified class.
<C> C
getAt(String uri, javax.ws.rs.core.MediaType mediaType, Class<C> c)
          Gets the web resource at the specified URI as an instance of the specified class in the way it is sent back by the web resource in the specified media type.
 void gettingAnUnexistingResource()
           
 void gettingAResourceByANonAuthenticatedUser()
           
 void gettingAResourceByAnUnauthorizedUser()
           
 void gettingAResourceWithAnExpiredSession()
           
static String withAsSessionKey(String sessionKey)
           
 
Methods inherited from class com.silverpeas.web.RESTWebServiceTest
addComponentInstance, addTool, aUser, authenticate, buildQueryParametersFrom, denieAuthorizationToUsers, denieSpaceAuthorizationToUsers, getAccessControllerMock, getExistingComponentInstances, getExistingTools, getMockedSpaceAccessController, getOrganizationControllerMock, getPersonalizationServiceMock, getTestResources, prepareMockedResources, resource, setComponentAccessibilityToUser
 
Methods inherited from class com.sun.jersey.test.framework.JerseyTest
client, configure, getBaseURI, getClient, getClientFactory, getPort, getTestContainerFactory, setClientFactory, setTestContainerFactory, setUp, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.silverpeas.web.WebResourceTesting
anUnexistingResourceURI, aResource, aResourceURI, getSessionKey, getWebEntityClass
 

Constructor Detail

ResourceGettingTest

public ResourceGettingTest(String webServicePackage,
                           String springContext)
See Also:
RESTWebServiceTest.RESTWebServiceTest(java.lang.String, java.lang.String)
Method Detail

withAsSessionKey

public static String withAsSessionKey(String sessionKey)

asMediaType

public static javax.ws.rs.core.MediaType asMediaType(javax.ws.rs.core.MediaType mediaType)

getAt

public <C> C getAt(String uri,
                   Class<C> c)
Gets the web resource at the specified URI as an instance of the specified class. The state of the resource sent back by the web resource is expected to be in JSON.

Type Parameters:
C - the type of the resource to return.
Parameters:
uri - the URI identifying uniquely the resource. the uri can be compound of a query string (starts at ?).
c - the class of which the returned resource should be an instance.
Returns:
the web entity representing the resource at the specified URI.

getAt

public <C> C getAt(String uri,
                   javax.ws.rs.core.MediaType mediaType,
                   Class<C> c)
Gets the web resource at the specified URI as an instance of the specified class in the way it is sent back by the web resource in the specified media type.

Type Parameters:
C - the type of the resource to return.
Parameters:
uri - the URI identifying uniquely the resource. the uri can be compound of a query string (starts at ?).
mediaType - the expected media type in which the returned resource state is encoded.
c - the class of which the returned resource should be an instance.
Returns:
the web entity representing the resource at the specified URI.

gettingAResourceByANonAuthenticatedUser

public void gettingAResourceByANonAuthenticatedUser()

gettingAResourceWithAnExpiredSession

public void gettingAResourceWithAnExpiredSession()

gettingAResourceByAnUnauthorizedUser

public void gettingAResourceByAnUnauthorizedUser()

gettingAnUnexistingResource

public void gettingAnUnexistingResource()


Copyright © 2016 Silverpeas. All Rights Reserved.