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 Details

    • DEFAULT_TEST_READY_TIMEOUT_SECONDS

      public static final int DEFAULT_TEST_READY_TIMEOUT_SECONDS
      See Also:
    • DEFAULT_TEST_SERVLET_PATH

      public static final String DEFAULT_TEST_SERVLET_PATH
      See Also:
  • 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