public abstract class AbstractConfigurableBundleCreatorTests extends AbstractOnTheFlyBundleCreatorTests
public class SimpleOsgiTest extends AbstractConfigurableBundleCreatorTests {
public void testOsgiPlatformStarts() throws Exception {
System.out.println(bundleContext.getProperty(Constants.FRAMEWORK_VENDOR));
System.out.println(bundleContext.getProperty(Constants.FRAMEWORK_VERSION));
System.out.println(bundleContext.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
}
}
The above class can be ran just like any other JUnit test. Equinox
platform will be automatically started, the test will packed in an OSGi
bundle (with its manifest created automatically) which will be deployed
inside the OSGi platform. After running the test inside the OSGi environment,
the test results (whether they are exceptions or failures) will be reported
back to the running tool transparently. Please see the reference
documentation for more examples, customization tips and help on how to do
efficient and fast integration testing.
This class allows the test on-the-fly bundle (jar) can be configured
declaratively‎ by indicating the locations for:
AbstractOnTheFlyBundleCreatorTests class is the ability to create a
manifest for the test bundle on the fly, based on the classes present in the
archive.
Note: This class is the main testing framework entry pointAbstractOnTheFlyBundleCreatorTests| Modifier and Type | Field and Description |
|---|---|
protected static String |
INCLUDE_PATTERNS |
protected static String |
LIBS |
protected static String |
MANIFEST |
protected static String |
ROOT_DIR |
DEFAULT_WAIT_TIMEOSGI_FRAMEWORK_SELECTORresourceLoaderbundleContextAUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NOapplicationContextlogger| Constructor and Description |
|---|
AbstractConfigurableBundleCreatorTests() |
| Modifier and Type | Method and Description |
|---|---|
protected String[] |
getBundleContentPattern()
Returns the patterns used for identifying the resources added to the jar.
|
protected Properties |
getDefaultSettings()
Returns the default settings used when creating the jar, in case no
customisations have been applied.
|
protected String |
getManifestLocation()
Returns the location (in Spring resource style) of the manifest location
to be used.
|
protected String |
getRootPath()
Returns the root path used for locating the resources that will be packed
in the test bundle (the root path does not become part of the jar).
|
protected Properties |
getSettings()
Returns the settings used for creating this jar.
|
protected String |
getSettingsLocation()
Returns the settings location (by default, the test name; i.e.
|
protected void |
postProcessBundleContext(org.osgi.framework.BundleContext context)
Post-processes the bundle context.
|
createDefaultManifest, createManifestOnlyFromTestClass, getManifestgetLocator, getSpringDMVersion, getSpringVersion, getTestBundles, getTestBundlesNames, getTestFrameworkBundles, getTestFrameworkBundlesNames, getTestingFrameworkBundlesConfiguration, locateBundle, locateBundles, preProcessBundleContextgetDefaultWaitTime, isSpringDMManaged, shouldWaitForSpringBundlesContextCreation, waitOnContextCreation, waitOnContextCreation, waitOnContextCreationcreatePlatform, getBootDelegationPackages, getPlatformNamerun, runBarecreateApplicationContext, isContextKeyEmptygetAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariablescontextKey, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigLocations, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, onSetUp, onTearDown, prepareApplicationContext, setDirty, setUp, tearDownaddContext, contextKeyString, getContext, hasCachedContext, setDirtygetDisabledTestCount, isDisabledInThisEnvironment, recordDisabledassertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runTest, setName, toStringprotected static final String ROOT_DIR
protected static final String INCLUDE_PATTERNS
protected static final String LIBS
protected static final String MANIFEST
public AbstractConfigurableBundleCreatorTests()
protected String getRootPath()
AbstractOnTheFlyBundleCreatorTests"file:./target/test-classes"
will be resolved and used.getRootPath in class AbstractOnTheFlyBundleCreatorTestsprotected String[] getBundleContentPattern()
**/*.
In large test environments, performance can be improved by limiting
the resource added to the bundle by selecting only certain packages or
classes. This results in a small test bundle which is faster to create,
deploy and install.
Ant-style patterns for identifying the resources added to the jar.The
patterns are considered from the root path when performing the search.
By default, the content pattern is **/* which
includes all sources from the root. One can configure the pattern to
include specific files by using different patterns. For example, to
include just the classes, XML and properties files one can use the
following patterns:
**/*.class for classes
**/*.xml for XML files
**/*.properties for properties files
getBundleContentPattern in class AbstractOnTheFlyBundleCreatorTestsprotected String getManifestLocation()
AbstractOnTheFlyBundleCreatorTestsnull is returned, indicating that
the manifest should be picked up from the bundle content (if it's
available) or be automatically created based on the test class imports.getManifestLocation in class AbstractOnTheFlyBundleCreatorTestsAbstractOnTheFlyBundleCreatorTests.getManifest(),
AbstractOnTheFlyBundleCreatorTests.createDefaultManifest()protected String getSettingsLocation()
foo.bar.SomeTest will try to load
foo/bar/SomeTest-bundle.properties).protected Properties getDefaultSettings()
getSettingsLocation()protected Properties getSettings() throws Exception
getSettingsLocation(). If no file is found, the default
settings will be used.
A non-null properties object will always be returned.Exception - if loading the settings file failsprotected void postProcessBundleContext(org.osgi.framework.BundleContext context)
throws Exception
AbstractOsgiTestsBundleContext belongs to the underlying OSGi framework.
Normally, this method is called only one during the lifecycle of a test suite.postProcessBundleContext in class AbstractOnTheFlyBundleCreatorTestscontext - the platform bundle contextExceptionAbstractOsgiTests.preProcessBundleContext(BundleContext)Copyright © 2006–2023. All rights reserved.