Author: mes
Date: 2010-08-17 12:00:20 -0700 (Tue, 17 Aug 2010)
New Revision: 21406
Added:
core3/integration-test-support/trunk/
core3/integration-test-support/trunk/osgi.bnd
core3/integration-test-support/trunk/pom.xml
core3/integration-test-support/trunk/src/
core3/integration-test-support/trunk/src/main/
core3/integration-test-support/trunk/src/main/java/
core3/integration-test-support/trunk/src/main/java/org/
core3/integration-test-support/trunk/src/main/java/org/cytoscape/
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
Log:
inital creation
Added: core3/integration-test-support/trunk/osgi.bnd
===================================================================
--- core3/integration-test-support/trunk/osgi.bnd
(rev 0)
+++ core3/integration-test-support/trunk/osgi.bnd 2010-08-17 19:00:20 UTC
(rev 21406)
@@ -0,0 +1,6 @@
+#-----------------------------------------------------------------
+# Use this file to add customized Bnd instructions for the bundle
+#-----------------------------------------------------------------
+
+Export-Package: ${bundle.namespace}
+
Added: core3/integration-test-support/trunk/pom.xml
===================================================================
--- core3/integration-test-support/trunk/pom.xml
(rev 0)
+++ core3/integration-test-support/trunk/pom.xml 2010-08-17 19:00:20 UTC
(rev 21406)
@@ -0,0 +1,147 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+
+ <parent>
+ <artifactId>parent</artifactId>
+ <groupId>org.cytoscape</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <properties>
+
<bundle.symbolicName>org.cytoscape.integration-test-support</bundle.symbolicName>
+ <bundle.namespace>org.cytoscape.integration</bundle.namespace>
+ </properties>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.cytoscape</groupId>
+ <artifactId>integration-test-support</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>${bundle.symbolicName}</name>
+
+ <packaging>bundle</packaging>
+
+ <repositories>
+ <!-- bootstrap for cytoscape , namely the parent POM snapshots
-->
+ <repository>
+ <id>cytoscape_snapshots</id>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <name>Cytoscape Snapshots</name>
+
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/snapshots/</url>
+ </repository>
+ <!-- bootstrap for cytoscape d, namely the parent POM releases
-->
+ <repository>
+ <id>cytoscape_releases</id>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <name>Cytoscape Releases</name>
+
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/releases/</url>
+ </repository>
+
+ <repository>
+ <id>i21-s3-osgi-repo</id>
+ <name>i21 osgi artifacts repo</name>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <url>http://maven.springframework.org/osgi</url>
+ </repository>
+ </repositories>
+
+
+ <build>
+ <plugins>
+ <!--
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <configuration>
+ <descriptorRefs>
+ <descriptorRef>jar-with-dependencies</descriptorRef>
+ </descriptorRefs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ -->
+ <plugin>
+ <groupId>org.ops4j</groupId>
+ <artifactId>maven-pax-plugin</artifactId>
+ <version>1.4</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.3</version>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${bundle.symbolicName}</Bundle-SymbolicName>
+ <Bundle-Version>${pom.version}</Bundle-Version>
+ <_include>-osgi.bnd</_include>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-test</artifactId>
+ <version>${spring.osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-annotation</artifactId>
+ <version>${spring.osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>spring-osgi-extender</artifactId>
+ <version>${spring.osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.osgi</groupId>
+ <artifactId>log4j.osgi</artifactId>
+ <version>1.2.15-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.api</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>com.springsource.slf4j.log4j</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+
<artifactId>com.springsource.slf4j.org.apache.commons.logging</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.sonatype.tycho</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.6.0.v20100517</version>
+ </dependency>
+ </dependencies>
+</project>
Added:
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
===================================================================
---
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
(rev 0)
+++
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
2010-08-17 19:00:20 UTC (rev 21406)
@@ -0,0 +1,124 @@
+package org.cytoscape.integration;
+
+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;
+
+/**
+ * This is a simple wrapper class that when constructed properly verifies that
+ * the expected services are exported given the Spring bundle-config-osgi.xml
+ * configuration. This class should be used by every module that uses Spring-DM
+ * to verify that the configuration is functional. To use this class simply
+ * extend the class and call the constructor with the proper configuration
+ * information for your bundle.
+ * <br>
+ * Here is a simple example
+ * <code>
+package org.cytoscape.viewmodel;
+
+import org.cytoscape.view.model.CyNetworkViewFactory;
+import org.cytoscape.view.model.RootVisualLexicon;
+import org.cytoscape.integration.AbstractIntegrationTester;
+
+public class ITViewModelImpl extends AbstractIntegrationTester {
+
+ public ITViewModelImpl() {
+ super( // bundle name
+ "org.cytoscape.viewmodel-impl",
+
+ // necessary bundles to run in the form: groupId, artifactId,
version
+ new String[] { "org.cytoscape, event-api, 1.0",
+ "org.cytoscape, event-impl, 1.0",
+ "org.cytoscape, model-api, 1.0",
+ "org.cytoscape, integration-test-support, 1.0",
+ "org.cytoscape, service-util, 1.0",
+ "org.cytoscape, viewmodel-api, 1.0",
+ "org.cytoscape, viewmodel-impl, 1.0", },
+
+ // the beans you want to test
+ new String[] { "rootVisualLexicon", "cyNetworkViewFactory" },
+
+ // the classes of the beans
+ new Class[] { RootVisualLexicon.class,
CyNetworkViewFactory.class }
+ );
+ }
+}
+ * </code>
+ */
+public class AbstractIntegrationTester extends
AbstractConfigurableBundleCreatorTests {
+
+ private String expectedBundleName;
+ private String[] dependencyBundleNames;
+ private String[] expectedBeanNames;
+ private Class[] expectedClasses;
+
+ /**
+ * The constructor that must be used to properly configure this class
so that
+ * the integration tests run as expected. The configuration being
tested is
+ * found in src/main/resources/META-INF/spring/bundle-context-osgi.xml.
+ *
+ * @param expectedBundleName The name of the bundle that you're testing.
+ * @param dependencyBundleNames The names and versions of the bundles
needed to
+ * provide the necessary OSGi services to start this bundle.
+ * @param expectedBeanNames The names of the beans that are exported as
services
+ * by this bundle and whose configuration an existance you want to
verify. This
+ * should include all services exported by this bundle.
+ * @param expectedClasses The Class object associated with each bean
being tested. This
+ * array should be the same length as teh expectedBeanNames array.
+ */
+ public AbstractIntegrationTester(String expectedBundleName,
+ String[] dependencyBundleNames,
+ String[] expectedBeanNames,
+ Class[] expectedClasses) {
+ this.expectedBundleName = expectedBundleName;
+ this.dependencyBundleNames = dependencyBundleNames;
+ this.expectedBeanNames = expectedBeanNames;
+ this.expectedClasses = expectedClasses;
+ }
+
+ public void testOsgiPlatformStarts() throws Exception {
+
+ // check bundleContext
+ assertNotNull(bundleContext);
+
+ // check that the expected bundle exists
+ for (Bundle bundle : bundleContext.getBundles()) {
+ final String bundleName =
OsgiStringUtils.nullSafeName(bundle);
+ if (bundleName.equals(expectedBundleName))
+ return;
+ }
+
+ fail("expected bundle: " + expectedBundleName + " NOT found!");
+ }
+
+ public void testServiceReferencesExist() {
+ for ( int i = 0; i < expectedBeanNames.length; i++ )
+ checkServiceReference(expectedBeanNames[i],
expectedClasses[i]);
+ }
+
+ private void checkServiceReference(String expectedBeanName, Class<?>
serviceClass) {
+ final ServiceReference ref =
bundleContext.getServiceReference(serviceClass.getName());
+ assertNotNull(ref);
+ Object beanName =
ref.getProperty("org.springframework.osgi.bean.name");
+ assertEquals(expectedBeanName, beanName);
+ }
+
+ /**
+ * 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 dependencyBundleNames;
+ }
+}
--
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.