Class KarafConsole

java.lang.Object
org.apache.karaf.itests.KarafTestSupport
org.codice.ddf.itests.common.KarafConsole

public class KarafConsole extends org.apache.karaf.itests.KarafTestSupport
Class that provides access to the Karaf Console.

Note: This class is needed to expose the protected methods provided by KarafTestSupport. Since we already extend from our own base class, out test classes cannot extend from this one to access its protected methods.

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.karaf.itests.KarafTestSupport

    org.apache.karaf.itests.KarafTestSupport.Retry
  • Field Summary

    Fields inherited from class org.apache.karaf.itests.KarafTestSupport

    baseTestWatcher, bundleContext, configurationAdmin, featureService, MAX_HTTP_PORT, MAX_RMI_REG_PORT, MAX_RMI_SERVER_PORT, MAX_SSH_PORT, MIN_HTTP_PORT, MIN_RMI_REG_PORT, MIN_RMI_SERVER_PORT, MIN_SSH_PORT, retry, sessionFactory
  • Constructor Summary

    Constructors
    Constructor
    Description
    KarafConsole(org.osgi.framework.BundleContext bundleContext, org.apache.karaf.features.FeaturesService featuresService, org.apache.karaf.shell.api.console.SessionFactory sessionFactory)
    Karaf console constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    runCommand(String command)
    Runs a shell command and returns output as a String.
    runCommand(String command, long timeout)
    Runs a shell command and returns output as a String.
    runCommand(String command, long timeout, Principal... principals)
    Runs a shell command and returns output as a String.
    runCommand(String command, Principal... principals)
    Runs a shell command and returns output as a String.

    Methods inherited from class org.apache.karaf.itests.KarafTestSupport

    addFeaturesRepository, assertBundleInstalled, assertBundleNotInstalled, assertContains, assertContainsNot, assertFeatureInstalled, assertFeatureInstalled, assertFeatureNotInstalled, assertFeatureNotInstalled, assertFeaturesInstalled, assertServiceAvailable, assertServiceAvailable, assertServiceAvailable, assertServiceAvailable, close, config, executeAlias, executeAlias, executeCommand, executeCommand, findBundleByName, getAvailablePort, getConfigFile, getHttpPort, getJMXConnector, getJMXConnector, getJmxServiceUrl, getKarafDistribution, getOsgiService, getOsgiService, getOsgiService, getOsgiService, getOsgiService, getSshPort, installAndAssertFeature, installAssertAndUninstallFeature, installAssertAndUninstallFeatures, installBundle, probeConfiguration, uninstallNewFeatures, waitBundleState, waitForService

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KarafConsole

      public KarafConsole(org.osgi.framework.BundleContext bundleContext, org.apache.karaf.features.FeaturesService featuresService, org.apache.karaf.shell.api.console.SessionFactory sessionFactory)
      Karaf console constructor.
      Parameters:
      bundleContext - bundle context to use when using the console. Cannot be null.
  • Method Details

    • runCommand

      public String runCommand(String command, long timeout, Principal... principals)
      Runs a shell command and returns output as a String. Commands have a default timeout of 10 seconds.
      Parameters:
      command - command to execute. Cannot be null.
      timeout - command timeout in milliseconds
      principals - principals (e.g. RolePrincipal objects) to run the command under (optional)
      Returns:
      command output. Can be empty but not null.
    • runCommand

      public String runCommand(String command, Principal... principals)
      Runs a shell command and returns output as a String. Commands have a default timeout of 10 seconds.
      Parameters:
      command - command to execute. Cannot be null.
      principals - principals (e.g. RolePrincipal objects) to run the command under (optional)
      Returns:
      command output. Can be empty but not null.
    • runCommand

      public String runCommand(String command)
      Runs a shell command and returns output as a String. Commands have a default timeout of 10 seconds. Uses the DEFAULT_ROLES to execute the command as an administrator.
      Parameters:
      command - command to execute. Cannot be null.
      Returns:
      command output. Can be empty but not null.
    • runCommand

      public String runCommand(String command, long timeout)
      Runs a shell command and returns output as a String. The command will timeout after the supplied timeout (in milliseconds). Uses the DEFAULT_ROLES to execute the command as an administrator.
      Parameters:
      command - command to execute. Cannot be null.
      timeout - command timeout in milliseconds.
      Returns:
      command output. Can be empty but not null.