Package org.apache.sling.testing.teleporter.client

# 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.

## Nested Class Summary

## Nested classes/interfaces inherited from class org.apache.sling.junit.rules.TeleporterRule

`org.apache.sling.junit.rules.TeleporterRule.Customizer`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`DEFAULT_TEST_READY_TIMEOUT_SECONDS`
`static final String`
`DEFAULT_TEST_SERVLET_PATH`

### Fields inherited from class org.apache.sling.junit.rules.TeleporterRule

`classUnderTest, CLIENT_CLASS, CUSTOMIZER_PATTERN, embeddedResourcePaths`

## Constructor Summary

Constructors
Constructor
Description
`ClientSideTeleporter()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addAdditionalBundleHeader(String name, String value)`
Set additional bundle headers on the generated test bundle
`org.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 directory
`ClientSideTeleporter`
`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" value
`ClientSideTeleporter`
`includeDependencyPrefix(String prefix)`
Define a prefix for class names that can be embedded in the test bundle if the `DependencyAnalyzer` 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" value
`void`
`setPreventToUninstallBundle(boolean preventToUninstallTestBundle)`
`void`
`setServerCredentials(String username, String password)`
Set the credentials to use to install our test bundle on the server
`void`
`setTestReadyTimeoutSeconds(int tm)`
Define how long to wait for our test to be ready on the server-side, after installing the test bundle
`void`
`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

### Methods inherited from class org.apache.sling.junit.rules.TeleporterRule

`createInstance, customize, forClass, forClass, getService, getService, isServerSide, withResources`

### Methods inherited from class org.junit.rules.ExternalResource

`after, before`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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

## Constructor Details

### ClientSideTeleporter

public ClientSideTeleporter()

## Method Details

### setBaseUrl

public void setBaseUrl(String url)

### setClassUnderTest

protected void setClassUnderTest(Class<?> c)

Overrides:
  `setClassUnderTest` in class `org.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 the `TeleporterRule.getService(Class)` or `TeleporterRule.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 the `DependencyAnalyzer` thinks they should. Overridden by `excludeDependencyPrefix(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 over `includeDependencyPrefix(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

### getAdditionalBundleHeaders

public Map<String,String> getAdditionalBundleHeaders()

### 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 interface `org.junit.rules.TestRule`
Overrides:
  `apply` in class `org.junit.rules.ExternalResource`