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 StringADDITONAL_BUNDLES_PATHstatic StringADDITONAL_BUNDLES_UNINSTALLstatic StringADMINstatic StringBUNDLE_INSTALL_TIMEOUT_SECONDSstatic StringBUNDLE_TO_INSTALL_PREFIXstatic StringKEEP_JAR_RUNNING_PROPstatic StringSERVER_HOSTNAME_PROPstatic StringSERVER_READY_PROP_PREFIXstatic StringSERVER_READY_QUIET_PERIOD_PROPstatic StringSERVER_READY_TIMEOUT_DELAY_PROPstatic StringSERVER_READY_TIMEOUT_INITIAL_DELAY_PROPstatic StringSERVER_READY_TIMEOUT_PROPstatic StringSTART_BUNDLES_TIMEOUT_SECONDSstatic StringTEST_SERVER_PASSWORDstatic StringTEST_SERVER_URL_PROPstatic StringTEST_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 voidblockIfRequested()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_PATHprotected List<File>getBundlesToInstall(String additionalBundlesPath)Get the list of additional bundles to install, as specified by additionalBundlesPath parameterorg.apache.sling.testing.clients.osgi.OsgiConsoleClientgetOsgiConsoleClient()StringgetServerBaseUrl()Start server if needed, and return its base URLStringgetServerPassword()Return password configured for execution of HTTP requestsStringgetServerUsername()Return username configured for execution of HTTP requestsorg.apache.sling.testing.clients.SlingClientgetSlingClient()Returns a SlingClient for this serverprotected voidinstallAdditionalBundles()booleanisServerStartedByThisClass()protected voiduninstallAdditionalBundles()voiduninstallAdditionalBundlesIfNecessary()Automatically by the SlingRemoteTestRunner since package version 1.1.0.protected voidwaitForQuietPeriod()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 voidwaitForServerReady()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 InterruptedExceptionWait 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:
getServerBaseUrlin interfaceSlingInstance
-
getServerUsername
public String getServerUsername()
Return username configured for execution of HTTP requests- Specified by:
getServerUsernamein interfaceSlingInstance
-
getServerPassword
public String getServerPassword()
Return password configured for execution of HTTP requests- Specified by:
getServerPasswordin interfaceSlingInstance
-
getSlingClient
public org.apache.sling.testing.clients.SlingClient getSlingClient()
Description copied from interface:SlingInstanceReturns a SlingClient for this server- Specified by:
getSlingClientin 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 ExceptionCheck 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
Files 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()
-
-