org.springframework.osgi.test
Class AbstractOnTheFlyBundleCreatorTests
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.springframework.test.ConditionalTestCase
org.springframework.test.AbstractSpringContextTests
org.springframework.test.AbstractSingleSpringContextTests
org.springframework.test.AbstractDependencyInjectionSpringContextTests
org.springframework.osgi.test.AbstractOptionalDependencyInjectionTests
org.springframework.osgi.test.AbstractOsgiTests
org.springframework.osgi.test.AbstractConfigurableOsgiTests
org.springframework.osgi.test.AbstractSynchronizedOsgiTests
org.springframework.osgi.test.AbstractDependencyManagerTests
org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests
- All Implemented Interfaces:
- Test
- Direct Known Subclasses:
- AbstractConfigurableBundleCreatorTests
public abstract class AbstractOnTheFlyBundleCreatorTests
- extends AbstractDependencyManagerTests
Enhanced subclass of 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.
- Author:
- 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.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 |
AbstractOnTheFlyBundleCreatorTests
public AbstractOnTheFlyBundleCreatorTests()
AbstractOnTheFlyBundleCreatorTests
public AbstractOnTheFlyBundleCreatorTests(String testName)
getRootPath
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:
"file:./target/test-classes"
- Returns:
- root path given as a String
getBundleContentPattern
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.
- Returns:
- the patterns identifying the resources added to the jar
getManifestLocation
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.
- Returns:
- the manifest location
- See Also:
getManifest()
,
createDefaultManifest()
getManifest
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 Manifest
object
containing default entries.
Subclasses can override this method to enhance the returned
Manifest.
- Returns:
- Manifest used for this test suite.
- See Also:
createDefaultManifest()
createManifestOnlyFromTestClass
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
). 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.
- Returns:
- true if only the test hierarchy is searched for dependencies or
false if all classes discovered in the test archive need to be
parsed.
createDefaultManifest
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.
- Returns:
- default manifest for the jar created on the fly
postProcessBundleContext
protected void postProcessBundleContext(BundleContext context)
throws Exception
- Description copied from class:
AbstractOsgiTests
- 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.
The given
BundleContext
belongs to the underlying OSGi
framework.
Normally, this method is called only one during the lifecycle of a
test suite.
- Overrides:
postProcessBundleContext
in class AbstractSynchronizedOsgiTests
- Parameters:
context
- the platform bundle context
- Throws:
Exception
- See Also:
AbstractOsgiTests.preProcessBundleContext(BundleContext)
Copyright © 2006-2009 Spring Framework. All Rights Reserved.