com.atlassian.bamboo.testutils.backdoor
Class BackdoorControl<T extends BackdoorControl<T>>

java.lang.Object
  extended by com.atlassian.bamboo.testutils.backdoor.BackdoorControl<T>
Direct Known Subclasses:
AdministrationControl, AgentsControl, ApplicationLinksControl, BuildResultsControl, CaptchaControl, DarkFeatureControl, GroupControl, LogControl, PermissionsControl, PlansControl, PluginSettingsControl, SchedulerControl, ServerCapabilitiesControl, ServerControl, TestsControl, UserControl

public class BackdoorControl<T extends BackdoorControl<T>>
extends Object

Copied from jira-testkit-client


Nested Class Summary
protected static class BackdoorControl.JsonMediaTypeFilter
          Sets the Content-Type header to "" if not already set.
 
Field Summary
static String ADMIN_REST_PATH
           
static String API_REST_PATH
           
static String DEFAULT_REST_PATH
          The default REST path for the TestKit resources.
protected  String rootPath
          Base URL.
 
Constructor Summary
BackdoorControl(BambooEnvironmentData environmentData)
           
 
Method Summary
protected  com.sun.jersey.api.client.Client client()
          Returns the Jersey client to use.
protected  com.sun.jersey.api.client.WebResource createResource()
          Creates the resource that corresponds to the root of the TestKit REST API, using the values returned by getRestModulePath().
protected  com.sun.jersey.api.client.WebResource createResource(TestUser user)
           
protected  com.sun.jersey.api.client.WebResource createResourceForPath(String restModulePath, String restModuleVersion, TestUser user)
          Creates the resource that corresponds to the root of a REST API.
protected  com.sun.jersey.api.client.WebResource createResourceForPath(String restModulePath, TestUser user)
          Creates the resource that corresponds to the root of a REST API.
protected  String get(com.sun.jersey.api.client.WebResource webResource)
          Convenience method that simply calls WebResource.get(String.class) on the passed-in WebResource.
protected  BambooEnvironmentData getEnvironmentData()
           
protected  String getRestModulePath()
          Returns the REST path used in this plugin's atlassian-plugin.xml (e.g.
protected static String percentEncode(String queryParam)
          Percent-encode the % when stuffing it into a query param.
 PingResponse ping()
           
protected  com.sun.jersey.api.client.WebResource resourceRoot(String url)
          Creates a WebResource for the given URL.
protected  com.sun.jersey.api.client.WebResource resourceRoot(String url, TestUser user)
          Creates a WebResource for the given URL.
 void tearDown()
          Cleanup resources
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REST_PATH

public static final String DEFAULT_REST_PATH
The default REST path for the TestKit resources.

See Also:
Constant Field Values

API_REST_PATH

public static final String API_REST_PATH
See Also:
Constant Field Values

ADMIN_REST_PATH

public static final String ADMIN_REST_PATH
See Also:
Constant Field Values

rootPath

protected final String rootPath
Base URL.

Constructor Detail

BackdoorControl

public BackdoorControl(@NotNull
                       BambooEnvironmentData environmentData)
Method Detail

ping

public PingResponse ping()

tearDown

public void tearDown()
Cleanup resources


client

protected com.sun.jersey.api.client.Client client()
Returns the Jersey client to use.

Returns:
a Client

resourceRoot

protected com.sun.jersey.api.client.WebResource resourceRoot(String url)
Creates a WebResource for the given URL.

Parameters:
url - a String containing a URL
Returns:
a WebResource, with optional authentication parameters

resourceRoot

protected com.sun.jersey.api.client.WebResource resourceRoot(String url,
                                                             TestUser user)
Creates a WebResource for the given URL. The relevant authentication parameters are added to the resource, if applicable.

Parameters:
url - a String containing a URL
Returns:
a WebResource, with optional authentication parameters

createResource

protected com.sun.jersey.api.client.WebResource createResource()
Creates the resource that corresponds to the root of the TestKit REST API, using the values returned by getRestModulePath(). Note that the created WebResource has the following properties: . To create a WebResource for a different root, use createResource()

Returns:
a WebResource for the TestKit REST API root
See Also:
createResource(), getRestModulePath()

createResource

protected com.sun.jersey.api.client.WebResource createResource(TestUser user)

createResourceForPath

protected final com.sun.jersey.api.client.WebResource createResourceForPath(String restModulePath,
                                                                            TestUser user)
Creates the resource that corresponds to the root of a REST API. Note that the created WebResource has the following properties:

Parameters:
restModulePath - a String containing the REST path
Returns:
a WebResource for the the API root at the specified path
See Also:
getRestModulePath()

createResourceForPath

protected final com.sun.jersey.api.client.WebResource createResourceForPath(String restModulePath,
                                                                            String restModuleVersion,
                                                                            TestUser user)
Creates the resource that corresponds to the root of a REST API. Note that the created WebResource has the following properties:

Parameters:
restModulePath - a String containing the REST path
restModuleVersion - a String containing the REST module version
Returns:
a WebResource for the the API root at the specified path
See Also:
getRestModulePath()

getRestModulePath

protected String getRestModulePath()
Returns the REST path used in this plugin's atlassian-plugin.xml (e.g. &lt;rest path="..."&gt;). The default value is ""backdoor"".

Returns:
the REST path used in this plugin's atlassian-plugin.xml (e.g. &lt;rest path="..."&gt;).

get

protected final String get(com.sun.jersey.api.client.WebResource webResource)
Convenience method that simply calls WebResource.get(String.class) on the passed-in WebResource.

This method is often used for mutative operations which should really be using a POST instead, but doing a GET is much more convenient since you can do it right from your browser when testing a backdoor and this is only testing code so it's OK.

Parameters:
webResource - the WebResource to perform the GET on

percentEncode

protected static String percentEncode(String queryParam)
Percent-encode the % when stuffing it into a query param. Otherwise it may not get escaped properly, as per this EAC blog.

Parameters:
queryParam - the query param value
Returns:
a String with % replaced by %25

getEnvironmentData

protected BambooEnvironmentData getEnvironmentData()


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.