Package org.opennms.core.test.karaf
Class KarafTestCase
- java.lang.Object
-
- org.opennms.core.test.karaf.KarafTestCase
-
public abstract class KarafTestCase extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected org.osgi.framework.BundleContext
bundleContext
protected org.apache.karaf.features.FeaturesService
featuresService
static String
MAX_HTTP_PORT
static String
MAX_RMI_REG_PORT
static String
MAX_RMI_SERVER_PORT
static String
MAX_SSH_PORT
static String
MIN_HTTP_PORT
static String
MIN_RMI_REG_PORT
static String
MIN_RMI_SERVER_PORT
static 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(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 List<org.ops4j.pax.exam.Option>
configAsList()
protected String
executeCommand(String command)
Executes a shell command and returns output as a String.protected static File
findPom(File root)
protected org.ops4j.pax.exam.options.MavenUrlReference
getFrameworkUrl()
Use the vanilla Apache Karaf container.protected static String
getKarafVersion()
protected static String
getOpenNMSVersion()
protected <T> T
getOsgiService(Class<T> type)
protected String[]
getSystemPackages()
Override this method to add system packages to the test container.protected void
installFeature(String featureName)
protected void
installFeature(String featureName, String version)
protected void
installFeature(String featureName, 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 String MIN_RMI_SERVER_PORT
- See Also:
- Constant Field Values
-
MAX_RMI_SERVER_PORT
public static final String MAX_RMI_SERVER_PORT
- See Also:
- Constant Field Values
-
MIN_HTTP_PORT
public static final String MIN_HTTP_PORT
- See Also:
- Constant Field Values
-
MAX_HTTP_PORT
public static final String MAX_HTTP_PORT
- See Also:
- Constant Field Values
-
MIN_RMI_REG_PORT
public static final String MIN_RMI_REG_PORT
- See Also:
- Constant Field Values
-
MAX_RMI_REG_PORT
public static final String MAX_RMI_REG_PORT
- See Also:
- Constant Field Values
-
MIN_SSH_PORT
public static final String MIN_SSH_PORT
- See Also:
- Constant Field Values
-
MAX_SSH_PORT
public static final 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 String getKarafVersion()
-
getOpenNMSVersion
protected static 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 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 String[] getSystemPackages()
Override this method to add system packages to the test container.
-
addFeaturesUrl
protected void addFeaturesUrl(String url)
-
installFeature
protected void installFeature(String featureName)
-
installFeature
protected void installFeature(String featureName, EnumSet<org.apache.karaf.features.FeaturesService.Option> options)
-
executeCommand
protected String executeCommand(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(Class<T> type)
-
-