Package org.xwiki.test.ui
Class TestUtils.RestTestUtils
- java.lang.Object
-
- org.xwiki.test.ui.TestUtils.RestTestUtils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestUtils.RestTestUtils.ResourceAPI
-
Field Summary
Fields Modifier and Type Field Description static Boolean
ELEMENTS_ENCODED
static Map<org.xwiki.model.EntityType,TestUtils.RestTestUtils.ResourceAPI>
RESOURCES_MAP
static String
urlPrefix
-
Constructor Summary
Constructors Constructor Description RestTestUtils(TestUtils testUtils)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(org.xwiki.rest.model.jaxb.Object obj)
Add a new object.org.apache.commons.httpclient.methods.EntityEnclosingMethod
add(org.xwiki.rest.model.jaxb.Object obj, boolean release)
Add a new object.void
attachFile(org.xwiki.model.reference.EntityReference reference, Object is, boolean failIfExists)
URI
createUri(Object resourceUri, Map<String,Object[]> queryParams, Object... elements)
void
delete(org.xwiki.model.reference.EntityReference reference)
void
deleteAttachement(org.xwiki.model.reference.EntityReference reference)
void
deletePage(String space, String page)
void
deletePage(String space, String page, Locale locale)
org.apache.commons.httpclient.methods.DeleteMethod
executeDelete(Object resourceUri, Object... elements)
org.apache.commons.httpclient.methods.DeleteMethod
executeDelete(Object resourceUri, Map<String,Object[]> queryParams, Object... elements)
org.apache.commons.httpclient.methods.GetMethod
executeGet(Object resourceUri, Object... elements)
org.apache.commons.httpclient.methods.GetMethod
executeGet(Object resourceUri, Map<String,Object[]> queryParams, Object... elements)
org.apache.commons.httpclient.methods.GetMethod
executeGet(Object resourceURI, org.xwiki.model.reference.EntityReference reference)
org.apache.commons.httpclient.methods.GetMethod
executeGet(org.xwiki.model.reference.EntityReference reference)
org.apache.commons.httpclient.methods.PostMethod
executePost(Object resourceUri, Object restObject, Object... elements)
org.apache.commons.httpclient.methods.PostMethod
executePost(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements)
org.apache.commons.httpclient.methods.PutMethod
executePut(Object resourceUri, Object restObject, Object... elements)
org.apache.commons.httpclient.methods.PutMethod
executePut(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements)
boolean
exists(org.xwiki.model.reference.EntityReference reference)
<T> T
get(Object resourceURI, boolean failIfNotFound)
<T> T
get(Object resourceURI, org.xwiki.model.reference.EntityReference reference)
Return object model of the passed reference with the passed resource URI.<T> T
get(Object resourceURI, org.xwiki.model.reference.EntityReference reference, boolean failIfNotFound)
Return object model of the passed reference with the passed resource URI or null if none could be found.<T> T
get(org.xwiki.model.reference.EntityReference reference)
Return object model of the passed reference.<T> T
get(org.xwiki.model.reference.EntityReference reference, boolean failIfNotFound)
Return object model of the passed reference or null if none could be found.String
getBaseURL()
byte[]
getBuffer(String resourceUri, Map<String,Object[]> queryParams, Object... elements)
InputStream
getInputStream(String resourceUri, Map<String,?> queryParams, Object... elements)
static org.xwiki.rest.model.jaxb.Property
getProperty(String name, org.xwiki.rest.model.jaxb.Object preferencesObject, boolean create)
<T> T
getResource(String resourceUri, Map<String,Object[]> queryParams, Object... elements)
Class<?>
getResourceAPI(org.xwiki.model.reference.EntityReference reference)
protected javax.ws.rs.core.UriBuilder
getUriBuilder(Class<?> resource)
javax.ws.rs.core.UriBuilder
getUriBuilder(Object resourceUri, Map<String,Object[]> queryParams)
static org.xwiki.rest.model.jaxb.Object
object(String className)
org.xwiki.rest.model.jaxb.Object
object(org.xwiki.model.reference.EntityReference parentReference, String className)
org.xwiki.rest.model.jaxb.Object
object(org.xwiki.model.reference.EntityReference parentReference, String className, int number)
org.xwiki.rest.model.jaxb.Page
page(org.xwiki.model.reference.EntityReference reference)
InputStream
postInputStream(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements)
InputStream
postRESTInputStream(Object resourceUri, Object restObject, Object... elements)
static org.xwiki.rest.model.jaxb.Property
property(String name, Object value)
org.apache.commons.httpclient.methods.EntityEnclosingMethod
save(org.xwiki.rest.model.jaxb.Page page, boolean release, int... expectedCodes)
void
save(org.xwiki.rest.model.jaxb.Page page, int... expectedCodes)
Add or update.void
savePage(org.xwiki.model.reference.EntityReference reference)
void
savePage(org.xwiki.model.reference.EntityReference reference, String content, String title)
void
savePage(org.xwiki.model.reference.EntityReference reference, String content, String syntaxId, String title, String parentFullPageName)
void
setURLPrefix(String newURLPrefix)
Used when running in a docker container for example and thus when we need a REST URL pointing to a host different than the TestUTils baseURL which is used inside the Selenium docker container and is thus different from a REST URL used outside of any container and that needs to call XWiki running inside a container...Object[]
toElements(org.xwiki.model.reference.EntityReference reference)
Object[]
toElements(org.xwiki.rest.model.jaxb.Object obj, boolean onlyDocument)
protected Object[]
toElements(org.xwiki.rest.model.jaxb.Page page)
static String
toPropertyString(Object value)
<T> T
toResource(InputStream is)
protected InputStream
toResourceInputStream(Object restObject)
void
update(org.xwiki.rest.model.jaxb.Object obj)
Fail if the object does not exist.org.apache.commons.httpclient.methods.EntityEnclosingMethod
update(org.xwiki.rest.model.jaxb.Object obj, boolean release)
Fail if the object does not exist.
-
-
-
Field Detail
-
ELEMENTS_ENCODED
public static final Boolean ELEMENTS_ENCODED
-
RESOURCES_MAP
public static final Map<org.xwiki.model.EntityType,TestUtils.RestTestUtils.ResourceAPI> RESOURCES_MAP
-
urlPrefix
public static String urlPrefix
-
-
Constructor Detail
-
RestTestUtils
public RestTestUtils(TestUtils testUtils)
-
-
Method Detail
-
object
public static org.xwiki.rest.model.jaxb.Object object(String className)
- Since:
- 7.3M1
-
property
public static org.xwiki.rest.model.jaxb.Property property(String name, Object value)
- Since:
- 7.3M1
-
getBaseURL
public String getBaseURL()
-
setURLPrefix
public void setURLPrefix(String newURLPrefix)
Used when running in a docker container for example and thus when we need a REST URL pointing to a host different than the TestUTils baseURL which is used inside the Selenium docker container and is thus different from a REST URL used outside of any container and that needs to call XWiki running inside a container... ;)- Since:
- 10.9
-
toElements
protected Object[] toElements(org.xwiki.rest.model.jaxb.Page page)
-
toElements
public Object[] toElements(org.xwiki.rest.model.jaxb.Object obj, boolean onlyDocument)
-
toElements
public Object[] toElements(org.xwiki.model.reference.EntityReference reference)
-
save
public void save(org.xwiki.rest.model.jaxb.Page page, int... expectedCodes) throws Exception
Add or update.- Throws:
Exception
-
save
public org.apache.commons.httpclient.methods.EntityEnclosingMethod save(org.xwiki.rest.model.jaxb.Page page, boolean release, int... expectedCodes) throws Exception
- Throws:
Exception
-
page
public org.xwiki.rest.model.jaxb.Page page(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.3M1
-
object
public org.xwiki.rest.model.jaxb.Object object(org.xwiki.model.reference.EntityReference parentReference, String className)
- Since:
- 9.8RC1
-
object
public org.xwiki.rest.model.jaxb.Object object(org.xwiki.model.reference.EntityReference parentReference, String className, int number)
- Since:
- 9.8RC1
-
savePage
public void savePage(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
savePage
public void savePage(org.xwiki.model.reference.EntityReference reference, String content, String title) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
savePage
public void savePage(org.xwiki.model.reference.EntityReference reference, String content, String syntaxId, String title, String parentFullPageName) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
add
public void add(org.xwiki.rest.model.jaxb.Object obj) throws Exception
Add a new object.- Throws:
Exception
-
add
public org.apache.commons.httpclient.methods.EntityEnclosingMethod add(org.xwiki.rest.model.jaxb.Object obj, boolean release) throws Exception
Add a new object.- Throws:
Exception
-
update
public void update(org.xwiki.rest.model.jaxb.Object obj) throws Exception
Fail if the object does not exist.- Throws:
Exception
-
update
public org.apache.commons.httpclient.methods.EntityEnclosingMethod update(org.xwiki.rest.model.jaxb.Object obj, boolean release) throws Exception
Fail if the object does not exist.- Throws:
Exception
-
delete
public void delete(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
-
deletePage
public void deletePage(String space, String page, Locale locale) throws Exception
- Throws:
Exception
- Since:
- 9.0RC1
-
attachFile
public void attachFile(org.xwiki.model.reference.EntityReference reference, Object is, boolean failIfExists) throws Exception
- Throws:
Exception
- Since:
- 8.0M1
-
deleteAttachement
public void deleteAttachement(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
-
exists
public boolean exists(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
-
get
public <T> T get(org.xwiki.model.reference.EntityReference reference) throws Exception
Return object model of the passed reference. Fail if none could be found.- Throws:
Exception
- Since:
- 7.3
-
get
public <T> T get(org.xwiki.model.reference.EntityReference reference, boolean failIfNotFound) throws Exception
Return object model of the passed reference or null if none could be found.- Throws:
Exception
- Since:
- 8.0M1
-
getResourceAPI
public Class<?> getResourceAPI(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
- Since:
- 9.0RC1
-
get
public <T> T get(Object resourceURI, org.xwiki.model.reference.EntityReference reference) throws Exception
Return object model of the passed reference with the passed resource URI. Fail if none could be found.- Throws:
Exception
- Since:
- 8.0M1
-
get
public <T> T get(Object resourceURI, org.xwiki.model.reference.EntityReference reference, boolean failIfNotFound) throws Exception
Return object model of the passed reference with the passed resource URI or null if none could be found.- Throws:
Exception
- Since:
- 8.0M1
-
get
public <T> T get(Object resourceURI, boolean failIfNotFound) throws Exception
- Throws:
Exception
-
getInputStream
public InputStream getInputStream(String resourceUri, Map<String,?> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
postRESTInputStream
public InputStream postRESTInputStream(Object resourceUri, Object restObject, Object... elements) throws Exception
- Throws:
Exception
-
postInputStream
public InputStream postInputStream(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
toResource
public <T> T toResource(InputStream is) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
toResourceInputStream
protected InputStream toResourceInputStream(Object restObject) throws javax.xml.bind.JAXBException
- Throws:
javax.xml.bind.JAXBException
-
executeGet
public org.apache.commons.httpclient.methods.GetMethod executeGet(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
- Since:
- 7.3
-
executeGet
public org.apache.commons.httpclient.methods.GetMethod executeGet(Object resourceURI, org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
- Since:
- 8.0M1
-
executeGet
public org.apache.commons.httpclient.methods.GetMethod executeGet(Object resourceUri, Object... elements) throws Exception
- Throws:
Exception
-
executeGet
public org.apache.commons.httpclient.methods.GetMethod executeGet(Object resourceUri, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
executePost
public org.apache.commons.httpclient.methods.PostMethod executePost(Object resourceUri, Object restObject, Object... elements) throws Exception
- Throws:
Exception
-
executePost
public org.apache.commons.httpclient.methods.PostMethod executePost(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
executePut
public org.apache.commons.httpclient.methods.PutMethod executePut(Object resourceUri, Object restObject, Object... elements) throws Exception
- Throws:
Exception
-
executePut
public org.apache.commons.httpclient.methods.PutMethod executePut(Object resourceUri, Object restObject, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
executeDelete
public org.apache.commons.httpclient.methods.DeleteMethod executeDelete(Object resourceUri, Object... elements) throws Exception
- Throws:
Exception
-
executeDelete
public org.apache.commons.httpclient.methods.DeleteMethod executeDelete(Object resourceUri, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
createUri
public URI createUri(Object resourceUri, Map<String,Object[]> queryParams, Object... elements)
-
getUriBuilder
public javax.ws.rs.core.UriBuilder getUriBuilder(Object resourceUri, Map<String,Object[]> queryParams)
-
getUriBuilder
protected javax.ws.rs.core.UriBuilder getUriBuilder(Class<?> resource)
-
getBuffer
public byte[] getBuffer(String resourceUri, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
getResource
public <T> T getResource(String resourceUri, Map<String,Object[]> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
getProperty
public static org.xwiki.rest.model.jaxb.Property getProperty(String name, org.xwiki.rest.model.jaxb.Object preferencesObject, boolean create)
-
-