## page was renamed from Cytoscape_3.0/Developer/Testing/Integration = Integration Test with OSGi, Spring DM, and Maven = == Status == * Still under construction - KeiichiroOno (8/16/2010) == Introduction == From Cytoscape 3, all modules are OSGi bundles. This means unit tests are not enough to verify the bundle is actually working or not on the OSGi framework because unit tests does not validate configuration files for Spring. To test the bundle's functionality, you need to write an integration test. == Automate Integration Test == You can integrate integration test to your build process by Maven. The following is the step-by-step instruction how to write an integration test for implementation bundles, which are actually import/export OSGi services. === Pom File === Integration test should be executed ''AFTER'' your code passes the unit tests. To run separate test suite as an integration test, you need to use [[http://maven.apache.org/plugins/maven-failsafe-plugin/|maven-failsafe-plugin]]. You need to add the following section to your pom file: {{{#!xml org.apache.maven.plugins maven-failsafe-plugin 2.6 integration-test integration-test verify verify }}} === Log4j Props === It is very hard to understand what's going on in the test process without watching log from Spring Extender. To watch log messages from Spring, you need to add '''log4j.properties''' file in '''''src/test/resources/''''': {{{ log4j.rootCategory=info, stdout log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout.ConversionPattern=%t %p [%c] - %m%n log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.threshold=TRACE log4j.logger.org.springframework=INFO log4j.logger.org.springframework.osgi.test=INFO }}} === Test Code === Integration test code is very similar to standard JUnit test cases. To use testing framework by Spring, you need to use '''''AbstractConfigurableBundleCreatorTests''''' {{{#!java // Use IT*.java for Integration tests public class ITViewModelImpl extends AbstractConfigurableBundleCreatorTests { // Your test code } }}} The test class file should start with ''IT''. Complete example code is available here: http://chianti.ucsd.edu/svn/core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ITViewModelImpl.java To learn more about the Spring's testing framework, please read this document: http://static.springsource.org/osgi/docs/current/reference/html/testing.html === Configuration File for Testing === In the test, you need to import services from the target bundle and check it's actually working or not. In the following example, integration test imports two OSGi services exported by viewmodel-impl: {{{ }}} Example project with integration test is available here: http://chianti.ucsd.edu/svn/core3/viewmodel-impl/trunk/