Author: mes
Date: 2010-11-18 16:52:01 -0800 (Thu, 18 Nov 2010)
New Revision: 22916

Added:
   
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/ServiceTestSupport.java
Removed:
   
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
Modified:
   core3/integration-test-support/trunk/pom.xml
Log:
refactored to provide support for pax-exam instead

Modified: core3/integration-test-support/trunk/pom.xml
===================================================================
--- core3/integration-test-support/trunk/pom.xml        2010-11-19 00:50:03 UTC 
(rev 22915)
+++ core3/integration-test-support/trunk/pom.xml        2010-11-19 00:52:01 UTC 
(rev 22916)
@@ -1,94 +1,35 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
 
-       <parent>
-               <artifactId>parent</artifactId>
-               <groupId>org.cytoscape</groupId>
-               <version>3.0.0-alpha3</version>
-       </parent>
+  <parent>
+    <artifactId>parent</artifactId>
+    <groupId>org.cytoscape</groupId>
+    <version>3.0.0-alpha4-SNAPSHOT</version>
+  </parent>
 
-       <properties>
-               
<bundle.symbolicName>org.cytoscape.integration-test-support</bundle.symbolicName>
-               <bundle.namespace>org.cytoscape.integration</bundle.namespace>
-       </properties>
+  <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>3.0.0-alpha3-SNAPSHOT</version>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.cytoscape</groupId>
+  <artifactId>integration-test-support</artifactId>
+  <version>3.0.0-alpha3-SNAPSHOT</version>
 
-       <name>${bundle.symbolicName}</name>
+  <name>${bundle.symbolicName}</name>
 
-       <packaging>bundle</packaging>
+  <packaging>bundle</packaging>
 
-       <scm>
-               
<connection>scm:svn:http://chianti.ucsd.edu/svn/core3/integration-test-support/trunk</connection>
-               
<developerConnection>scm:svn:svn+ssh://grenache.ucsd.edu/cellar/common/svn/core3/integration-test-support/trunk</developerConnection>
-               
<url>http://chianti.ucsd.edu/svn/core3/integration-test-support/trunk</url>
-       </scm>
+  <scm>
+    
<connection>scm:svn:http://chianti.ucsd.edu/svn/core3/integration-test-support/trunk</connection>
+    
<developerConnection>scm:svn:svn+ssh://grenache.ucsd.edu/cellar/common/svn/core3/integration-test-support/trunk</developerConnection>
+    <url>http://chianti.ucsd.edu/svn/core3/integration-test-support/trunk</url>
+  </scm>
 
-       <repositories>
-               <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>
-               <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>spring-osgi</id>
-                       <snapshots>
-                               <enabled>false</enabled>
-                       </snapshots>
-                       <releases>
-                               <enabled>true</enabled>
-                       </releases>
-                       <name>Cytoscape Spring OSGi Release Mirror</name>
-                       
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/spring-osgi/</url>
-               </repository>
-               <repository>
-                       <id>spring-osgi-snapshots</id>
-                       <snapshots>
-                               <enabled>true</enabled>
-                       </snapshots>
-                       <releases>
-                               <enabled>false</enabled>
-                       </releases>
-                       <name>Cytoscape Spring OSGi Snapshot Mirror</name>
-                       
<url>http://cytoscape.wodaklab.org/nexus/content/repositories/spring-osgi-snapshots/</url>
-               </repository>
-       </repositories>
-
   <build>
     <plugins>
       <plugin>
-        <inherited>false</inherited>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-release-plugin</artifactId>
-        <version>2.0</version>
-        <configuration>
-          <autoVersionSubmodules>true</autoVersionSubmodules>
-          <goals>deploy</goals>
-          <!-- special for this one because of the log4j.osgi dependency -->
-          <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
-        </configuration>
-      </plugin>
-      <plugin>
         <groupId>org.ops4j</groupId>
         <artifactId>maven-pax-plugin</artifactId>
         <version>1.4</version>
@@ -109,46 +50,26 @@
     </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>
+  <dependencies>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam</artifactId>
+      <version>1.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-junit</artifactId>
+      <version>1.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.ops4j.pax.exam</groupId>
+      <artifactId>pax-exam-container-default</artifactId>
+      <version>1.2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${junit.version}</version>
+    </dependency>
+  </dependencies>
 </project>

Deleted: 
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
 2010-11-19 00:50:03 UTC (rev 22915)
+++ 
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/AbstractIntegrationTester.java
 2010-11-19 00:52:01 UTC (rev 22916)
