org.springframework.osgi.test
Class AbstractSynchronizedOsgiTests
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
- All Implemented Interfaces:
- Test
- Direct Known Subclasses:
- AbstractDependencyManagerTests
public abstract class AbstractSynchronizedOsgiTests
- extends AbstractConfigurableOsgiTests
JUnit superclass which offers synchronization for application context
initialization. The class automatically determines
Spring powered bundles that are installed by the testing framework
and (by default), will wait for their application context to fully start.
Only after all the application contexts have been fully refreshed, the actual
test execution will commence.
The class also provides utility waiting methods for discovering Spring
application context (published as OSGi services) in case programmatic waiting
is required (for example, when installing bundles manually).
As the rest of the other classes, the behaviour of this class can be
customized by extending its methods.
- Author:
- Costin Leau, Adrian Colyer
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 |
DEFAULT_WAIT_TIME
protected static final long DEFAULT_WAIT_TIME
- See Also:
- Constant Field Values
AbstractSynchronizedOsgiTests
public AbstractSynchronizedOsgiTests()
- Default constructor. Constructs a new
AbstractSynchronizedOsgiTests
instance.
AbstractSynchronizedOsgiTests
public AbstractSynchronizedOsgiTests(String name)
- Constructs a new
AbstractSynchronizedOsgiTests
instance.
- Parameters:
name
- test name
waitOnContextCreation
protected void waitOnContextCreation(String forBundleWithSymbolicName,
long timeout)
- Waits for a Spring powered bundle, given by its symbolic name
to be fully started.
Forces the current (test) thread to wait for the a Spring application
context to be published under the given symbolic name. This method allows
waiting for full initialization of Spring OSGi bundles before starting
the actual test execution. This method will use the test bundle context
for service lookup.
- Parameters:
forBundleWithSymbolicName
- bundle symbolic nametimeout
- maximum time to wait (in seconds) for the application
context to be published
waitOnContextCreation
protected void waitOnContextCreation(BundleContext context,
String forBundleWithSymbolicName,
long timeout)
- Waits for a Spring powered bundle, given by its symbolic name,
to be fully started.
Forces the current (test) thread to wait for the a Spring application
context to be published under the given symbolic name. This method allows
waiting for full initialization of Spring OSGi bundles before starting
the actual test execution.
- Parameters:
context
- bundle context to use for service lookupforBundleWithSymbolicName
- bundle symbolic nametimeout
- maximum time to wait (in seconds) for the application
context to be published
waitOnContextCreation
protected void waitOnContextCreation(String forBundleWithSymbolicName)
- Waits for a Spring powered bundle, given by its symbolic name,
to be fully started.
This method uses the default wait time and test bundle context and is
identical to #waitOnContextCreation(bundleContext,
forBundleWithSymbolicName,
getDefaultWaitTime()
).
This method is used by the testing framework at startup before
executing the actual tests.
- Parameters:
forBundleWithSymbolicName
- bundle symbolic name- See Also:
getDefaultWaitTime()
,
waitOnContextCreation(BundleContext, String, long)
getDefaultWaitTime
protected long getDefaultWaitTime()
- Returns the test default waiting time (in seconds). Subclasses should
override this method if the
DEFAULT_WAIT_TIME
is not enough. For
more customization, consider setting
shouldWaitForSpringBundlesContextCreation()
to false and using
waitOnContextCreation(BundleContext, String, long)
.
- Returns:
- the default wait time (in seconds) for each spring bundle context
to be published as an OSGi service
shouldWaitForSpringBundlesContextCreation
protected boolean shouldWaitForSpringBundlesContextCreation()
- Indicates whether the test class should wait or not for the context
creation of Spring/OSGi bundles before executing the tests. Default is
true.
- Returns:
- true (the default) if the test will wait for spring bundle
context creation or false otherwise
postProcessBundleContext
protected void postProcessBundleContext(BundleContext platformBundleContext)
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 AbstractOsgiTests
- Parameters:
platformBundleContext
- the platform bundle context
- Throws:
Exception
- See Also:
AbstractOsgiTests.preProcessBundleContext(BundleContext)
isSpringDMManaged
protected boolean isSpringDMManaged(Bundle bundle)
- Determines if the given bundle, is Spring DM managed or not. This method
is used at startup, for waiting on all Spring DM contexts to be properly
started and published.
- Parameters:
bundle
-
- Returns:
Copyright © 2006-2009 Spring Framework. All Rights Reserved.