Class SlingTestBase
- java.lang.Object
-
- org.apache.sling.testing.serversetup.instance.SlingTestBase
-
- All Implemented Interfaces:
SlingInstance
public class SlingTestBase extends Object implements SlingInstance
Base class for running tests against a Sling instance, takes care of starting Sling and waiting for it to be ready.
-
-
Field Summary
Fields Modifier and Type Field Description static String
ADDITONAL_BUNDLES_PATH
static String
ADDITONAL_BUNDLES_UNINSTALL
static String
ADMIN
static String
BUNDLE_INSTALL_TIMEOUT_SECONDS
static String
BUNDLE_TO_INSTALL_PREFIX
static String
KEEP_JAR_RUNNING_PROP
static String
SERVER_HOSTNAME_PROP
static String
SERVER_READY_PROP_PREFIX
static String
SERVER_READY_QUIET_PERIOD_PROP
static String
SERVER_READY_TIMEOUT_DELAY_PROP
static String
SERVER_READY_TIMEOUT_INITIAL_DELAY_PROP
static String
SERVER_READY_TIMEOUT_PROP
static String
START_BUNDLES_TIMEOUT_SECONDS
static String
TEST_SERVER_PASSWORD
static String
TEST_SERVER_URL_PROP
static String
TEST_SERVER_USERNAME
-
Constructor Summary
Constructors Constructor Description SlingTestBase()
SlingTestBase(SlingInstanceState slingTestState, Properties systemProperties)
Get configuration but do not start server yet, that's done on demand
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
blockIfRequested()
Optionally block here so that the runnable jar stays up - we can then run tests against it from another VM.protected List<org.apache.http.NameValuePair>
extractParams(URI url)
Convert the query part of the URI to a list of name value pairs that are suitable for the client callsprotected List<File>
getBundlesToInstall()
Get the list of additional bundles to install, as specified by the system propertyADDITONAL_BUNDLES_PATH
protected List<File>
getBundlesToInstall(String additionalBundlesPath)
Get the list of additional bundles to install, as specified by additionalBundlesPath parameterorg.apache.sling.testing.clients.osgi.OsgiConsoleClient
getOsgiConsoleClient()
String
getServerBaseUrl()
Start server if needed, and return its base URLString
getServerPassword()
Return password configured for execution of HTTP requestsString
getServerUsername()
Return username configured for execution of HTTP requestsorg.apache.sling.testing.clients.SlingClient
getSlingClient()
Returns a SlingClient for this serverprotected void
installAdditionalBundles()
boolean
isServerStartedByThisClass()
protected void
uninstallAdditionalBundles()
void
uninstallAdditionalBundlesIfNecessary()
Automatically by the SlingRemoteTestRunner since package version 1.1.0.protected void
waitForQuietPeriod()
Wait for the configured duration as a quite period to let the server settle down after doing the startup and install additional bundles work.protected void
waitForServerReady()
Check a number of server URLs for readyness
-
-
-
Field Detail
-
TEST_SERVER_URL_PROP
public static final String TEST_SERVER_URL_PROP
- See Also:
- Constant Field Values
-
TEST_SERVER_USERNAME
public static final String TEST_SERVER_USERNAME
- See Also:
- Constant Field Values
-
TEST_SERVER_PASSWORD
public static final String TEST_SERVER_PASSWORD
- See Also:
- Constant Field Values
-
SERVER_READY_TIMEOUT_PROP
public static final String SERVER_READY_TIMEOUT_PROP
- See Also:
- Constant Field Values
-
SERVER_READY_TIMEOUT_INITIAL_DELAY_PROP
public static final String SERVER_READY_TIMEOUT_INITIAL_DELAY_PROP
- See Also:
- Constant Field Values
-
SERVER_READY_TIMEOUT_DELAY_PROP
public static final String SERVER_READY_TIMEOUT_DELAY_PROP
- See Also:
- Constant Field Values
-
SERVER_READY_QUIET_PERIOD_PROP
public static final String SERVER_READY_QUIET_PERIOD_PROP
- See Also:
- Constant Field Values
-
SERVER_READY_PROP_PREFIX
public static final String SERVER_READY_PROP_PREFIX
- See Also:
- Constant Field Values
-
KEEP_JAR_RUNNING_PROP
public static final String KEEP_JAR_RUNNING_PROP
- See Also:
- Constant Field Values
-
SERVER_HOSTNAME_PROP
public static final String SERVER_HOSTNAME_PROP
- See Also:
- Constant Field Values
-
ADDITONAL_BUNDLES_PATH
public static final String ADDITONAL_BUNDLES_PATH
- See Also:
- Constant Field Values
-
ADDITONAL_BUNDLES_UNINSTALL
public static final String ADDITONAL_BUNDLES_UNINSTALL
- See Also:
- Constant Field Values
-
BUNDLE_TO_INSTALL_PREFIX
public static final String BUNDLE_TO_INSTALL_PREFIX
- See Also:
- Constant Field Values
-
START_BUNDLES_TIMEOUT_SECONDS
public static final String START_BUNDLES_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
BUNDLE_INSTALL_TIMEOUT_SECONDS
public static final String BUNDLE_INSTALL_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
ADMIN
public static final String ADMIN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SlingTestBase
public SlingTestBase()
-
SlingTestBase
public SlingTestBase(SlingInstanceState slingTestState, Properties systemProperties)
Get configuration but do not start server yet, that's done on demand
-
-
Method Detail
-
uninstallAdditionalBundlesIfNecessary
public void uninstallAdditionalBundlesIfNecessary()
Automatically by the SlingRemoteTestRunner since package version 1.1.0.
-
waitForQuietPeriod
protected void waitForQuietPeriod() throws InterruptedException
Wait for the configured duration as a quite period to let the server settle down after doing the startup and install additional bundles work.- Throws:
InterruptedException
-
installAdditionalBundles
protected void installAdditionalBundles()
-
uninstallAdditionalBundles
protected void uninstallAdditionalBundles()
-
getServerBaseUrl
public String getServerBaseUrl()
Start server if needed, and return its base URL- Specified by:
getServerBaseUrl
in interfaceSlingInstance
-
getServerUsername
public String getServerUsername()
Return username configured for execution of HTTP requests- Specified by:
getServerUsername
in interfaceSlingInstance
-
getServerPassword
public String getServerPassword()
Return password configured for execution of HTTP requests- Specified by:
getServerPassword
in interfaceSlingInstance
-
getSlingClient
public org.apache.sling.testing.clients.SlingClient getSlingClient()
Description copied from interface:SlingInstance
Returns a SlingClient for this server- Specified by:
getSlingClient
in interfaceSlingInstance
-
getOsgiConsoleClient
public org.apache.sling.testing.clients.osgi.OsgiConsoleClient getOsgiConsoleClient()
-
blockIfRequested
protected void blockIfRequested()
Optionally block here so that the runnable jar stays up - we can then run tests against it from another VM.
-
waitForServerReady
protected void waitForServerReady() throws Exception
Check a number of server URLs for readyness- Throws:
Exception
-
extractParams
protected List<org.apache.http.NameValuePair> extractParams(URI url) throws UnsupportedEncodingException
Convert the query part of the URI to a list of name value pairs that are suitable for the client calls- Throws:
UnsupportedEncodingException
-
getBundlesToInstall
protected List<File> getBundlesToInstall()
Get the list of additional bundles to install, as specified by the system propertyADDITONAL_BUNDLES_PATH
- Returns:
- the list of
File
s pointing to the Bundle JARs or the empty list in case no additional bundles should be installed (nevernull
).
-
getBundlesToInstall
protected List<File> getBundlesToInstall(String additionalBundlesPath)
Get the list of additional bundles to install, as specified by additionalBundlesPath parameter
-
isServerStartedByThisClass
public boolean isServerStartedByThisClass()
-
-