Package org.xwiki.test.ui
Class TestUtils
- java.lang.Object
-
- org.xwiki.test.ui.TestUtils
-
public class TestUtils extends Object
Helper methods for testing, not related to a specific Page Object. Also made available to tests classes.- Since:
- 3.2M3
- Version:
- $Id: 246ff993085e9dc3b11660d02f0436dadf4011f5 $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
TestUtils.RestTestUtils
class
TestUtils.Session
This class represents all cookies stored in the browser.
-
Field Summary
Fields Modifier and Type Field Description static org.apache.commons.httpclient.UsernamePasswordCredentials
ADMIN_CREDENTIALS
static String
BASE_BIN_URL
Deprecated.since 7.3M1, usegetBaseBinURL()
insteadstatic String
BASE_REST_URL
Deprecated.since 7.3M1, usegetBaseURL()
insteadstatic String
BASE_URL
Deprecated.since 7.3M1, usegetBaseURL()
insteadstatic int[]
STATUS_ACCEPTED
static int[]
STATUS_CREATED
static int[]
STATUS_CREATED_ACCEPTED
static int[]
STATUS_NO_CONTENT
static int[]
STATUS_NO_CONTENT_NOT_FOUND
static int[]
STATUS_OK
static int[]
STATUS_OK_NOT_FOUND
static org.apache.commons.httpclient.UsernamePasswordCredentials
SUPER_ADMIN_CREDENTIALS
-
Constructor Summary
Constructors Constructor Description TestUtils()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassProperty(String space, String page, String propertyName, String propertyType)
void
addClassProperty(org.xwiki.model.reference.EntityReference reference, String propertyName, String propertyType)
void
addObject(String space, String page, String className, Object... properties)
void
addObject(String space, String page, String className, Map<String,?> properties)
void
addObject(org.xwiki.model.reference.EntityReference reference, String className, Object... properties)
void
addObject(org.xwiki.model.reference.EntityReference reference, String className, Map<String,?> properties)
void
addQueryStringEntry(StringBuilder builder, String key, Object value)
void
addQueryStringEntry(StringBuilder builder, String key, String value)
void
assertOnPage(String pageURL)
After successful completion of this function, you are guaranteed to be logged in as the given user and on the page passed in pageURL.void
assertOnPage(org.xwiki.model.reference.EntityReference reference)
Verify if the passed reference corresponds to the current page, independently of the wiki.static <M extends org.apache.commons.httpclient.HttpMethod>
MassertStatusCodes(M method, boolean release, int... expectedCodes)
static void
assertStatuses(int actualCode, int... expectedCodes)
void
attachFile(String space, String page, String name, File file, boolean failIfExists)
void
attachFile(String space, String page, String name, InputStream is, boolean failIfExists)
void
attachFile(String space, String page, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
void
attachFile(List<String> spaces, String page, String name, InputStream is, boolean failIfExists)
void
attachFile(List<String> spaces, String page, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
void
attachFile(org.xwiki.model.reference.EntityReference reference, Object is, boolean failIfExists)
void
attachFile(org.xwiki.model.reference.EntityReference pageReference, String name, InputStream is, boolean failIfExists)
void
attachFile(org.xwiki.model.reference.EntityReference pageReference, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
void
closeTab(String secondTabHandle)
void
createAdminUser()
Creates the Admin user and add it to the XWikiAdminGroup.ViewPage
createPage(String space, String page, String content, String title)
ViewPage
createPage(String space, String page, String content, String title, String syntaxId)
ViewPage
createPage(String space, String page, String content, String title, String syntaxId, String parentFullPageName)
ViewPage
createPage(List<String> spaces, String page, String content, String title)
ViewPage
createPage(List<String> spaces, String page, String content, String title, String syntaxId)
ViewPage
createPage(List<String> spaces, String page, String content, String title, String syntaxId, String parentFullPageName)
ViewPage
createPage(org.xwiki.model.reference.EntityReference reference, String content)
ViewPage
createPage(org.xwiki.model.reference.EntityReference reference, String content, String title)
ViewPage
createPage(org.xwiki.model.reference.EntityReference reference, String content, String title, String syntaxId)
ViewPage
createPage(org.xwiki.model.reference.EntityReference reference, String content, String title, String syntaxId, String parentFullPageName)
ViewPage
createPageWithAttachment(String space, String page, String content, String title, String attachmentName, InputStream attachmentData)
ViewPage
createPageWithAttachment(String space, String page, String content, String title, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
ViewPage
createPageWithAttachment(String space, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData)
ViewPage
createPageWithAttachment(String space, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
ViewPage
createPageWithAttachment(List<String> spaces, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
ViewPage
createPageWithAttachment(org.xwiki.model.reference.EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData)
ViewPage
createPageWithAttachment(org.xwiki.model.reference.EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials)
void
createUser(String username, String password, String redirectURL, Object... properties)
void
createUserAndLogin(String username, String password, Object... properties)
void
createUserAndLoginWithRedirect(String username, String password, String url, Object... properties)
void
deleteAttachement(org.xwiki.model.reference.EntityReference reference)
void
deleteAttachement(org.xwiki.model.reference.EntityReference pageReference, String filename)
void
deleteLatestVersion(String space, String page)
Delete the latest version from the history of a page, using the/deleteversions/
action.void
deleteObject(String space, String page, String className, int objectNumber)
void
deletePage(String space, String page)
void
deletePage(org.xwiki.model.reference.EntityReference reference)
void
deletePage(org.xwiki.model.reference.EntityReference reference, boolean affectChildren)
void
deleteSpace(String space)
Accesses the URL to delete the specified space.void
deleteSpace(org.xwiki.model.reference.EntityReference space)
Accesses the URL to delete the specified space.void
deleteVersion(String space, String page, String version)
Delete a specific version from the history of a page, using the/deleteversions/
action.void
deleteVersions(String space, String page, String v1, String v2)
Delete an interval of versions from the history of a page, using the/deleteversions/
action.void
disableSyntaxHighlighting()
Disable Syntax Highlighting.ClassEditPage
editClass(String space, String page)
ClassEditPage
editClass(org.xwiki.model.reference.DocumentReference reference)
Goes to a page in edit class mode.ObjectEditPage
editObjects(String space, String page)
String
escapeURL(String url)
Encodes a given string so that it may be used as a URL component.String
escapeXPath(String value)
Usage example:String
executeAndGetBodyAsString(org.xwiki.model.reference.EntityReference reference, Map<String,?> queryParameters)
protected org.apache.commons.httpclient.methods.DeleteMethod
executeDelete(String uri)
protected void
executeDelete(String uri, int... expectedCodes)
protected org.apache.commons.httpclient.methods.GetMethod
executeGet(String uri)
protected org.apache.commons.httpclient.methods.GetMethod
executeGet(String uri, boolean release, int... expectedCodes)
protected org.apache.commons.httpclient.methods.GetMethod
executeGet(String uri, int... expectedCodes)
protected org.apache.commons.httpclient.methods.PostMethod
executePost(String uri, InputStream content, String mediaType)
protected org.apache.commons.httpclient.methods.PostMethod
executePost(String uri, InputStream content, String mediaType, boolean release, int... expectedCodes)
protected org.apache.commons.httpclient.methods.PostMethod
executePost(String uri, InputStream content, String mediaType, int... expectedCodes)
protected org.apache.commons.httpclient.methods.PutMethod
executePut(String uri, InputStream content, String mediaType)
protected org.apache.commons.httpclient.methods.PutMethod
executePut(String uri, InputStream content, String mediaType, boolean release, int... expectedCodes)
protected void
executePut(String uri, InputStream content, String mediaType, int... expectedCodes)
void
forceGuestUser()
Forces the current user to be the Guest user by clearing all coookies.String
getAttachmentURL(String space, String page, String attachment)
String
getAttachmentURL(String space, String page, String attachment, String action)
String
getAttachmentURL(String space, String page, String attachment, String action, String queryString)
String
getBaseBinURL()
String
getBaseBinURL(String wiki)
String
getBaseURL()
XWikiExecutor
getCurrentExecutor()
String
getCurrentTabHandle()
String
getCurrentWiki()
org.apache.commons.httpclient.UsernamePasswordCredentials
getDefaultCredentials()
XWikiWebDriver
getDriver()
InputStream
getInputStream(String prefix, String path, Map<String,?> queryParams, Object... elements)
InputStream
getInputStream(String path, Map<String,?> queryParams)
String
getLoggedInUserName()
String
getMavenVersion()
String
getSecretToken()
Get the secret token used for CSRF protection.TestUtils.Session
getSession()
String
getString(String baseURL, String path, Map<String,?> queryParams)
Extended version to work in a docker context.String
getString(String path, Map<String,?> queryParams)
String
getURL(String space, String page)
Get the URL to view a page.String
getURL(String action, String[] path, String queryString)
String
getURL(String action, String[] path, String queryString, String fragment)
String
getURL(String space, String page, String action)
Get the URL of an action on a page.String
getURL(String space, String page, String action, String queryString)
Get the URL of an action on a page with a specified query string.String
getURL(String space, String page, String action, Map<String,?> queryParameters)
Get the URL of an action on a page with specified parameters.String
getURL(List<String> spaces, String page)
String
getURL(List<String> spaces, String page, String action, String queryString)
String
getURL(org.xwiki.model.reference.EntityReference reference)
String
getURL(org.xwiki.model.reference.EntityReference reference, String action, String queryString)
String
getURL(org.xwiki.model.reference.EntityReference reference, String action, String queryString, String fragment)
String
getURLFragment(org.xwiki.model.reference.EntityReference reference)
String
getURLToDeletePage(String space, String page)
String
getURLToDeletePage(org.xwiki.model.reference.EntityReference reference)
String
getURLToDeletePage(org.xwiki.model.reference.EntityReference reference, boolean affectChildren)
String
getURLToDeleteSpace(String space)
String
getURLToDeleteSpace(org.xwiki.model.reference.EntityReference space)
String
getURLToLoginAndGotoPage(String username, String password, String pageURL)
String
getURLToLoginAs(String username, String password)
String
getURLToLoginAsAdmin()
String
getURLToLoginAsAdminAndGotoPage(String pageURL)
String
getURLToLoginAsSuperAdmin()
String
getURLToLoginAsSuperAdminAndGotoPage(String pageURL)
String
getURLToLogout()
Consider using setSession(null) because it will drop the cookies which is faster than invoking a logout action.String
getURLToNonExistentPage()
String
getVersion()
void
gotoPage(String url)
ViewPage
gotoPage(String space, String page)
void
gotoPage(String space, String page, String action)
void
gotoPage(String space, String page, String action, Object... queryParameters)
void
gotoPage(String space, String page, String action, String queryString)
void
gotoPage(String space, String page, String action, Map<String,?> queryParameters)
void
gotoPage(List<String> spaces, String page, String action, String queryString)
void
gotoPage(List<String> spaces, String page, String action, Map<String,?> queryParameters)
ViewPage
gotoPage(org.xwiki.model.reference.EntityReference reference)
void
gotoPage(org.xwiki.model.reference.EntityReference reference, String action)
void
gotoPage(org.xwiki.model.reference.EntityReference reference, String action, Object... queryParameters)
void
gotoPage(org.xwiki.model.reference.EntityReference reference, String action, String queryString)
void
gotoPage(org.xwiki.model.reference.EntityReference reference, String action, String queryString, String fragment)
void
gotoPage(org.xwiki.model.reference.EntityReference reference, String action, Map<String,?> queryParameters)
void
importXar(File file)
static void
initializeComponent(org.xwiki.component.manager.ComponentManager componentManager)
boolean
isInAdminMode()
boolean
isInClassEditMode()
boolean
isInCreateMode()
boolean
isInDeleteMode()
boolean
isInInlineEditMode()
boolean
isInObjectEditMode()
boolean
isInRenameMode()
boolean
isInRightsEditMode()
boolean
isInSourceViewMode()
boolean
isInViewMode()
boolean
isInWikiEditMode()
boolean
isInWYSIWYGEditMode()
void
login(String username, String password)
void
loginAndGotoPage(String username, String password, String pageURL)
void
loginAndGotoPage(String username, String password, String pageURL, boolean checkLoginSuccess)
void
loginAsAdmin()
void
loginAsAdminAndGotoPage(String pageURL)
void
loginAsSuperAdmin()
void
loginAsSuperAdminAndGotoPage(String pageURL)
String
openLinkInTab(org.openqa.selenium.By by, String... existingTabHandles)
boolean
pageExists(String space, String page)
boolean
pageExists(List<String> spaces, String page)
void
recacheSecretToken()
(Re)-cache the secret token used for CSRF protection.org.xwiki.model.reference.EntityReference
resolveDocumentReference(String referenceAsString)
org.xwiki.model.reference.EntityReference
resolveSpaceReference(String referenceAsString)
TestUtils.RestTestUtils
rest()
void
rollBackTo(String space, String page, String version)
Roll back a page to the specified version, using the/rollback/
action.void
rollbackToPreviousVersion(String space, String page)
Roll back a page to the previous version, using the/rollback/
action.String
serializeReference(org.xwiki.model.reference.EntityReference reference)
static void
setContext(PersistentTestContext context)
Used so that AllTests can set the persistent test context.void
setCurrentWiki(String currentWiki)
void
setDefaultCredentials(String username, String password)
org.apache.commons.httpclient.UsernamePasswordCredentials
setDefaultCredentials(org.apache.commons.httpclient.UsernamePasswordCredentials defaultCredentials)
void
setExecutors(List<XWikiExecutor> executors)
void
setGlobalRights(String groups, String users, String rights, boolean enabled)
Add or update aXWikiGlobalRights
xobject to the current wiki'sXWikiPrefrences
document.void
setHierarchyMode(String mode)
Set the hierarchy mode used in the wikivoid
setPropertyInXWikiCfg(String configuration)
Set global xwiki configuration options (as if the xwiki.cfg file had been modified).void
setPropertyInXWikiPreferences(String propertyName, String propertyType, Object value)
Add and set a property into XWiki.XWikiPreferences.void
setRights(org.xwiki.model.reference.EntityReference entityReference, String groups, String users, String rights, boolean enabled)
Add or update aXWikiRights
xobject to the document specified in the passed entity reference.void
setSession(TestUtils.Session session)
static void
setURLPrefix(String urlPrefix)
String
setWikiPreference(String propertyName, String value)
Sets the value of an existing property of XWiki.XWikiPreferences.void
switchExecutor(int index)
void
switchTab(String tabHandle)
String
toQueryParameterKey(String className, Integer objectNumber, String key)
Map<String,?>
toQueryParameters(Object... properties)
Map<String,?>
toQueryParameters(String className, Integer objectNumber, Object... properties)
Map<String,?>
toQueryParameters(String className, Integer objectNumber, Map<String,?> properties)
String
toQueryString(Object... queryParameters)
String
toQueryString(Map<String,?> queryParameters)
void
updateClassProperty(org.xwiki.model.reference.EntityReference reference, Object... queryParameters)
void
updateObject(String space, String page, String className, int objectNumber, Object... properties)
void
updateObject(String space, String page, String className, int objectNumber, Map<String,?> properties)
void
updateObject(List<String> spaces, String page, String className, int objectNumber, Object... properties)
void
updateObject(org.xwiki.model.reference.EntityReference entityReference, String className, int objectNumber, Object... properties)
-
-
-
Field Detail
-
ADMIN_CREDENTIALS
public static final org.apache.commons.httpclient.UsernamePasswordCredentials ADMIN_CREDENTIALS
- Since:
- 5.0M2
-
SUPER_ADMIN_CREDENTIALS
public static final org.apache.commons.httpclient.UsernamePasswordCredentials SUPER_ADMIN_CREDENTIALS
- Since:
- 5.1M1
-
BASE_URL
@Deprecated public static final String BASE_URL
Deprecated.since 7.3M1, usegetBaseURL()
instead- Since:
- 5.0M2
-
BASE_BIN_URL
@Deprecated public static final String BASE_BIN_URL
Deprecated.since 7.3M1, usegetBaseBinURL()
instead- Since:
- 5.0M2
-
BASE_REST_URL
@Deprecated public static final String BASE_REST_URL
Deprecated.since 7.3M1, usegetBaseURL()
instead- Since:
- 5.0M2
-
STATUS_OK_NOT_FOUND
public static final int[] STATUS_OK_NOT_FOUND
- Since:
- 7.3M1
-
STATUS_OK
public static final int[] STATUS_OK
- Since:
- 7.3M1
-
STATUS_NO_CONTENT
public static final int[] STATUS_NO_CONTENT
- Since:
- 7.3M1
-
STATUS_NO_CONTENT_NOT_FOUND
public static final int[] STATUS_NO_CONTENT_NOT_FOUND
- Since:
- 8.3RC1
-
STATUS_CREATED_ACCEPTED
public static final int[] STATUS_CREATED_ACCEPTED
- Since:
- 7.3M1
-
STATUS_CREATED
public static final int[] STATUS_CREATED
- Since:
- 7.3M1
-
STATUS_ACCEPTED
public static final int[] STATUS_ACCEPTED
- Since:
- 9.5RC1
-
-
Method Detail
-
getCurrentExecutor
public XWikiExecutor getCurrentExecutor()
- Since:
- 8.0M1
-
switchExecutor
public void switchExecutor(int index)
- Since:
- 8.0M1
-
setExecutors
public void setExecutors(List<XWikiExecutor> executors)
- Since:
- 8.0M1
-
setContext
public static void setContext(PersistentTestContext context)
Used so that AllTests can set the persistent test context.
-
initializeComponent
public static void initializeComponent(org.xwiki.component.manager.ComponentManager componentManager) throws Exception
- Throws:
Exception
-
getDriver
public XWikiWebDriver getDriver()
-
getSession
public TestUtils.Session getSession()
-
setSession
public void setSession(TestUtils.Session session)
-
setDefaultCredentials
public void setDefaultCredentials(String username, String password)
- Since:
- 7.0RC1
-
setDefaultCredentials
public org.apache.commons.httpclient.UsernamePasswordCredentials setDefaultCredentials(org.apache.commons.httpclient.UsernamePasswordCredentials defaultCredentials)
- Since:
- 7.0RC1
-
getDefaultCredentials
public org.apache.commons.httpclient.UsernamePasswordCredentials getDefaultCredentials()
-
loginAsSuperAdmin
public void loginAsSuperAdmin()
-
loginAsSuperAdminAndGotoPage
public void loginAsSuperAdminAndGotoPage(String pageURL)
-
loginAsAdmin
public void loginAsAdmin()
-
loginAsAdminAndGotoPage
public void loginAsAdminAndGotoPage(String pageURL)
-
loginAndGotoPage
public void loginAndGotoPage(String username, String password, String pageURL, boolean checkLoginSuccess)
- Since:
- 11.6RC1
-
getURLToLogout
public String getURLToLogout()
Consider using setSession(null) because it will drop the cookies which is faster than invoking a logout action.
-
getURLToLoginAsAdmin
public String getURLToLoginAsAdmin()
-
getURLToLoginAsSuperAdmin
public String getURLToLoginAsSuperAdmin()
-
getURLToLoginAsAdminAndGotoPage
public String getURLToLoginAsAdminAndGotoPage(String pageURL)
- Parameters:
pageURL
- the URL of the page to go to after logging in.- Returns:
- URL to accomplish login and goto.
-
getURLToLoginAsSuperAdminAndGotoPage
public String getURLToLoginAsSuperAdminAndGotoPage(String pageURL)
- Parameters:
pageURL
- the URL of the page to go to after logging in.- Returns:
- URL to accomplish login and goto.
-
getURLToLoginAndGotoPage
public String getURLToLoginAndGotoPage(String username, String password, String pageURL)
- Parameters:
username
- the name of the user to log in as.password
- the password for the user to log in.pageURL
- the URL of the page to go to after logging in.- Returns:
- URL to accomplish login and goto.
-
getURLToNonExistentPage
public String getURLToNonExistentPage()
- Returns:
- URL to a non existent page that loads very fast (we are using plain mode so that we don't even have to display the skin ;))
-
assertOnPage
public void assertOnPage(String pageURL)
After successful completion of this function, you are guaranteed to be logged in as the given user and on the page passed in pageURL.
-
getLoggedInUserName
public String getLoggedInUserName()
-
createUserAndLogin
public void createUserAndLogin(String username, String password, Object... properties)
-
createUserAndLoginWithRedirect
public void createUserAndLoginWithRedirect(String username, String password, String url, Object... properties)
-
createUser
public void createUser(String username, String password, String redirectURL, Object... properties)
-
createAdminUser
public void createAdminUser()
Creates the Admin user and add it to the XWikiAdminGroup.- Since:
- 12.2
-
setGlobalRights
public void setGlobalRights(String groups, String users, String rights, boolean enabled)
Add or update aXWikiGlobalRights
xobject to the current wiki'sXWikiPrefrences
document.- Parameters:
groups
- the comma-separated list of groups that will have the rights (e.g.XWiki.XWikiAdminGroup
. Can be empty or nullusers
- the comma-separated list of users that will have the rights (e.g.XWiki.Admin
. Can be empty of nullrights
- the comma-separated list of rights to give (e.g.edit,admin
)enabled
- true if the rights should be allowed, false if they should be disabled- Since:
- 12.2
-
setRights
public void setRights(org.xwiki.model.reference.EntityReference entityReference, String groups, String users, String rights, boolean enabled)
Add or update aXWikiRights
xobject to the document specified in the passed entity reference.- Parameters:
entityReference
- the reference to the document for which to set rights forgroups
- the comma-separated list of groups that will have the rights (e.g.XWiki.XWikiAdminGroup
. Can be empty or nullusers
- the comma-separated list of users that will have the rights (e.g.XWiki.Admin
. Can be empty of nullrights
- the comma-separated list of rights to give (e.g.edit,admin
)enabled
- true if the rights should be allowed, false if they should be disabled- Since:
- 12.2
-
gotoPage
public ViewPage gotoPage(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(org.xwiki.model.reference.EntityReference reference, String action)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(String space, String page, String action, Object... queryParameters)
- Since:
- 3.5M1
-
gotoPage
public void gotoPage(org.xwiki.model.reference.EntityReference reference, String action, Object... queryParameters)
- Since:
- 11.3RC1
-
gotoPage
public void gotoPage(String space, String page, String action, Map<String,?> queryParameters)
-
gotoPage
public void gotoPage(List<String> spaces, String page, String action, Map<String,?> queryParameters)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(org.xwiki.model.reference.EntityReference reference, String action, Map<String,?> queryParameters)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(List<String> spaces, String page, String action, String queryString)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(org.xwiki.model.reference.EntityReference reference, String action, String queryString)
- Since:
- 7.2M2
-
gotoPage
public void gotoPage(org.xwiki.model.reference.EntityReference reference, String action, String queryString, String fragment)
- Since:
- 10.9
-
gotoPage
public void gotoPage(String url)
-
getURLToDeletePage
public String getURLToDeletePage(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.2M2
-
getURLToDeletePage
public String getURLToDeletePage(org.xwiki.model.reference.EntityReference reference, boolean affectChildren)
- Since:
- 12.9RC1
-
getURLToDeleteSpace
public String getURLToDeleteSpace(String space)
- Parameters:
space
- the name of the space to delete- Returns:
- the URL that can be used to delete the specified pace
- Since:
- 4.5
-
getURLToDeleteSpace
public String getURLToDeleteSpace(org.xwiki.model.reference.EntityReference space)
- Parameters:
space
- the reference of the space to delete- Returns:
- the URL that can be used to delete the specified pace
- Since:
- 14.1RC1
-
createPage
public ViewPage createPage(org.xwiki.model.reference.EntityReference reference, String content)
- Since:
- 11.5RC1, 11.3.1
-
createPage
public ViewPage createPage(org.xwiki.model.reference.EntityReference reference, String content, String title)
- Since:
- 7.2M2
-
createPage
public ViewPage createPage(List<String> spaces, String page, String content, String title)
- Since:
- 7.2M2
-
createPage
public ViewPage createPage(String space, String page, String content, String title, String syntaxId)
-
createPage
public ViewPage createPage(org.xwiki.model.reference.EntityReference reference, String content, String title, String syntaxId)
- Since:
- 7.2M2
-
createPage
public ViewPage createPage(List<String> spaces, String page, String content, String title, String syntaxId)
- Since:
- 7.2M2
-
createPage
public ViewPage createPage(String space, String page, String content, String title, String syntaxId, String parentFullPageName)
-
createPage
public ViewPage createPage(List<String> spaces, String page, String content, String title, String syntaxId, String parentFullPageName)
- Since:
- 7.2M2
-
createPage
public ViewPage createPage(org.xwiki.model.reference.EntityReference reference, String content, String title, String syntaxId, String parentFullPageName)
- Since:
- 7.2M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(String space, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData) throws Exception
- Throws:
Exception
- Since:
- 5.1M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(String space, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 5.1M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(List<String> spaces, String page, String content, String title, String syntaxId, String parentFullPageName, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 7.2M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(String space, String page, String content, String title, String attachmentName, InputStream attachmentData) throws Exception
- Throws:
Exception
- Since:
- 5.1M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(String space, String page, String content, String title, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 5.1M2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(org.xwiki.model.reference.EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 12.2
-
createPageWithAttachment
public ViewPage createPageWithAttachment(org.xwiki.model.reference.EntityReference reference, String content, String title, String attachmentName, InputStream attachmentData) throws Exception
- Throws:
Exception
- Since:
- 12.2
-
deletePage
public void deletePage(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.2M2
-
deletePage
public void deletePage(org.xwiki.model.reference.EntityReference reference, boolean affectChildren)
- Since:
- 12.9RC1
-
resolveDocumentReference
public org.xwiki.model.reference.EntityReference resolveDocumentReference(String referenceAsString)
- Since:
- 7.2M2
-
resolveSpaceReference
public org.xwiki.model.reference.EntityReference resolveSpaceReference(String referenceAsString)
- Since:
- 7.2M3
-
serializeReference
public String serializeReference(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.2RC1
-
deleteSpace
public void deleteSpace(String space)
Accesses the URL to delete the specified space.- Parameters:
space
- the name of the space to delete- Since:
- 4.5
-
deleteSpace
public void deleteSpace(org.xwiki.model.reference.EntityReference space)
Accesses the URL to delete the specified space.- Parameters:
space
- the reference of the space to delete- Since:
- 14.1RC1
-
pageExists
public boolean pageExists(List<String> spaces, String page) throws Exception
- Throws:
Exception
- Since:
- 7.2M2
-
getURL
public String getURL(String space, String page)
Get the URL to view a page.- Parameters:
space
- the space in which the page resides.page
- the name of the page.
-
getURL
public String getURL(String space, String page, String action)
Get the URL of an action on a page.- Parameters:
space
- the space in which the page resides.page
- the name of the page.action
- the action to do on the page.
-
getURL
public String getURL(String space, String page, String action, String queryString)
Get the URL of an action on a page with a specified query string.- Parameters:
space
- the space in which the page resides.page
- the name of the page.action
- the action to do on the page.queryString
- the query string to pass in the URL.
-
getURL
public String getURL(List<String> spaces, String page, String action, String queryString)
- Since:
- 7.2M2
-
getURL
public String getURL(org.xwiki.model.reference.EntityReference reference)
- Since:
- 12.2
-
getURL
public String getURL(org.xwiki.model.reference.EntityReference reference, String action, String queryString)
- Since:
- 7.2M2
-
getURL
public String getURL(org.xwiki.model.reference.EntityReference reference, String action, String queryString, String fragment)
- Since:
- 10.9
-
executeAndGetBodyAsString
public String executeAndGetBodyAsString(org.xwiki.model.reference.EntityReference reference, Map<String,?> queryParameters) throws Exception
- Throws:
Exception
- Since:
- 9.7RC1
-
getURLFragment
public String getURLFragment(org.xwiki.model.reference.EntityReference reference)
- Since:
- 7.2M2
-
getCurrentWiki
public String getCurrentWiki()
- Since:
- 7.3M1
-
setCurrentWiki
public void setCurrentWiki(String currentWiki)
- Since:
- 14.5
-
getBaseURL
public String getBaseURL()
- Since:
- 7.3M1
-
setURLPrefix
public static void setURLPrefix(String urlPrefix)
- Since:
- 10.6RC1
-
getBaseBinURL
public String getBaseBinURL()
- Since:
- 7.3M1
-
getURL
public String getURL(String action, String[] path, String queryString, String fragment)
- Since:
- 10.9
-
getURL
public String getURL(String space, String page, String action, Map<String,?> queryParameters)
Get the URL of an action on a page with specified parameters. If you need to pass multiple parameters with the same key, this function will not work.- Parameters:
space
- the space in which the page resides.page
- the name of the page.action
- the action to do on the page.queryParameters
- the parameters to pass in the URL, these will be automatically URL encoded.
-
getAttachmentURL
public String getAttachmentURL(String space, String page, String attachment, String action, String queryString)
- Parameters:
space
- the name of the space that contains the page with the specified attachmentpage
- the name of the page that holds the attachmentattachment
- the attachment nameaction
- the action to perform on the attachmentqueryString
- the URL query string- Returns:
- the URL that performs the specified action on the specified attachment
-
getAttachmentURL
public String getAttachmentURL(String space, String page, String attachment, String action)
- Parameters:
space
- the name of the space that contains the page with the specified attachmentpage
- the name of the page that holds the attachmentattachment
- the attachment nameaction
- the action to perform on the attachment- Returns:
- the URL that performs the specified action on the specified attachment
-
getAttachmentURL
public String getAttachmentURL(String space, String page, String attachment)
- Parameters:
space
- the name of the space that contains the page with the specified attachmentpage
- the name of the page that holds the attachmentattachment
- the attachment name- Returns:
- the URL to download the specified attachment
-
recacheSecretToken
public void recacheSecretToken()
(Re)-cache the secret token used for CSRF protection. A user with edit rights on Main.WebHome must be logged in. This method must be called beforegetSecretToken()
is called and after each re-login.- See Also:
getSecretToken()
-
getSecretToken
public String getSecretToken()
Get the secret token used for CSRF protection. Remember to callrecacheSecretToken()
first.- Returns:
- anti-CSRF secret token, or empty string if the token was not cached
- See Also:
recacheSecretToken()
-
isInWYSIWYGEditMode
public boolean isInWYSIWYGEditMode()
-
isInWikiEditMode
public boolean isInWikiEditMode()
-
isInViewMode
public boolean isInViewMode()
-
isInSourceViewMode
public boolean isInSourceViewMode()
-
isInInlineEditMode
public boolean isInInlineEditMode()
-
isInRightsEditMode
public boolean isInRightsEditMode()
-
isInObjectEditMode
public boolean isInObjectEditMode()
-
isInClassEditMode
public boolean isInClassEditMode()
-
isInDeleteMode
public boolean isInDeleteMode()
-
isInRenameMode
public boolean isInRenameMode()
-
isInCreateMode
public boolean isInCreateMode()
-
isInAdminMode
public boolean isInAdminMode()
-
assertOnPage
public void assertOnPage(org.xwiki.model.reference.EntityReference reference)
Verify if the passed reference corresponds to the current page, independently of the wiki. Throws anAssertionFailedError
if it's not the case.- Parameters:
reference
- the reference to the document to check- Since:
- 12.2
-
forceGuestUser
public void forceGuestUser()
Forces the current user to be the Guest user by clearing all coookies.
-
addObject
public void addObject(org.xwiki.model.reference.EntityReference reference, String className, Object... properties)
- Since:
- 7.2RC1
-
addObject
public void addObject(org.xwiki.model.reference.EntityReference reference, String className, Map<String,?> properties)
- Since:
- 7.3M2
-
addObject
public void addObject(String space, String page, String className, Map<String,?> properties)
-
deleteObject
public void deleteObject(String space, String page, String className, int objectNumber) throws Exception
- Throws:
Exception
-
updateObject
public void updateObject(String space, String page, String className, int objectNumber, Map<String,?> properties)
-
updateObject
public void updateObject(String space, String page, String className, int objectNumber, Object... properties)
-
updateObject
public void updateObject(org.xwiki.model.reference.EntityReference entityReference, String className, int objectNumber, Object... properties)
- Since:
- 11.5RC1, 11.3.1
-
updateObject
public void updateObject(List<String> spaces, String page, String className, int objectNumber, Object... properties)
- Since:
- 8.3RC1
-
addClassProperty
public void addClassProperty(org.xwiki.model.reference.EntityReference reference, String propertyName, String propertyType)
- Since:
- 11.3RC1
-
updateClassProperty
public void updateClassProperty(org.xwiki.model.reference.EntityReference reference, Object... queryParameters)
- Since:
- 11.3RC1
-
addClassProperty
public void addClassProperty(String space, String page, String propertyName, String propertyType)
-
addQueryStringEntry
public void addQueryStringEntry(StringBuilder builder, String key, Object value)
- Since:
- 3.2M1
-
addQueryStringEntry
public void addQueryStringEntry(StringBuilder builder, String key, String value)
- Since:
- 3.2M1
-
toQueryParameters
public Map<String,?> toQueryParameters(String className, Integer objectNumber, Object... properties)
-
toQueryParameters
public Map<String,?> toQueryParameters(String className, Integer objectNumber, Map<String,?> properties)
-
toQueryParameterKey
public String toQueryParameterKey(String className, Integer objectNumber, String key)
-
editObjects
public ObjectEditPage editObjects(String space, String page)
-
editClass
public ClassEditPage editClass(String space, String page)
-
editClass
public ClassEditPage editClass(org.xwiki.model.reference.DocumentReference reference)
Goes to a page in edit class mode.- Parameters:
reference
- a document reference- Returns:
- the
ClassEditPage
Page Object for the page - Since:
- 14.0RC1
-
attachFile
public void attachFile(String space, String page, String name, File file, boolean failIfExists) throws Exception
- Throws:
Exception
-
attachFile
public void attachFile(String space, String page, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 5.1M2
-
attachFile
public void attachFile(List<String> spaces, String page, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 7.2M2
-
attachFile
public void attachFile(String space, String page, String name, InputStream is, boolean failIfExists) throws Exception
- Throws:
Exception
-
attachFile
public void attachFile(List<String> spaces, String page, String name, InputStream is, boolean failIfExists) throws Exception
- Throws:
Exception
- Since:
- 7.2M2
-
attachFile
public void attachFile(org.xwiki.model.reference.EntityReference pageReference, String name, InputStream is, boolean failIfExists) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
attachFile
public void attachFile(org.xwiki.model.reference.EntityReference reference, Object is, boolean failIfExists) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
attachFile
public void attachFile(org.xwiki.model.reference.EntityReference pageReference, String name, InputStream is, boolean failIfExists, org.apache.commons.httpclient.UsernamePasswordCredentials credentials) throws Exception
- Throws:
Exception
- Since:
- 12.2
-
deleteAttachement
public void deleteAttachement(org.xwiki.model.reference.EntityReference pageReference, String filename) throws Exception
- Throws:
Exception
-
deleteAttachement
public void deleteAttachement(org.xwiki.model.reference.EntityReference reference) throws Exception
- Throws:
Exception
-
deleteLatestVersion
public void deleteLatestVersion(String space, String page)
Delete the latest version from the history of a page, using the/deleteversions/
action.- Parameters:
space
- the space name of the pagepage
- the name of the page- Since:
- 7.0M2
-
deleteVersion
public void deleteVersion(String space, String page, String version)
Delete a specific version from the history of a page, using the/deleteversions/
action.- Parameters:
space
- the space name of the pagepage
- the name of the pageversion
- the version to delete- Since:
- 7.0M2
-
deleteVersions
public void deleteVersions(String space, String page, String v1, String v2)
Delete an interval of versions from the history of a page, using the/deleteversions/
action.- Parameters:
space
- the space name of the pagepage
- the name of the pagev1
- the starting version to deletev2
- the ending version to delete- Since:
- 7.0M2
-
rollbackToPreviousVersion
public void rollbackToPreviousVersion(String space, String page)
Roll back a page to the previous version, using the/rollback/
action.- Parameters:
space
- the space name of the pagepage
- the name of the page- Since:
- 7.0M2
-
rollBackTo
public void rollBackTo(String space, String page, String version)
Roll back a page to the specified version, using the/rollback/
action.- Parameters:
space
- the space name of the pagepage
- the name of the pageversion
- the version to rollback to- Since:
- 7.0M2
-
setHierarchyMode
public void setHierarchyMode(String mode)
Set the hierarchy mode used in the wiki- Parameters:
mode
- the mode to use ("reference" or "parentchild")- Since:
- 7.2M2
-
setPropertyInXWikiPreferences
public void setPropertyInXWikiPreferences(String propertyName, String propertyType, Object value)
Add and set a property into XWiki.XWikiPreferences. Create XWiki.XWikiPreferences if it does not exist.- Parameters:
propertyName
- name of the property to setpropertyType
- the type of the property to addvalue
- value to set to the property- Since:
- 7.2M2
-
setPropertyInXWikiCfg
public void setPropertyInXWikiCfg(String configuration) throws IOException
Set global xwiki configuration options (as if the xwiki.cfg file had been modified). This is useful for testing configuration options.- Parameters:
configuration
- the configuration inProperties
format. For example "param1=value2\nparam2=value2"- Throws:
IOException
- if an error occurs while parsing the configuration
-
setWikiPreference
public String setWikiPreference(String propertyName, String value) throws Exception
Sets the value of an existing property of XWiki.XWikiPreferences.- Parameters:
propertyName
- name of the property to setvalue
- value to set to the property- Returns:
- the previous value, if the property was set,
null
otherwise - Throws:
Exception
- Since:
- 9.7RC1
-
assertStatuses
public static void assertStatuses(int actualCode, int... expectedCodes)
- Since:
- 7.3M1
-
assertStatusCodes
public static <M extends org.apache.commons.httpclient.HttpMethod> M assertStatusCodes(M method, boolean release, int... expectedCodes) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
escapeURL
public String escapeURL(String url)
Encodes a given string so that it may be used as a URL component. Compatible with javascript decodeURIComponent, though more strict than encodeURIComponent: all characters except [a-zA-Z0-9], '.', '-', '*', '_' are encoded. Uses the same algorithm than the one used to generate URLs as otherwise tests won't find the proper matches... See XWikiServletURLFactory#encodeWithinPath() and #encodeWithinQuery().- Parameters:
url
- the url to encode
-
escapeXPath
public String escapeXPath(String value)
Usage example:By.xpath("//a[. = " + escapeXPath(value) + "]")
- Parameters:
value
- the value to escape- Returns:
- the escaped value
-
getInputStream
public InputStream getInputStream(String path, Map<String,?> queryParams) throws Exception
- Throws:
Exception
-
getString
public String getString(String path, Map<String,?> queryParams) throws Exception
- Throws:
Exception
-
getString
public String getString(String baseURL, String path, Map<String,?> queryParams) throws Exception
Extended version to work in a docker context.- Parameters:
baseURL
- the base urlpath
- an additional path added after the base urlqueryParams
- additional query parameter added to the computed url- Returns:
- the context of the computed url
- Throws:
Exception
- in case of error when executing the request
-
getInputStream
public InputStream getInputStream(String prefix, String path, Map<String,?> queryParams, Object... elements) throws Exception
- Throws:
Exception
-
executeGet
protected org.apache.commons.httpclient.methods.GetMethod executeGet(String uri) throws Exception
- Throws:
Exception
-
executeGet
protected org.apache.commons.httpclient.methods.GetMethod executeGet(String uri, int... expectedCodes) throws Exception
- Throws:
Exception
-
executeGet
protected org.apache.commons.httpclient.methods.GetMethod executeGet(String uri, boolean release, int... expectedCodes) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executePost
protected org.apache.commons.httpclient.methods.PostMethod executePost(String uri, InputStream content, String mediaType) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executePost
protected org.apache.commons.httpclient.methods.PostMethod executePost(String uri, InputStream content, String mediaType, int... expectedCodes) throws Exception
- Throws:
Exception
-
executePost
protected org.apache.commons.httpclient.methods.PostMethod executePost(String uri, InputStream content, String mediaType, boolean release, int... expectedCodes) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executeDelete
protected org.apache.commons.httpclient.methods.DeleteMethod executeDelete(String uri) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executeDelete
protected void executeDelete(String uri, int... expectedCodes) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executePut
protected org.apache.commons.httpclient.methods.PutMethod executePut(String uri, InputStream content, String mediaType) throws Exception
- Throws:
Exception
- Since:
- 7.3M1
-
executePut
protected void executePut(String uri, InputStream content, String mediaType, int... expectedCodes) throws Exception
- Throws:
Exception
-
executePut
protected org.apache.commons.httpclient.methods.PutMethod executePut(String uri, InputStream content, String mediaType, boolean release, int... expectedCodes) throws Exception
- Throws:
Exception
-
rest
public TestUtils.RestTestUtils rest()
-
disableSyntaxHighlighting
public void disableSyntaxHighlighting() throws Exception
Disable Syntax Highlighting.- Throws:
Exception
- Since:
- 9.7RC1
-
switchTab
public void switchTab(String tabHandle)
- Since:
- 11.5RC1
-
getCurrentTabHandle
public String getCurrentTabHandle()
- Since:
- 11.5RC1
-
openLinkInTab
public String openLinkInTab(org.openqa.selenium.By by, String... existingTabHandles)
- Since:
- 11.5RC1
-
closeTab
public void closeTab(String secondTabHandle)
- Since:
- 11.5, 11.6RC1
-
-