public abstract class AbstractOnTheFlyBundleCreatorTests extends AbstractDependencyManagerTests
AbstractDependencyManagerTests that facilitates
OSGi testing by creating at runtime, on the fly, a jar using the indicated
manifest and resource patterns (by default all files found under the root
path).
The test class can automatically determine the imports required by the
test, create the OSGi bundle manifest and pack the test and its resources in
a jar that can be installed inside an OSGi platform.
Additionally, a valid OSGi manifest is automatically created for the
resulting test if the user does not provide one. The classes present in the
archive are analyzed and based on their byte-code, the required
Import-Package entries (for packages not found in the bundle)
are created.
Please see the reference documentation for an in-depth explanation and usage
examples.
Note that in more complex scenarios, dedicated packaging tools (such as
ant scripts or maven2) should be used.
It is recommend to extend AbstractConfigurableBundleCreatorTests
rather then this class as the former offers sensible defaults.DEFAULT_WAIT_TIMEOSGI_FRAMEWORK_SELECTORresourceLoaderbundleContextAUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NOapplicationContextlogger| Constructor and Description |
|---|
AbstractOnTheFlyBundleCreatorTests() |
AbstractOnTheFlyBundleCreatorTests(String testName) |
| Modifier and Type | Method and Description |
|---|---|
protected Manifest |
createDefaultManifest()
Creates the default manifest in case none if found on the disk.
|
protected boolean |
createManifestOnlyFromTestClass()
Indicates if the automatic manifest creation should consider only the
test class (
true) or all classes included in the test
bundle(false). |
protected String[] |
getBundleContentPattern()
Returns the patterns used for identifying the resources added to the jar.
|
protected Manifest |
getManifest()
Returns the current test bundle manifest.
|
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 void |
postProcessBundleContext(org.osgi.framework.BundleContext context)
Post-processes the bundle context.
|
getLocator, 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, toStringpublic AbstractOnTheFlyBundleCreatorTests()
public AbstractOnTheFlyBundleCreatorTests(String testName)
protected String getRootPath()
"file:./target/test-classes"
will be resolved and used.protected 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.protected String getManifestLocation()
null 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.getManifest(),
createDefaultManifest()protected Manifest getManifest()
null (default), it will search for
META-INF/MANIFEST.MF file in jar content (as specified
through the patterns) and, if it cannot find the file,
automatically create a Manifest object
containing default entries.
Subclasses can override this method to enhance the returned
Manifest.createDefaultManifest()protected boolean createManifestOnlyFromTestClass()
true) or all classes included in the test
bundle(false). The latter should be used when the test
bundle contains additional classes that help with the test case.
By default, this method returns true, meaning that
only the test class will be searched for dependencies.protected Manifest createDefaultManifest()
protected 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 AbstractSynchronizedOsgiTestscontext - the platform bundle contextExceptionAbstractOsgiTests.preProcessBundleContext(BundleContext)Copyright © 2006–2023. All rights reserved.