@@ -1,153 +0,0 @@
-package org.cytoscape.integration;
-
-import java.util.jar.Manifest;
-import org.osgi.framework.Bundle;
-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
- * <pre>
-package integration;
-
-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 },
-
-               // the package names that contain all beans being tested 
-               new String[] { "org.cytoscape.view.model" }
-               );
-    }
-}
- * </pre>
- */
-public class AbstractIntegrationTester extends 
AbstractConfigurableBundleCreatorTests {
-
-       private String expectedBundleName;
-       private String[] dependencyBundleNames;
-       private String[] expectedBeanNames;
-       private Class[] expectedClasses;
-       private String[] importPackages;
-
-       /**
-        * 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.
-        * @param importPackages This is a list of package names that must be 
imported by the
-        * built-on-the-fly integration test bundle so that all beans are seen. 
This means
-        * the package containing each bean should be listed. 
-        */
-       public AbstractIntegrationTester(String expectedBundleName,
-                                      String[] dependencyBundleNames,
-                                      String[] expectedBeanNames,
-                                      Class[] expectedClasses,
-                                   String[] importPackages) {
-               this.expectedBundleName = expectedBundleName;
-               this.dependencyBundleNames = dependencyBundleNames;
-               this.expectedBeanNames = expectedBeanNames;
-               this.expectedClasses = expectedClasses;
-               this.importPackages = importPackages;
-       }
-
-       public void testOsgiPlatformStarts() throws Exception {
-               logger.info("INTEGRATION TEST:  testOsgiPlatformStarts");
-
-               // check bundleContext
-               assertNotNull(bundleContext);
-
-               for (Bundle bundle : bundleContext.getBundles()) 
-                       logger.info("found bundle: " + 
OsgiStringUtils.nullSafeName(bundle));
-
-               // 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() {
-               logger.info("INTEGRATION TEST:  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);
-               System.out.println("############ Got OSGi Service: " + 
ref.toString());
-               Object beanName = 
ref.getProperty("org.springframework.osgi.bean.name");
-               assertEquals(expectedBeanName, beanName);
-       }
-
-       /**
-        * Import bundles required to run bundle.
-        */
-       @Override
-       protected String[] getTestBundlesNames() {
-               return dependencyBundleNames;
-       }
-
-       /**
-        * Provide correct import package metadata for on-the-fly bundle.
-        */
-       @Override
-       protected Manifest getManifest() {
-               // let the testing framework create/load the manifest
-               Manifest mf = super.getManifest();
-       
-               // get original import statement
-               String original = 
mf.getMainAttributes().getValue("Import-Package");
-       
-               // update with new packages
-               for ( String pkg : importPackages )
-                       original = original + "," + pkg;
-
-               logger.info("all import packages: " + original);
-
-               // put it back
-               mf.getMainAttributes().putValue("Import-Package", original);
-
-               return mf;
-       }
-}

Added: 
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/ServiceTestSupport.java
===================================================================
--- 
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/ServiceTestSupport.java
                                (rev 0)
+++ 
core3/integration-test-support/trunk/src/main/java/org/cytoscape/integration/ServiceTestSupport.java
        2010-11-19 00:52:01 UTC (rev 22916)
@@ -0,0 +1,54 @@
+package org.cytoscape.integration; 
+
+import static org.junit.Assert.*;
+import static org.ops4j.pax.exam.CoreOptions.*;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.*;
+import org.junit.Test;
+import org.junit.Before;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A Pax Exam support class that provides methods useful for verifying 
+ * the existance of OSGi services.
+ */
+public abstract class ServiceTestSupport {
+
+       /**
+        * The OSGi BundleContext made available for additional testing.
+        */
+       @Inject
+       protected BundleContext bundleContext;
+
+       /**
+        * Asserts that a service of the specified type exists. Uses
+        * a wait time of 1 second.
+        * @param clazz The service interface type to be checked. 
+        */
+       protected void checkService(Class<?> clazz) {
+               checkService(clazz,1000);
+       }
+
+       /**
+        * Asserts that a service of the specified type exists.
+        * @param clazz The service interface type to be checked. 
+        * @param waitTime The time the service tracker should wait to 
+        * find the specified service in milliseconds.
+        */
+       protected void checkService(Class<?> clazz, int waitTime) {
+               try {  
+                       ServiceTracker tracker = new 
ServiceTracker(bundleContext, clazz.getName(), null);
+                       tracker.open();
+                       Object service = tracker.waitForService(waitTime);
+                       tracker.close();
+                       assertNotNull(service);
+               } catch (Exception e) {
+                       fail(e.getMessage());
+               }
+       }
+}

-- 
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.

Reply via email to