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.BundleContextbundleContextprotected org.apache.karaf.features.FeaturesServicefeaturesServicestatic java.lang.StringMAX_HTTP_PORTstatic java.lang.StringMAX_RMI_REG_PORTstatic java.lang.StringMAX_RMI_SERVER_PORTstatic java.lang.StringMAX_SSH_PORTstatic java.lang.StringMIN_HTTP_PORTstatic java.lang.StringMIN_RMI_REG_PORTstatic java.lang.StringMIN_RMI_SERVER_PORTstatic java.lang.StringMIN_SSH_PORTprotected org.apache.karaf.shell.api.console.SessionFactorysessionFactory
-
Constructor Summary
Constructors Constructor Description KarafTestCase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddFeaturesUrl(java.lang.String url)voidbefore()org.ops4j.pax.exam.Option[]config()This is the defaultConfigurationfor 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.StringexecuteCommand(java.lang.String command)Executes a shell command and returns output as a String.protected static java.io.FilefindPom(java.io.File root)protected org.ops4j.pax.exam.options.MavenUrlReferencegetFrameworkUrl()Use the vanilla Apache Karaf container.protected static java.lang.StringgetKarafVersion()protected static java.lang.StringgetOpenNMSVersion()protected <T> TgetOsgiService(java.lang.Class<T> type)protected java.lang.String[]getSystemPackages()Override this method to add system packages to the test container.protected voidinstallFeature(java.lang.String featureName)protected voidinstallFeature(java.lang.String featureName, java.lang.String version)protected voidinstallFeature(java.lang.String featureName, java.util.EnumSet<org.apache.karaf.features.FeaturesService.Option> options)org.ops4j.pax.exam.TestProbeBuilderprobeConfiguration(org.ops4j.pax.exam.TestProbeBuilder probe)ThisProbeBuildercan 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)
ThisProbeBuildercan 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 defaultConfigurationfor any Pax Exam tests that use this abstract base class. If you wish to add more Configuration parameters, you should callconfigAsList(), append theOptionvalues to the list, and then return it in aConfigurationfunction 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)
-
-