org.universAAL.itests
Class IntegrationTest

Package class diagram package IntegrationTest
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
                                          extended by org.springframework.osgi.test.AbstractDependencyManagerTests
                                              extended by org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests
                                                  extended by org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests
                                                      extended by org.universAAL.itests.IntegrationTest
All Implemented Interfaces:
junit.framework.Test

public class IntegrationTest
extends org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests

This class has to be extended for the purpose of OSGi integration test implementation. IntegrationTest extends class from Spring DM framework and adds feature of setting up the TestCase with the use of Eclipse launch configuration or Pax composite files. Comment about logging: org.universAAL.middleware.container.utils.LogUtils cannot be used because BundleContext (and therefore ModuleContext) does not yet exist for the bundle in which integration tests are to be launched. Thus exceptions are simple printed out to screen.

Author:
rotgier

Nested Class Summary
 class IntegrationTest.FakeBundleContext
          The class is used for intercepting installation of test bundle.
 
Field Summary
 
Fields inherited from class org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests
INCLUDE_PATTERNS, LIBS, MANIFEST, ROOT_DIR
 
Fields inherited from class org.springframework.osgi.test.AbstractSynchronizedOsgiTests
DEFAULT_WAIT_TIME
 
Fields inherited from class org.springframework.osgi.test.AbstractConfigurableOsgiTests
OSGI_FRAMEWORK_SELECTOR
 
Fields inherited from class org.springframework.osgi.test.AbstractOsgiTests
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
protected IntegrationTest()
          Invoking noargument constructor indicates as follows: Default uAAL rundir, deployed to the nexus, is used The pax composite from project's target/artifact.composite file is launched.
protected IntegrationTest(String eclipseLaunchConfiguration)
          Invoking this constructor indicates that provided eclipse launch configuration is used for: providing set of bundles which should be started, providing run arguments, providing bundles.configuration.location (uAAL runtime configuration directory) Run arguments and bundles.configuration.location can be overridden by invocation of appropriate setter methods.
 
Method Summary
protected  String formatMsg(String format, Object... args)
          Formatting log messages with a use of String.format.
protected  String getPlatformName()
          This method informs Spring DM framework that Felix should be used as the OSGi platform for the tests.
protected  org.springframework.core.io.Resource[] getTestBundles()
          This method returns sorted list of bundles which will be started for the purpose of the TestCase.
protected  void log(String logMsg)
          Method for logging.
protected  void logAllBundles()
          Logs all bundles.
protected  void postProcessBundleContext(org.osgi.framework.BundleContext context)
          Method postProcessBundleContext has to be overridden to wrap system bundleContext into a fake one.
protected  void setBundleConfLocation(String path)
          Sets bundles.configuration.location system property.
 void setIgnoreVersionMismatch(boolean ignoreVersionMismatch)
          If set to true than version mismatch between bundle version specified in pom and bundle version specified in the manifest is ignored.
protected  void setLogLevel(int level)
          Sets felix.log.level property.
protected  void setPaxArtifactUrls(String... urls)
          Sets urls of pax artifacts which should be launched for integration testing.
protected  void setRunArguments(Properties p)
          Sets run arguments of uAAL platform.
protected  void setRunArguments(String... args)
          Sets run arguments of uAAL platform.
protected  void setUseOnlyLocalRepo(boolean useOnlyLocalRepo)
          Sets flag which can force mvn url handler to look up only local maven repository.
 
Methods inherited from class org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests
getBundleContentPattern, getDefaultSettings, getManifestLocation, getRootPath, getSettings, getSettingsLocation
 
Methods inherited from class org.springframework.osgi.test.AbstractOnTheFlyBundleCreatorTests
createDefaultManifest, createManifestOnlyFromTestClass, getManifest
 
Methods inherited from class org.springframework.osgi.test.AbstractDependencyManagerTests
getLocator, getSpringDMVersion, getSpringVersion, getTestBundlesNames, getTestFrameworkBundles, getTestFrameworkBundlesNames, getTestingFrameworkBundlesConfiguration, locateBundle, locateBundles, preProcessBundleContext
 
