- All Implemented Interfaces:
- Direct Known Subclasses:
public abstract class AbstractOnTheFlyBundleCreatorTests
- extends AbstractDependencyManagerTests
Enhanced subclass of 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
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
Import-Package entries (for packages not found in the bundle)
Please see the reference documentation for an in-depth explanation and usage
Note that in more complex scenarios, dedicated packaging tools (such as
ant scripts or maven2) should be used.
It is recommend to extend
rather then this class as the former offers sensible defaults.
- Costin Leau
|Methods inherited from class org.springframework.osgi.test.AbstractDependencyManagerTests
getLocator, getSpringDMVersion, getSpringVersion, getTestBundles, getTestBundlesNames, getTestFrameworkBundles, getTestFrameworkBundlesNames, getTestingFrameworkBundlesConfiguration, locateBundle, locateBundles, preProcessBundleContext
|Methods inherited from class org.springframework.test.AbstractSingleSpringContextTests
contextKey, createBeanDefinitionReader, customizeBeanFactory, getApplicationContext, getConfigLocations, getConfigPath, getConfigPaths, getLoadCount, loadContext, loadContextLocations, onSetUp, onTearDown, prepareApplicationContext, setDirty, setUp, tearDown
|Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, runTest, setName, toString
|Methods inherited from class junit.framework.Assert
assertEquals, 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, fail, fail, failNotEquals, failNotSame, failSame
public AbstractOnTheFlyBundleCreatorTests(String testName)
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).
By default, the Maven2 test layout is used:
- root path given as a String
protected String getBundleContentPattern()
- Returns the patterns used for identifying the resources added to the jar.
The patterns are added to the root path when performing the search. By
default, the pattern is
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.
- the patterns identifying the resources added to the jar
protected String getManifestLocation()
- Returns the location (in Spring resource style) of the manifest location
to be used. By default
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.
- the manifest location
- See Also:
protected Manifest getManifest()
- Returns the current test bundle manifest. The method tries to read the
manifest from the given location; in case the location is
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
containing default entries.
Subclasses can override this method to enhance the returned
- Manifest used for this test suite.
- See Also:
protected boolean createManifestOnlyFromTestClass()
- Indicates if the automatic manifest creation should consider only the
test class (
true) or all classes included in the test
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.
- true if only the test hierarchy is searched for dependencies or
false if all classes discovered in the test archive need to be parsed.
protected Manifest createDefaultManifest()
- Creates the default manifest in case none if found on the disk. By
default, the imports are synthetised based on the test class bytecode.
- default manifest for the jar created on the fly
protected void postProcessBundleContext(BundleContext context)
- Description copied from class:
- Post-processes the bundle context. This call back gives access to the
platform bundle context after the critical test infrastructure bundles
have been installed and started. The method is invoked after
preparing the OSGi environment for the test execution but before
any test is executed.
BundleContext belongs to the underlying OSGi
Normally, this method is called only one during the lifecycle of a
postProcessBundleContext in class
context - the platform bundle context
- See Also:
Copyright © 2006-2009 Spring Framework. All Rights Reserved.