org.springframework.osgi.test
Class AbstractSynchronizedOsgiTests

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
                                  extended by org.springframework.osgi.test.AbstractConfigurableOsgiTests
                                      extended by org.springframework.osgi.test.AbstractSynchronizedOsgiTests
All Implemented Interfaces:
Test, org.springframework.osgi.internal.test.OsgiJUnitTest
Direct Known Subclasses:
AbstractDependencyManagerTests

public abstract class AbstractSynchronizedOsgiTests
extends AbstractConfigurableOsgiTests

JUnit superclass which offers synchronization for bundle initialization. It provides utility waiting methods for bundle initialization.

Author:
Costin Leau, Adrian Colyer

Field Summary
protected static long DEFAULT_WAIT_TIME
           
 
Fields inherited from class org.springframework.osgi.test.AbstractConfigurableOsgiTests
OSGI_FRAMEWORK_SELECTOR
 
Fields inherited from class org.springframework.osgi.test.AbstractOsgiTests
bundleContext, resourceLoader
 
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
 
Fields inherited from interface org.springframework.osgi.internal.test.OsgiJUnitTest
FOR_OSGI, FROM_OSGI, OSGI_TEST, OSGI_TEST_BUNDLE_ID
 
Constructor Summary
AbstractSynchronizedOsgiTests()
           
AbstractSynchronizedOsgiTests(String name)
           
 
Method Summary
protected  long getDefaultWaitTime()
          Return the default waiting time in seconds for waitOnContextCreation(String).
protected  void postProcessBundleContext(BundleContext platformBundleContext)
          Take care of waiting for Spring powered bundle application context creation.
protected  boolean shouldWaitForSpringBundlesContextCreation()
          Should the test class wait for the context creation of Spring/OSGi bundles before executing the tests or not?
 void waitOnContextCreation(BundleContext context, String forBundleWithSymbolicName, long timeout)
          Place the current (test) thread to wait for the a Spring application context to be published under the given symbolic name.
 void waitOnContextCreation(String forBundleWithSymbolicName)
          'Sugar' method - identical to waitOnContextCreation(AbstractOsgiTests.getBundleContext(), forBundleWithSymbolicName, getDefaultWaitTime()).
 void waitOnContextCreation(String forBundleWithSymbolicName, long timeout)
          Place the current (test) thread to wait for the a Spring application context to be published under the given symbolic name.
 
Methods inherited from class org.springframework.osgi.test.AbstractConfigurableOsgiTests
createPlatform, getBootDelegationPackages, getPlatformName
 
Methods inherited from class org.springframework.osgi.test.AbstractOsgiTests
getBundleContext, getBundleLocations, getBundles, getMandatoryBundles, getResourceLoader, getTestBundles, getTestFrameworkBundles, injectBundleContext, injectOsgiJUnitTest, osgiRunTest, osgiSetUp, osgiTearDown, preProcessBundleContext, run, runBare, setName
 
Methods inherited from class org.springframework.osgi.test.AbstractOptionalDependencyInjectionTests
createApplicationContext
 
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, 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, 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

DEFAULT_WAIT_TIME

protected static final long DEFAULT_WAIT_TIME
See Also:
Constant Field Values
Constructor Detail

AbstractSynchronizedOsgiTests

public AbstractSynchronizedOsgiTests()

AbstractSynchronizedOsgiTests

public AbstractSynchronizedOsgiTests(String name)
Method Detail

waitOnContextCreation

public void waitOnContextCreation(String forBundleWithSymbolicName,
                                  long timeout)
Place 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 -
forBundleWithSymbolicName -
timeout - time to wait (in seconds) for the application context to be published

waitOnContextCreation

public void waitOnContextCreation(BundleContext context,
                                  String forBundleWithSymbolicName,
                                  long timeout)
Place 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 -
forBundleWithSymbolicName -
timeout -

waitOnContextCreation

public void waitOnContextCreation(String forBundleWithSymbolicName)
'Sugar' method - identical to waitOnContextCreation(AbstractOsgiTests.getBundleContext(), forBundleWithSymbolicName, getDefaultWaitTime()).

Parameters:
forBundleWithSymbolicName -

getDefaultWaitTime

protected long getDefaultWaitTime()
Return the default waiting time in seconds for waitOnContextCreation(String). 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()
Should the test class wait for the context creation of Spring/OSGi bundles before executing the tests or not? Default is true.

Returns:
true if the test will wait for spring bundle context creation or false otherwise

postProcessBundleContext

protected void postProcessBundleContext(BundleContext platformBundleContext)
                                 throws Exception
Take care of waiting for Spring powered bundle application context creation.

Overrides:
postProcessBundleContext in class AbstractOsgiTests
Throws:
Exception
See Also:
AbstractOsgiTests.preProcessBundleContext(BundleContext)


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