org.springframework.osgi.test
Class AbstractOsgiTests

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.springframework.test.ConditionalTestCase
              extended by org.springframework.test.AbstractSpringContextTests
                  extended by org.springframework.test.AbstractSingleSpringContextTests
                      extended by org.springframework.test.AbstractDependencyInjectionSpringContextTests
                          extended by org.springframework.osgi.test.AbstractOptionalDependencyInjectionTests
                              extended by org.springframework.osgi.test.AbstractOsgiTests
All Implemented Interfaces:
Test
Direct Known Subclasses:
AbstractConfigurableOsgiTests

public abstract class AbstractOsgiTests
extends AbstractOptionalDependencyInjectionTests

Base test for OSGi environments. Takes care of configuring the chosen OSGi platform, starting it, installing a number of bundles and delegating the test execution to a test copy that runs inside OSGi.

Author:
Costin Leau

Field Summary
protected  ResourceLoader resourceLoader
           
 
Fields inherited from class org.springframework.osgi.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
AbstractOsgiTests()
          Default constructor.
AbstractOsgiTests(String name)
          Constructs a new AbstractOsgiTests instance.
 
Method Summary
protected abstract  OsgiPlatform createPlatform()
          Creates (and configures) the OSGi platform.
protected abstract  Resource[] getTestBundles()
          Returns the bundles required for the test execution.
protected abstract  Resource[] getTestFrameworkBundles()
          Returns the test framework bundles (part of the test setup).
protected  void postProcessBundleContext(BundleContext platformBundleContext)
          Post-processes the bundle context.
protected  void preProcessBundleContext(BundleContext platformBundleContext)
          Pre-processes the bundle context.
 void run(TestResult result)
          

Replacement run method.

 void runBare()
           
 
Methods inherited from class org.springframework.osgi.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, 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

resourceLoader

protected ResourceLoader resourceLoader
Constructor Detail

AbstractOsgiTests

public AbstractOsgiTests()
Default constructor. Constructs a new AbstractOsgiTests instance.


AbstractOsgiTests

public AbstractOsgiTests(String name)
Constructs a new AbstractOsgiTests instance.

Parameters:
name - test name
Method Detail

getTestFrameworkBundles

protected abstract Resource[] getTestFrameworkBundles()
Returns the test framework bundles (part of the test setup). Used by the test infrastructure. Override this method only if you want to change the jars used by default, by the testing infrastructure. User subclasses should use getTestBundles() instead.

Returns:
the array of test framework bundle resources

getTestBundles

protected abstract Resource[] getTestBundles()
Returns the bundles required for the test execution.

Returns:
the array of bundles to install

createPlatform

protected abstract OsgiPlatform createPlatform()
                                        throws Exception
Creates (and configures) the OSGi platform.

Returns:
OSGi platform instance
Throws:
Exception - if the platform creation fails

preProcessBundleContext

protected void preProcessBundleContext(BundleContext platformBundleContext)
                                throws Exception
Pre-processes the bundle context. This call back gives access to the platform bundle context before any bundles have been installed. The method is invoked after starting the OSGi environment but before any bundles are installed in the OSGi framework.

Normally, this method is called only once during the lifecycle of a test suite.

Parameters:
platformBundleContext - the platform bundle context
Throws:
Exception - if processing the bundle context fails
See Also:
postProcessBundleContext(BundleContext)

postProcessBundleContext

protected void postProcessBundleContext(BundleContext platformBundleContext)
                                 throws Exception
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.

Parameters:
platformBundleContext - the platform bundle context
Throws:
Exception
See Also:
preProcessBundleContext(BundleContext)

run

public final void run(TestResult result)

Replacement run method. Gets a hold of the TestRunner used for running this test so it can populate it with the results retrieved from OSGi.

Specified by:
run in interface Test
Overrides:
run in class TestCase

runBare

public void runBare()
             throws Throwable
Overrides:
runBare in class ConditionalTestCase
Throws:
Throwable


Copyright © 2006-2008 Spring Framework. All Rights Reserved.