Methods inherited from class org.springframework.osgi.test.AbstractSynchronizedOsgiTests
getDefaultWaitTime, isSpringDMManaged, shouldWaitForSpringBundlesContextCreation, waitOnContextCreation, waitOnContextCreation, waitOnContextCreation
 
Methods inherited from class org.springframework.osgi.test.AbstractConfigurableOsgiTests
createPlatform, getBootDelegationPackages
 
Methods inherited from class org.springframework.osgi.test.AbstractOsgiTests
run, 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, 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
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, runTest, setName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntegrationTest

protected IntegrationTest()
Invoking noargument constructor indicates as follows: If there is a need to change some of above assumptions then appropriate setter method has to be invoked.


IntegrationTest

protected IntegrationTest(String eclipseLaunchConfiguration)
Invoking this constructor indicates that provided eclipse launch configuration is used for: Run arguments and bundles.configuration.location can be overridden by invocation of appropriate setter methods.

Parameters:
eclipseLaunchConfiguration - path to the launch configuration which will be used for setting up the OSGi platform in which TestCase will be executed.
Method Detail

log

protected void log(String logMsg)
Method for logging.

Parameters:
logMsg - Log message to be printed.

formatMsg

protected String formatMsg(String format,
                           Object... args)
Formatting log messages with a use of String.format.

Parameters:
format - Format in accordance with String.format API.
args - Arguments to be printed in accordance with passed format.
Returns:
Final formatted string.

logAllBundles

protected void logAllBundles()
Logs all bundles.


setLogLevel

protected void setLogLevel(int level)
Sets felix.log.level property. Acceptable values are as follows:

setRunArguments

protected void setRunArguments(String... args)
Sets run arguments of uAAL platform.

Parameters:
args - Arguments have to provided as list of strings. There has to be even number of arguments. All odd strings are interpreted as keys and all even string are interpreted as values.

setRunArguments

protected void setRunArguments(Properties p)
Sets run arguments of uAAL platform.

Parameters:
p - Properties which represent run arguments.

setPaxArtifactUrls

protected void setPaxArtifactUrls(String... urls)
Sets urls of pax artifacts which should be launched for integration testing.

Parameters:
urls - List of pax artifacts urls.

setBundleConfLocation

protected void setBundleConfLocation(String path)
Sets bundles.configuration.location system property.

Parameters:
path - Path to which bundles.configuration.location is to be set.

setUseOnlyLocalRepo

protected void setUseOnlyLocalRepo(boolean useOnlyLocalRepo)
Sets flag which can force mvn url handler to look up only local maven repository. Default value is false;

Parameters:
useOnlyLocalRepo -

setIgnoreVersionMismatch

public void setIgnoreVersionMismatch(boolean ignoreVersionMismatch)
If set to true than version mismatch between bundle version specified in pom and bundle version specified in the manifest is ignored.


getPlatformName

protected String getPlatformName()
This method informs Spring DM framework that Felix should be used as the OSGi platform for the tests.

Overrides:
getPlatformName in class org.springframework.osgi.test.AbstractConfigurableOsgiTests

postProcessBundleContext

protected void postProcessBundleContext(org.osgi.framework.BundleContext context)
                                 throws Exception
Method postProcessBundleContext has to be overridden to wrap system bundleContext into a fake one. Thanks to that installing bundle can be intercepted and JunitTestActivator can be created and started.

Overrides:
postProcessBundleContext in class org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests
Throws:
Exception

getTestBundles

protected org.springframework.core.io.Resource[] getTestBundles()
This method returns sorted list of bundles which will be started for the purpose of the TestCase. Method parses launch configuration provided in the constructor and extracts pax run arguments as well as JVM arguments. JVM arguments are then set by means of java.lang.System class. The "bundles.configuration.location" JVM argument provided in the launch configuration is ignored and the "bundlesConfLocation" property is used instead.

Overrides:
getTestBundles in class org.springframework.osgi.test.AbstractDependencyManagerTests
Returns:
Returns array of resources.


Copyright © 2014 universAAL Consortium. All Rights Reserved.