Class ClientSideTeleporter
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- org.apache.sling.junit.rules.TeleporterRule
-
- org.apache.sling.testing.teleporter.client.ClientSideTeleporter
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class ClientSideTeleporter extends org.apache.sling.junit.rules.TeleporterRule
Client-side TeleporterRule. Packages the test to run in a test bundle, installs the bundle, executes the test via the JUnit servlet, collects the results and uninstalls the bundle.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_TEST_READY_TIMEOUT_SECONDS
static String
DEFAULT_TEST_SERVLET_PATH
-
Constructor Summary
Constructors Constructor Description ClientSideTeleporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionalBundleHeader(String name, String value)
Set additional bundle headers on the generated test bundleorg.junit.runners.model.Statement
apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
ClientSideTeleporter
embedClass(Class<?> c)
Indicate that a specific class must be embedded in the test bundle.void
embedClassesDirectory(File classesDirectory)
Embeds every class found in the given directoryClientSideTeleporter
excludeDependencyPrefix(String prefix)
Define a prefix for class names that should not be embedded in the test bundle.Map<String,String>
getAdditionalBundleHeaders()
int
getHttpTimeoutSeconds()
Get HTTP connect and read timeouts, defaults to the "test ready timeout" valueClientSideTeleporter
includeDependencyPrefix(String prefix)
Define a prefix for class names that can be embedded in the test bundle if theDependencyAnalyzer
thinks they should.void
setBaseUrl(String url)
protected void
setClassUnderTest(Class<?> c)
void
setDirectoryForPersistingTestBundles(File directoryForPersistingTestBundles)
void
setEnableLogging(boolean enableLogging)
void
setHttpTimeoutSeconds(int tm)
Set HTTP connect and read timeouts, defaults to the "test ready timeout" valuevoid
setPreventToUninstallBundle(boolean preventToUninstallTestBundle)
void
setServerCredentials(String username, String password)
Set the credentials to use to install our test bundle on the servervoid
setTestReadyTimeoutSeconds(int tm)
Define how long to wait for our test to be ready on the server-side, after installing the test bundlevoid
setTestServletPath(String testServletPath)
void
setWaitForServiceTimoutSeconds(int tm)
Define how long to wait to get a service reference.void
setWebConsoleReadyTimeoutSeconds(int tm)
Define how long to wait for the webconsole to be ready, before installing the test bundle
-
-
-
Field Detail
-
DEFAULT_TEST_READY_TIMEOUT_SECONDS
public static final int DEFAULT_TEST_READY_TIMEOUT_SECONDS
- See Also:
- Constant Field Values
-
DEFAULT_TEST_SERVLET_PATH
public static final String DEFAULT_TEST_SERVLET_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
setBaseUrl
public void setBaseUrl(String url)
-
setClassUnderTest
protected void setClassUnderTest(Class<?> c)
- Overrides:
setClassUnderTest
in classorg.apache.sling.junit.rules.TeleporterRule
-
setTestReadyTimeoutSeconds
public void setTestReadyTimeoutSeconds(int tm)
Define how long to wait for our test to be ready on the server-side, after installing the test bundle
-
setWebConsoleReadyTimeoutSeconds
public void setWebConsoleReadyTimeoutSeconds(int tm)
Define how long to wait for the webconsole to be ready, before installing the test bundle
-
setHttpTimeoutSeconds
public void setHttpTimeoutSeconds(int tm)
Set HTTP connect and read timeouts, defaults to the "test ready timeout" value
-
getHttpTimeoutSeconds
public int getHttpTimeoutSeconds()
Get HTTP connect and read timeouts, defaults to the "test ready timeout" value
-
setWaitForServiceTimoutSeconds
public void setWaitForServiceTimoutSeconds(int tm)
Define how long to wait to get a service reference. This applies only on the server-side when using theTeleporterRule.getService(Class)
orTeleporterRule.getService(Class, String)
methods.
-
setServerCredentials
public void setServerCredentials(String username, String password)
Set the credentials to use to install our test bundle on the server
-
setTestServletPath
public void setTestServletPath(String testServletPath)
- Parameters:
testServletPath
- relative path to the Sling JUnit test servlet. If null, defaults to DEFAULT_TEST_SERVLET_PATH.
-
includeDependencyPrefix
public ClientSideTeleporter includeDependencyPrefix(String prefix)
Define a prefix for class names that can be embedded in the test bundle if theDependencyAnalyzer
thinks they should. Overridden byexcludeDependencyPrefix(java.lang.String)
if any conflicts arise.
-
excludeDependencyPrefix
public ClientSideTeleporter excludeDependencyPrefix(String prefix)
Define a prefix for class names that should not be embedded in the test bundle. Takes precedence overincludeDependencyPrefix(java.lang.String)
.
-
embedClass
public ClientSideTeleporter embedClass(Class<?> c)
Indicate that a specific class must be embedded in the test bundle. In theory our DependencyAnalyzer should find which classes need to be embedded, but if that does not work this method can be used as a workaround.
-
addAdditionalBundleHeader
public void addAdditionalBundleHeader(String name, String value)
Set additional bundle headers on the generated test bundle
-
setEnableLogging
public void setEnableLogging(boolean enableLogging)
-
setPreventToUninstallBundle
public void setPreventToUninstallBundle(boolean preventToUninstallTestBundle)
-
setDirectoryForPersistingTestBundles
public void setDirectoryForPersistingTestBundles(File directoryForPersistingTestBundles)
-
embedClassesDirectory
public void embedClassesDirectory(File classesDirectory) throws IOException, ClassNotFoundException
Embeds every class found in the given directory- Throws:
IOException
ClassNotFoundException
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description)
- Specified by:
apply
in interfaceorg.junit.rules.TestRule
- Overrides:
apply
in classorg.junit.rules.ExternalResource
-
-