Author: kono
Date: 2010-08-16 14:12:57 -0700 (Mon, 16 Aug 2010)
New Revision: 21401
Added:
core3/viewmodel-impl/trunk/src/test/resources/META-INF/
core3/viewmodel-impl/trunk/src/test/resources/META-INF/spring/
core3/viewmodel-impl/trunk/src/test/resources/META-INF/spring/bundle-context-test.xml
Removed:
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ViewModelImplIntegrationTest.java
Modified:
core3/viewmodel-impl/trunk/pom.xml
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ITViewModelImpl.java
Log:
Integration test had been added. This test starts viewmodel-impl bundle and
validate services defined in the Spring DM configuration files.
Modified: core3/viewmodel-impl/trunk/pom.xml
===================================================================
--- core3/viewmodel-impl/trunk/pom.xml 2010-08-16 20:45:21 UTC (rev 21400)
+++ core3/viewmodel-impl/trunk/pom.xml 2010-08-16 21:12:57 UTC (rev 21401)
@@ -36,9 +36,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <excludes>
-
<exclude>**/ViewModelImplIntegrationTest.java</exclude>
- </excludes>
+
<redirectTestOutputToFile>true</redirectTestOutputToFile>
</configuration>
</plugin>
@@ -141,42 +139,43 @@
</dependency>
-
+ <!-- Bundles required for testing -->
<dependency>
- <groupId>org.cytoscape</groupId>
- <artifactId>event-api</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-test</artifactId>
+ <version>${spring.osgi.version}</version>
+ <scope>test</scope>
</dependency>
-
-
-
-
<dependency>
<groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-test</artifactId>
- <version>1.2.1</version>
+ <artifactId>spring-osgi-annotation</artifactId>
+ <version>${spring.osgi.version}</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-extender</artifactId>
+ <version>${spring.osgi.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
<artifactId>log4j.osgi</artifactId>
<version>1.2.15-SNAPSHOT</version>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.api</artifactId>
<version>1.5.0</version>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.log4j</artifactId>
<version>1.5.0</version>
+ <scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
@@ -189,30 +188,5 @@
<version>3.6.0.v20100517</version>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-annotation</artifactId>
- <version>1.2.1</version>
- <scope>test</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.springframework.osgi</groupId>
- <artifactId>spring-osgi-extender</artifactId>
- <version>1.2.1</version>
- <type>bundle</type>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.cytoscape</groupId>
- <artifactId>test-support</artifactId>
- <version>1.0-SNAPSHOT</version>
- </dependency>
</dependencies>
-
-
-
</project>
Modified:
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
---
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-08-16 20:45:21 UTC (rev 21400)
+++
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context-osgi.xml
2010-08-16 21:12:57 UTC (rev 21401)
@@ -7,7 +7,8 @@
<!-- Import Services -->
<osgi:reference id="cyEventHelperServiceRef"
interface="org.cytoscape.event.CyEventHelper" />
- <osgi:reference id="cyServiceRegistrarRef"
interface="org.cytoscape.service.util.CyServiceRegistrar" />
+ <osgi:reference id="cyServiceRegistrarRef"
+ interface="org.cytoscape.service.util.CyServiceRegistrar" />
<!-- Export Beans as Services -->
<osgi:service id="cyNetworkViewFactoryService"
ref="cyNetworkViewFactory"
@@ -27,8 +28,7 @@
<!-- Define OSGi Service Listener -->
<osgi:set id="renderers"
interface="org.cytoscape.view.model.VisualLexicon"
cardinality="0..N">
- <osgi:listener bind-method="addVisualLexicon"
unbind-method="removeVisualLexicon"
- ref="rootVisualLexicon" />
+ <osgi:listener bind-method="addVisualLexicon"
+ unbind-method="removeVisualLexicon"
ref="rootVisualLexicon" />
</osgi:set>
-
</beans>
Modified:
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
---
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2010-08-16 20:45:21 UTC (rev 21400)
+++
core3/viewmodel-impl/trunk/src/main/resources/META-INF/spring/bundle-context.xml
2010-08-16 21:12:57 UTC (rev 21401)
@@ -6,6 +6,7 @@
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
<import resource="bundle-context-osgi.xml" />
<context:annotation-config />
Modified:
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ITViewModelImpl.java
===================================================================
---
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ITViewModelImpl.java
2010-08-16 20:45:21 UTC (rev 21400)
+++
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ITViewModelImpl.java
2010-08-16 21:12:57 UTC (rev 21401)
@@ -1,15 +1,37 @@
package org.cytoscape.viewmodel;
+import org.cytoscape.view.model.CyNetworkViewFactory;
+import org.cytoscape.view.model.RootVisualLexicon;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceReference;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
import org.springframework.osgi.util.OsgiStringUtils;
+/**
+ * Integration test for viewmodel-impl bundle.
+ *
+ * @author kono
+ *
+ */
public class ITViewModelImpl extends AbstractConfigurableBundleCreatorTests {
+ // Exported services (FROM viewmodel-impl bundle)
+ private RootVisualLexicon rootVisualLexicon;
+ private CyNetworkViewFactory cyNetworkViewFactory;
+
+ // Inject those services to this test (by setter injection)
+ public void setRootVisualLexicon(RootVisualLexicon rootVisualLexicon) {
+ this.rootVisualLexicon = rootVisualLexicon;
+ }
+
+ public void setCyNetworkViewFactory(
+ CyNetworkViewFactory cyNetworkViewFactory) {
+ this.cyNetworkViewFactory = cyNetworkViewFactory;
+ }
+
public void testOsgiPlatformStarts() throws Exception {
-
+ System.out.println("###### Starting Integration Test ######");
// Make sure bundle context exists.
assertNotNull(bundleContext);
@@ -21,40 +43,78 @@
.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
final Bundle[] bundles = bundleContext.getBundles();
- System.out
- .println("###### Integration Test OSGi System
Bundles ######");
+ Bundle viewModelImplBundle = null;
for (int i = 0; i < bundles.length; i++) {
- Bundle bundle = bundles[i];
-
System.out.println(OsgiStringUtils.nullSafeName(bundle));
+ final Bundle bundle = bundles[i];
+ final String bundleName =
OsgiStringUtils.nullSafeName(bundle);
+ System.out.println(bundleName);
+ if (bundleName.equals("org.cytoscape.viewmodel-impl"))
+ viewModelImplBundle = bundle;
ServiceReference[] services =
bundle.getRegisteredServices();
if (services != null)
for (ServiceReference ref : services)
System.out.println("\tService = " +
ref);
+ System.out.println("\n");
}
+ // Make sure viewmodel-impl bundle is running
+ assertNotNull(viewModelImplBundle);
+
+ System.out.println("###### ViewModel bundle registered.
######");
}
- public String getRootPath() {
- return "file:./target/test-classes";
+ public void testServiceReferencesExist() {
+ System.out.println("###### Starting Service Reference Tests
######");
+ final ServiceReference rootVisualLexiconServiceReference =
bundleContext
+
.getServiceReference(RootVisualLexicon.class.getName());
+ assertNotNull(rootVisualLexiconServiceReference);
+ Object beanName = rootVisualLexiconServiceReference
+
.getProperty("org.springframework.osgi.bean.name");
+ assertEquals("rootVisualLexicon", beanName);
+
+ final ServiceReference cyNetworkViewFactoryServiceReference =
bundleContext
+
.getServiceReference(CyNetworkViewFactory.class.getName());
+ assertNotNull(cyNetworkViewFactoryServiceReference);
+ beanName = cyNetworkViewFactoryServiceReference
+
.getProperty("org.springframework.osgi.bean.name");
+ assertEquals("cyNetworkViewFactory", beanName);
+
+ System.out.println("###### SR test done! ######");
}
- // protected String[] getConfigLocations() {
- // return new String[] {
- // //"file:./target/classes/META-INF/spring/bundle-context.xml",
- // // "file:./target/classes/META-INF/spring/bundle-context-osgi.xml",
- // "file:./target/test-classes/META-INF/spring/bundle-context-test.xml"
- //
- // };
- // }
+ /**
+ * Do very basic tests for injected services. Complete tests for all
methods
+ * will be done in the Unit tests.
+ *
+ */
+ public void testInjectedServices() {
+ System.out.println("###### Simple tests for injected services
######");
+ assertNotNull(rootVisualLexicon);
+ assertNotNull(cyNetworkViewFactory);
+ System.out.println("###### Injected services pass the tests.
######");
+ }
+ /**
+ * Specify Spring DM config file to import registered services by
+ * viewmodel-impl bundle.
+ *
+ */
+ @Override
+ protected String[] getConfigLocations() {
+ return new String[] {
"file:./target/test-classes/META-INF/spring/bundle-context-test.xml" };
+ }
+
+ /**
+ * Import bundles required to run viewmodel-impl bundle.
+ */
+ @Override
protected String[] getTestBundlesNames() {
- return new String[] {
- "org.cytoscape, event-api, 1.0-SNAPSHOT",
+ return new String[] { "org.cytoscape, event-api, 1.0-SNAPSHOT",
+ "org.cytoscape, event-impl, 1.0-SNAPSHOT",
"org.cytoscape, model-api, 1.0-SNAPSHOT",
"org.cytoscape, service-util, 1.0-SNAPSHOT",
- "org.cytoscape, viewmodel-api, 1.0-SNAPSHOT"
- };
+ "org.cytoscape, viewmodel-api, 1.0-SNAPSHOT",
+ "org.cytoscape, viewmodel-impl, 1.0-SNAPSHOT",
};
}
-
}
Deleted:
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ViewModelImplIntegrationTest.java
===================================================================
---
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ViewModelImplIntegrationTest.java
2010-08-16 20:45:21 UTC (rev 21400)
+++
core3/viewmodel-impl/trunk/src/test/java/org/cytoscape/viewmodel/ViewModelImplIntegrationTest.java
2010-08-16 21:12:57 UTC (rev 21401)
@@ -1,45 +0,0 @@
-package org.cytoscape.viewmodel;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Constants;
-import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
-import org.springframework.osgi.util.OsgiStringUtils;
-
-public class ViewModelImplIntegrationTest extends
- AbstractConfigurableBundleCreatorTests {
-
- public void testOsgiPlatformStarts() throws Exception {
-
- // Make sure bundle context exists.
- assertNotNull(bundleContext);
-
- System.out.println(bundleContext
- .getProperty(Constants.FRAMEWORK_VENDOR));
- System.out.println(bundleContext
- .getProperty(Constants.FRAMEWORK_VERSION));
- System.out.println(bundleContext
-
.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
-
- final Bundle[] bundles = bundleContext.getBundles();
- System.out.println("###### OSGi System Bundles ######");
- for (int i = 0; i < bundles.length; i++) {
-
System.out.println(OsgiStringUtils.nullSafeName(bundles[i]));
- }
- }
-
- public String getRootPath() {
- return "file:./target/test-classes";
- }
-
-// protected String[] getConfigLocations() {
-// return new String[] {
-//
"file:./target/classes/META-INF/spring/bundle-context.xml",
-//
"file:./target/classes/META-INF/spring/bundle-context-osgi.xml" };
-// }
-
-// @Override
-// protected String[] getTestBundlesNames() {
-// return new String[] { "org.cytoscape, viewmodel-api,
1.0-SNAPSHOT", "org.cytoscape, service-util, 1.0-SNAPSHOT", "org.cytoscape,
model-api, 1.0-SNAPSHOT", "org.cytoscape, viewmodel-impl, 1.0-SNAPSHOT",
"org.cytoscape, event-api, 1.0-SNAPSHOT" };
-// }
-
-}
Added:
core3/viewmodel-impl/trunk/src/test/resources/META-INF/spring/bundle-context-test.xml
===================================================================
---
core3/viewmodel-impl/trunk/src/test/resources/META-INF/spring/bundle-context-test.xml
(rev 0)
+++
core3/viewmodel-impl/trunk/src/test/resources/META-INF/spring/bundle-context-test.xml
2010-08-16 21:12:57 UTC (rev 21401)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd"
+ default-lazy-init="false">
+
+ <!-- Import services for testing -->
+ <osgi:reference id="rootVisualLexiconServiceRef"
+ interface="org.cytoscape.view.model.RootVisualLexicon" />
+ <osgi:reference id="cyNetworkViewFactoryServiceRef"
+ interface="org.cytoscape.view.model.CyNetworkViewFactory" />
+
+</beans>
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.