|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.springframework.test.ConditionalTestCase
org.springframework.test.AbstractSpringContextTests
org.springframework.test.AbstractSingleSpringContextTests
org.springframework.test.AbstractDependencyInjectionSpringContextTests
org.eclipse.gemini.blueprint.test.AbstractOptionalDependencyInjectionTests
org.eclipse.gemini.blueprint.test.AbstractOsgiTests
org.eclipse.gemini.blueprint.test.AbstractConfigurableOsgiTests
org.eclipse.gemini.blueprint.test.AbstractSynchronizedOsgiTests
org.eclipse.gemini.blueprint.test.AbstractDependencyManagerTests
org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests
org.eclipse.gemini.blueprint.test.AbstractConfigurableBundleCreatorTests
public abstract class AbstractConfigurableBundleCreatorTests
Abstract JUnit base class that allows easy OSGi integration testing. It builds on its super classes to allow full configuration of the underlying OSGi platform implementation, of the test bundle creation (including the manifest automatic generation).
This class follows the traditional Spring style of integration testing in which the test simply indicates the dependencies, leaving the rest of the work to be done by its super classes. Consider the following simple example:
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 point
AbstractOnTheFlyBundleCreatorTests| Field Summary | |
|---|---|
protected static String |
INCLUDE_PATTERNS
|
protected static String |
LIBS
|
protected static String |
MANIFEST
|
protected static String |
ROOT_DIR
|
| Fields inherited from class org.eclipse.gemini.blueprint.test.AbstractSynchronizedOsgiTests |
|---|
DEFAULT_WAIT_TIME |
| Fields inherited from class org.eclipse.gemini.blueprint.test.AbstractConfigurableOsgiTests |
|---|
OSGI_FRAMEWORK_SELECTOR |
| Fields inherited from class org.eclipse.gemini.blueprint.test.AbstractOsgiTests |
|---|
resourceLoader |
| Fields inherited from class org.eclipse.gemini.blueprint.test.AbstractOptionalDependencyInjectionTests |
|---|
bundleContext |
| Fields inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
|---|
AUTOWIRE_BY_NAME, AUTOWIRE_BY_TYPE, AUTOWIRE_NO |
| Fields inherited from class org.springframework.test.AbstractSingleSpringContextTests |
|---|
applicationContext |
| Fields inherited from class org.springframework.test.ConditionalTestCase |
|---|
logger |
| Constructor Summary | |
|---|---|
AbstractConfigurableBundleCreatorTests()
|
|
| Method Summary | |
|---|---|
protected String[] |
getBundleContentPattern()
Returns the patterns used for identifying the resources added to the jar. Ant-style patterns for identifying the resources added to the jar.The patterns are considered from the root path when performing the search. |
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. |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractOnTheFlyBundleCreatorTests |
|---|
createDefaultManifest, createManifestOnlyFromTestClass, getManifest |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractDependencyManagerTests |
|---|
getLocator, getSpringDMVersion, getSpringVersion, getTestBundles, getTestBundlesNames, getTestFrameworkBundles, getTestFrameworkBundlesNames, getTestingFrameworkBundlesConfiguration, locateBundle, locateBundles, preProcessBundleContext |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractSynchronizedOsgiTests |
|---|
getDefaultWaitTime, isSpringDMManaged, shouldWaitForSpringBundlesContextCreation, waitOnContextCreation, waitOnContextCreation, waitOnContextCreation |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractConfigurableOsgiTests |
|---|
createPlatform, getBootDelegationPackages, getPlatformName |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractOsgiTests |
|---|
run, runBare |
| Methods inherited from class org.eclipse.gemini.blueprint.test.AbstractOptionalDependencyInjectionTests |
|---|
createApplicationContext, isContextKeyEmpty |
| Methods inherited from class org.springframework.test.AbstractDependencyInjectionSpringContextTests |
|---|
getAutowireMode, injectDependencies, isDependencyCheck, isPopulateProtectedVariables, prepareTestInstance, setAutowireMode, setDependencyCheck, setPopulateProtectedVariables |
| 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 org.springframework.test.AbstractSpringContextTests |
|---|
addContext, contextKeyString, getContext, hasCachedContext, setDirty |
| Methods inherited from class org.springframework.test.ConditionalTestCase |
|---|
getDisabledTestCount, isDisabledInThisEnvironment, recordDisabled |
| 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, format |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final String ROOT_DIR
protected static final String INCLUDE_PATTERNS
protected static final String LIBS
protected static final String MANIFEST
| Constructor Detail |
|---|
public AbstractConfigurableBundleCreatorTests()
| Method Detail |
|---|
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 fails
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 AbstractOnTheFlyBundleCreatorTestscontext - the platform bundle context
ExceptionAbstractOsgiTests.preProcessBundleContext(BundleContext)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||