Class TestUtils.RestTestUtils

  • Enclosing class:
    TestUtils

    public static class TestUtils.RestTestUtils
    extends Object
    Since:
    7.3M1
    • Constructor Detail

      • RestTestUtils

        public RestTestUtils​(TestUtils testUtils)
    • Method Detail

      • object

        public static org.xwiki.rest.model.jaxb.Object object​(String className)
        Since:
        7.3M1
      • toPropertyString

        public static String toPropertyString​(Object value)
        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
      • 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
      • 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
      • executePost

        public org.apache.commons.httpclient.methods.PostMethod executePost​(Object resourceUri,
                                                                            Object restObject,
                                                                            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
      • executeDelete

        public org.apache.commons.httpclient.methods.DeleteMethod executeDelete​(Object resourceUri,
                                                                                Object... elements)
                                                                         throws Exception
        Throws:
        Exception
      • getUriBuilder

        public javax.ws.rs.core.UriBuilder getUriBuilder​(Object resourceUri,
                                                         Map<String,​Object[]> queryParams)
      • getUriBuilder

        protected javax.ws.rs.core.UriBuilder getUriBuilder​(Class<?> resource)
      • getProperty

        public static org.xwiki.rest.model.jaxb.Property getProperty​(String name,
                                                                     org.xwiki.rest.model.jaxb.Object preferencesObject,
                                                                     boolean create)