Package org.opennms.core.test.karaf
Class KarafTestCase
- java.lang.Object
-
- org.opennms.core.test.karaf.KarafTestCase
-
public abstract class KarafTestCase extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected org.osgi.framework.BundleContext
bundleContext
protected org.apache.karaf.features.FeaturesService
featuresService
static java.lang.String
MAX_HTTP_PORT
static java.lang.String
MAX_RMI_REG_PORT
static java.lang.String
MAX_RMI_SERVER_PORT
static java.lang.String
MAX_SSH_PORT
static java.lang.String
MIN_HTTP_PORT
static java.lang.String
MIN_RMI_REG_PORT
static java.lang.String
MIN_RMI_SERVER_PORT
static java.lang.String
MIN_SSH_PORT
protected org.apache.karaf.shell.api.console.SessionFactory
sessionFactory
-
Constructor Summary
Constructors Constructor Description KarafTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFeaturesUrl(java.lang.String url)
void
before()
org.ops4j.pax.exam.Option[]
config()
This is the defaultConfiguration
for any Pax Exam tests that use this abstract base class.protected org.ops4j.pax.exam.Option[]
configAsArray()
protected java.util.List<org.ops4j.pax.exam.Option>
configAsList()
protected java.lang.String
executeCommand(java.lang.String command)
Executes a shell command and returns output as a String.protected static java.io.File
findPom(java.io.File root)
protected org.ops4j.pax.exam.options.MavenUrlReference
getFrameworkUrl()
Use the vanilla Apache Karaf container.protected static java.lang.String
getKarafVersion()
protected static java.lang.String
getOpenNMSVersion()
protected <T> T
getOsgiService(java.lang.Class<T> type)
protected java.lang.String[]
getSystemPackages()
Override this method to add system packages to the test container.protected void
installFeature(java.lang.String featureName)
protected void
installFeature(java.lang.String featureName, java.lang.String version)
protected void
installFeature(java.lang.String featureName, java.util.EnumSet<org.apache.karaf.features.FeaturesService.Option> options)
org.ops4j.pax.exam.TestProbeBuilder
probeConfiguration(org.ops4j.pax.exam.TestProbeBuilder probe)
ThisProbeBuilder
can be used to add OSGi metadata to the test probe bundle.
-
-
-
Field Detail
-
MIN_RMI_SERVER_PORT
public static final java.lang.String MIN_RMI_SERVER_PORT
- See Also:
- Constant Field Values
-
MAX_RMI_SERVER_PORT
public static final java.lang.String MAX_RMI_SERVER_PORT
- See Also:
- Constant Field Values
-
MIN_HTTP_PORT
public static final java.lang.String MIN_HTTP_PORT
- See Also:
- Constant Field Values
-
MAX_HTTP_PORT
public static final java.lang.String MAX_HTTP_PORT
- See Also:
- Constant Field Values
-
MIN_RMI_REG_PORT
public static final java.lang.String MIN_RMI_REG_PORT
- See Also:
- Constant Field Values
-
MAX_RMI_REG_PORT
public static final java.lang.String MAX_RMI_REG_PORT
- See Also:
- Constant Field Values
-
MIN_SSH_PORT
public static final java.lang.String MIN_SSH_PORT
- See Also:
- Constant Field Values
-
MAX_SSH_PORT
public static final java.lang.String MAX_SSH_PORT
- See Also:
- Constant Field Values
-
bundleContext
@Inject protected org.osgi.framework.BundleContext bundleContext
-
featuresService
@Inject protected org.apache.karaf.features.FeaturesService featuresService
-
sessionFactory
@Inject protected org.apache.karaf.shell.api.console.SessionFactory sessionFactory
-
-
Method Detail
-
getKarafVersion
protected static java.lang.String getKarafVersion()
-
findPom
protected static java.io.File findPom(java.io.File root)
-
getOpenNMSVersion
protected static java.lang.String getOpenNMSVersion()
-
before
public void before()
-
probeConfiguration
public org.ops4j.pax.exam.TestProbeBuilder probeConfiguration(org.ops4j.pax.exam.TestProbeBuilder probe)
ThisProbeBuilder
can be used to add OSGi metadata to the test probe bundle. We only use it to give the bundle a nice human-readable name of "org.opennms.core.test.karaf.test".
-
config
public org.ops4j.pax.exam.Option[] config()
This is the defaultConfiguration
for any Pax Exam tests that use this abstract base class. If you wish to add more Configuration parameters, you should callconfigAsList()
, append theOption
values to the list, and then return it in aConfiguration
function that overridesconfig()
.
-
configAsList
protected java.util.List<org.ops4j.pax.exam.Option> configAsList()
-
configAsArray
protected org.ops4j.pax.exam.Option[] configAsArray()
-
getFrameworkUrl
protected org.ops4j.pax.exam.options.MavenUrlReference getFrameworkUrl()
Use the vanilla Apache Karaf container. Override this method to use a different Karaf-compatible framework artifact.
-
getSystemPackages
protected java.lang.String[] getSystemPackages()
Override this method to add system packages to the test container.
-
addFeaturesUrl
protected void addFeaturesUrl(java.lang.String url)
-
installFeature
protected void installFeature(java.lang.String featureName)
-
installFeature
protected void installFeature(java.lang.String featureName, java.util.EnumSet<org.apache.karaf.features.FeaturesService.Option> options)
-
installFeature
protected void installFeature(java.lang.String featureName, java.lang.String version)
-
executeCommand
protected java.lang.String executeCommand(java.lang.String command)
Executes a shell command and returns output as a String. Commands have a default timeout of 10 seconds.- Parameters:
command
-- Returns:
-
getOsgiService
protected <T> T getOsgiService(java.lang.Class<T> type)
-
-