You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by tj...@apache.org on 2014/06/30 18:55:06 UTC

svn commit: r1606837 [15/27] - in /aries/branches/subsystemsR6: ./ application/ application/application-api/ application/application-bundle/ application/application-converters/ application/application-default-local-platform/ application/application-dep...

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/JPAInjectionTest.java Mon Jun 30 16:54:57 2014
@@ -16,22 +16,16 @@
 package org.apache.aries.jpa.blueprint.aries.itest;
 
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
-import static org.apache.aries.itest.ExtraOptions.*;
-
-import org.apache.aries.itest.AbstractIntegrationTest;
 import org.apache.aries.jpa.blueprint.itest.JPATestBean;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleException;
 
-@RunWith(JUnit4TestRunner.class)
-public class JPAInjectionTest extends AbstractIntegrationTest {
- 
+public class JPAInjectionTest extends AbstractJPAItest {
+
   @Test
   public void findResources() throws Exception {
     JPATestBean bean = context().getService(JPATestBean.class, "(version=1.0.0)");
@@ -54,51 +48,22 @@ public class JPAInjectionTest extends Ab
   @Test
   public void testLifecycle() throws Exception {
     JPATestBean bean = context().getService(JPATestBean.class, "(lifecycle=true)");
-    
     assertTrue("No persistence context injection", bean.pContextAvailable());
     
-    context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle").update();
-    
+    context().getBundleByName(TEST_BUNDLE_NAME).update();
     assertTrue("No persistence context injection", bean.pContextAvailable());
   }
 
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    return testOptions(
-        paxLogging("DEBUG"),
-
-        // Bundles
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"), 
-        mavenBundle("org.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.aries"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-        mavenBundle("commons-lang", "commons-lang"),
-        mavenBundle("commons-collections", "commons-collections"),
-        mavenBundle("commons-pool", "commons-pool"),
-        mavenBundle("org.apache.derby", "derby"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
-        mavenBundle("org.apache.openjpa", "openjpa"),
-
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
-        
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.blueprint.itest.bundle"),
-        //For lifecycle testing
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle"),
-
-        // Add in a workaround to get OSGi 4.3 support with the current version of pax-exam
-        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-        equinox().version("3.7.0.v20110613")
+  @Configuration
+  public Option[] configuration() {
+    return options(
+    		baseOptions(),
+    		ariesJpa(),
+    		openJpa(),
+    		testDs(),
+    		testBundleBlueprint(),
+    		//	For lifecycle testing
+    		testBundle()
     );
       
   }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java Mon Jun 30 16:54:57 2014
@@ -17,9 +17,7 @@ package org.apache.aries.jpa.container.i
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import static org.apache.aries.itest.ExtraOptions.*;
-import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
 import java.sql.Driver;
 import java.sql.SQLException;
@@ -33,189 +31,151 @@ import javax.sql.DataSource;
 import javax.sql.XADataSource;
 import javax.transaction.UserTransaction;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
-import org.apache.aries.jpa.container.PersistenceUnitConstants;
 import org.apache.aries.jpa.container.itest.entities.Car;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.apache.derby.jdbc.EmbeddedDataSource;
 import org.apache.derby.jdbc.EmbeddedXADataSource;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.ServiceReference;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.jdbc.DataSourceFactory;
 
-@RunWith(JUnit4TestRunner.class)
-public class JPAContainerDataSourceFactoryTest extends AbstractIntegrationTest {
-
-  @Test
-  public void testDataSourceFactoryLifecycle() throws Exception {
-    //Wait for startup
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    //Now go
-    ServiceReference[] refs = context().getServiceReferences(
-        EntityManagerFactory.class.getName(), "(&(osgi.unit.name=dsf-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull(refs);
-    
-    Hashtable<String, Object> props = new Hashtable();
-    props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "org.apache.derby.jdbc.EmbeddedDriver");
-    
-    ServiceRegistration reg = context().registerService(DataSourceFactory.class.getName(), 
-        new DerbyDataSourceFactory(), props);
-    
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, 
-        "(&(osgi.unit.name=dsf-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    
-    EntityManager em = emf.createEntityManager();
-    
-    em.getTransaction().begin();
-    
-    Car c = new Car();
-    c.setNumberPlate("123456");
-    c.setColour("blue");
-    em.persist(c);
-    
-    em.getTransaction().commit();
-    
-    em.close();
-    
-    em = emf.createEntityManager();
-    
-    assertEquals("blue", em.find(Car.class, "123456").getColour());
-    
-    reg.unregister();
-    
-    refs = context().getServiceReferences(
-        EntityManagerFactory.class.getName(), "(&(osgi.unit.name=dsf-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull(refs);
-  }
-  
-  @Test
-  public void testDataSourceFactoryXALifecycle() throws Exception {
-    //Wait for startup
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    //Now go
-    ServiceReference[] refs = context().getServiceReferences(
-        EntityManagerFactory.class.getName(), "(&(osgi.unit.name=dsf-xa-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull(refs);
-    
-    Hashtable<String, Object> props = new Hashtable();
-    props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "org.apache.derby.jdbc.EmbeddedDriver");
-    
-    ServiceRegistration reg = context().registerService(DataSourceFactory.class.getName(), 
-        new DerbyDataSourceFactory(), props);
-    
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, 
-        "(&(osgi.unit.name=dsf-xa-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    
-    EntityManager em = emf.createEntityManager();
-    
-    //Use a JTA tran to show integration
-    UserTransaction ut = context().getService(UserTransaction.class);
-    
-    ut.begin();
-    em.joinTransaction();
-    Car c = new Car();
-    c.setNumberPlate("123456");
-    c.setColour("blue");
-    em.persist(c);
-    
-    ut.commit();
-      
-    em.close();
-    
-    em = emf.createEntityManager();
-    
-    assertEquals("blue", em.find(Car.class, "123456").getColour());
-    
-    reg.unregister();
-    
-    refs = context().getServiceReferences(
-        EntityManagerFactory.class.getName(), "(&(osgi.unit.name=dsf-xa-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull(refs);
-  }
-  
-  
-  
-  private static class DerbyDataSourceFactory implements DataSourceFactory {
-
-    public DataSource createDataSource(Properties props) throws SQLException {
-      EmbeddedDataSource ds = new EmbeddedDataSource();
-      ds.setDatabaseName("memory:TEST");
-      ds.setCreateDatabase("create");
-      return ds;
-    }
-
-    public ConnectionPoolDataSource createConnectionPoolDataSource(
-        Properties props) throws SQLException {
-      // TODO Auto-generated method stub
-      return null;
-    }
-
-    public XADataSource createXADataSource(Properties props)
-        throws SQLException {
-      EmbeddedXADataSource ds = new EmbeddedXADataSource();
-      ds.setDatabaseName("memory:TEST");
-      ds.setCreateDatabase("create");
-      return ds;
-    }
-
-    public Driver createDriver(Properties props) throws SQLException {
-      // TODO Auto-generated method stub
-      return null;
-    }
-    
-  }
-  
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    return testOptions(
-        transactionBootDelegation(),
-        paxLogging("DEBUG"),
-
-        // Bundles
-        mavenBundle("commons-lang", "commons-lang"),
-        mavenBundle("commons-collections", "commons-collections"),
-        mavenBundle("commons-pool", "commons-pool"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
-        mavenBundle("org.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager" ),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers" ),
-        mavenBundle("org.apache.derby", "derby"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-        mavenBundle("org.apache.openjpa", "openjpa"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-        mavenBundle("org.osgi", "org.osgi.enterprise"),
-//        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
-        //waitForFrameworkStartup(),
-        
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle"),
-        
-        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-        equinox().version("3.7.0.v20110613"));
-  }
+public class JPAContainerDataSourceFactoryTest extends AbstractJPAItest {
+	private static final String DSF_TEST_UNIT = "dsf-test-unit";
+	private static final String DSF_XA_TEST_UNIT = "dsf-xa-test-unit";
+	
+	@SuppressWarnings("rawtypes")
+	private ServiceRegistration reg;
+
+	@Before
+	public void waitStartup() throws InvalidSyntaxException {
+		getEMF(TEST_UNIT);
+		assertNull(getEMFRefs(DSF_TEST_UNIT));
+		assertNull(getEMFRefs(DSF_XA_TEST_UNIT));
+		reg = registerDataSourceFactory();
+	}
+	
+	@After
+	public void shutDown() throws InvalidSyntaxException {
+		reg.unregister();
+		assertNull(getEMFRefs(DSF_TEST_UNIT));
+		assertNull(getEMFRefs(DSF_XA_TEST_UNIT));
+	}
+
+	@Test
+	public void testDataSourceFactoryLifecycle() throws Exception {
+		EntityManagerFactory emf = getEMF(DSF_TEST_UNIT);
+
+		EntityManager em = emf.createEntityManager();
+		em.getTransaction().begin();
+		Car c = createCar();
+		em.persist(c);
+		em.getTransaction().commit();
+		em.close();
+		
+		assertCarFound(emf);
+
+		em = emf.createEntityManager();
+		em.getTransaction().begin();
+		deleteCar(em, c);
+		em.getTransaction().commit();
+		em.close();
+	}
+
+	@Test
+	public void testDataSourceFactoryXALifecycle() throws Exception {
+		EntityManagerFactory emf = getEMF(DSF_XA_TEST_UNIT);
+		EntityManager em = emf.createEntityManager();
+
+		// Use a JTA transaction to show integration
+		UserTransaction ut = context().getService(UserTransaction.class);
+		ut.begin();
+		em.joinTransaction();
+		Car c = createCar();
+		em.persist(c);
+		ut.commit();
+		em.close();
+
+		assertCarFound(emf);
+		
+		em = emf.createEntityManager();
+		ut.begin();
+		em.joinTransaction();
+		deleteCar(em, c);
+		ut.commit();
+		em.close();
+	}
+
+	private static class DerbyDataSourceFactory implements DataSourceFactory {
+
+		public DataSource createDataSource(Properties props)
+				throws SQLException {
+			EmbeddedDataSource ds = new EmbeddedDataSource();
+			ds.setDatabaseName("memory:TEST");
+			ds.setCreateDatabase("create");
+			return ds;
+		}
+
+		public ConnectionPoolDataSource createConnectionPoolDataSource(
+				Properties props) throws SQLException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+		public XADataSource createXADataSource(Properties props)
+				throws SQLException {
+			EmbeddedXADataSource ds = new EmbeddedXADataSource();
+			ds.setDatabaseName("memory:TEST");
+			ds.setCreateDatabase("create");
+			return ds;
+		}
+
+		public Driver createDriver(Properties props) throws SQLException {
+			// TODO Auto-generated method stub
+			return null;
+		}
+
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	private ServiceRegistration registerDataSourceFactory() {
+		Hashtable<String, Object> props = new Hashtable();
+		props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS,	"org.apache.derby.jdbc.EmbeddedDriver");
+		return context().registerService(DataSourceFactory.class.getName(), new DerbyDataSourceFactory(), props);
+	}
+
+	private Car createCar() {
+		Car c = new Car();
+		c.setNumberPlate("123456");
+		c.setColour("blue");
+		return c;
+	}
+	
+
+	private void deleteCar(EntityManager em, Car c) {
+		c = em.merge(c);
+		em.remove(c);
+	}
+
+	private void assertCarFound(EntityManagerFactory emf) {
+		EntityManager em;
+		em = emf.createEntityManager();
+		assertEquals("blue", em.find(Car.class, "123456").getColour());
+	}
+
+	@Configuration
+	public Option[] configuration() {
+		return options(
+				baseOptions(),
+				ariesJpa(),
+				transactionWrapper(),
+				openJpa(),
+				testBundle()
+				);
+	}
 
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java Mon Jun 30 16:54:57 2014
@@ -15,84 +15,46 @@
  */
 package org.apache.aries.jpa.container.itest;
 
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-import static org.apache.aries.itest.ExtraOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.aries.itest.AbstractIntegrationTest;
-import org.apache.aries.jpa.container.PersistenceUnitConstants;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 
-@RunWith(JUnit4TestRunner.class)
-public class JPAContainerTest extends AbstractIntegrationTest {
+public class JPAContainerTest extends AbstractJPAItest {
+
+	@Test
+	public void findEntityManagerFactory() throws Exception {
+		getEMF(TEST_UNIT);
+	}
+
+	@Test
+	public void findEntityManagerFactory2() throws Exception {
+		getEMF(BP_TEST_UNIT);
+	}
+
+	@Test
+	public void findEntityManager() throws Exception {
+		getEMF(TEST_UNIT).createEntityManager();
+	}
+
+	@Test
+	public void findEntityManager2() throws Exception {
+		getEMF(BP_TEST_UNIT).createEntityManager();
+	}
+
+	@Configuration
+	public Option[] configuration() {
+		return options(
+				baseOptions(),
+				ariesJpa(),
+				// Needed for the BP_TEST_UNIT
+				transactionWrapper(),
+				openJpa(),
+				testDs(),
+				testBundle());
 
-  @Test
-  public void findEntityManagerFactory() throws Exception {
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-  }
-  
-  @Test
-  public void findEntityManagerFactory2() throws Exception {
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=bp-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-  }
-  
-  @Test
-  public void findEntityManager() throws Exception {
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    emf.createEntityManager();
-  }
-  
-  @Test
-  public void findEntityManager2() throws Exception {
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=bp-test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    emf.createEntityManager();
-  }
-
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    return testOptions(
-        transactionBootDelegation(),
-        paxLogging("DEBUG"),
-
-        // Bundles
-        mavenBundle("commons-lang", "commons-lang"),
-        mavenBundle("commons-collections", "commons-collections"),
-        mavenBundle("commons-pool", "commons-pool"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
-        mavenBundle("org.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager" ),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers" ),
-        mavenBundle("org.apache.derby", "derby"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-        mavenBundle("org.apache.openjpa", "openjpa"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-
-        //vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
-        //waitForFrameworkStartup(),
-        
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle"),
-
-        // Add in a workaround to get OSGi 4.3 support with the current version of pax-exam
-        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-        equinox().version("3.7.0.v20110613")
-    );
- 
-  }
+	}
 
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkContextTest.java Mon Jun 30 16:54:57 2014
@@ -15,28 +15,22 @@
  */
 package org.apache.aries.jpa.context.itest;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
 
 import org.junit.Ignore;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 
 @Ignore
-@RunWith(JUnit4TestRunner.class)
 public class EclipseLinkContextTest extends JPAContextTest {
     @Configuration
-    public static Option[] eclipseLinkConfig() {
-        return options(        
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr"),
-                
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter"),
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink")
+    public Option[] eclipseLinkConfig() {
+        return options(
+        		baseOptions(),
+        		ariesJpa(),
+        		eclipseLink(),
+                testBundleEclipseLink()
         );
     }
+	
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkStartupTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkStartupTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkStartupTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/EclipseLinkStartupTest.java Mon Jun 30 16:54:57 2014
@@ -15,25 +15,21 @@
  */
 package org.apache.aries.jpa.context.itest;
 
-import static org.apache.aries.itest.ExtraOptions.mavenBundle;
-import static org.apache.aries.itest.ExtraOptions.paxLogging;
-import static org.apache.aries.itest.ExtraOptions.testOptions;
-import static org.ops4j.pax.exam.CoreOptions.felix;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.spi.PersistenceProvider;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 import org.osgi.framework.Bundle;
 
 @Ignore
-@RunWith(JUnit4TestRunner.class)
-public class EclipseLinkStartupTest extends AbstractIntegrationTest {
+public class EclipseLinkStartupTest extends AbstractJPAItest {
     
     @Test
     public void testContextCreationWithStartingBundle() throws Exception {
@@ -49,43 +45,12 @@ public class EclipseLinkStartupTest exte
         context().getService(EntityManagerFactory.class);
     }
 
-    @org.ops4j.pax.exam.junit.Configuration
-    public static Option[] configuration() {
-        return testOptions(
-                felix().version("3.2.1"),
-                paxLogging("INFO"),
-
-                // Bundles
-                mavenBundle("org.osgi", "org.osgi.compendium"),
-                mavenBundle("org.apache.aries", "org.apache.aries.util"),
-                // Adding blueprint to the runtime is a hack to placate the
-                // maven bundle plugin.
-                mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-                mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
-                mavenBundle("org.ow2.asm", "asm-all"),
-                mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-                mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-                mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-                mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
-                mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
-                mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context"),
-                mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager"),
-                mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers"),
-                mavenBundle("org.apache.derby", "derby"),
-                mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-                mavenBundle("commons-lang", "commons-lang"),
-                mavenBundle("commons-collections", "commons-collections"),
-                mavenBundle("commons-pool", "commons-pool"),
-
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
-                mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr"),
-                
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter"),
+    @Configuration
+    public Option[] configuration() {
+        return CoreOptions.options(
+        		baseOptions(),
+        		ariesJpa(),
+        		eclipseLink(),
                 mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink").noStart()
             );
     }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/JPAContextTest.java Mon Jun 30 16:54:57 2014
@@ -17,10 +17,6 @@ package org.apache.aries.jpa.context.ite
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-
-import static org.apache.aries.itest.ExtraOptions.*;
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
@@ -31,11 +27,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.inject.Inject;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
 import javax.persistence.FlushModeType;
 import javax.persistence.LockModeType;
-import javax.persistence.PersistenceContextType;
 import javax.persistence.Query;
 import javax.persistence.TransactionRequiredException;
 import javax.persistence.TypedQuery;
@@ -47,48 +43,43 @@ import javax.transaction.RollbackExcepti
 import javax.transaction.SystemException;
 import javax.transaction.UserTransaction;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
-import org.apache.aries.jpa.container.PersistenceUnitConstants;
-import org.apache.aries.jpa.container.context.PersistenceContextProvider;
 import org.apache.aries.jpa.container.itest.entities.Car;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
+import org.junit.Ignore;
 import org.junit.Test;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
 import org.ops4j.pax.exam.Option;
 
-public abstract class JPAContextTest extends AbstractIntegrationTest {
+public abstract class JPAContextTest extends AbstractJPAItest {
+  
+  @Inject
+  UserTransaction ut;
  
   @Test
   public void findEntityManagerFactory() throws Exception {
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
+    getEMF(TEST_UNIT);
   }
   
   @Test
   public void findManagedContextFactory() throws Exception {
     try{
-      context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
+      getProxyEMF(TEST_UNIT);
       fail("No context should exist");
     } catch (RuntimeException re) {
       //Expected
     }
     
-    registerClient("test-unit");
-    
-    getProxyEMF("test-unit");    
-  }
-
-  private EntityManagerFactory getProxyEMF(String name) {
-    
-    return context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=" + name + ")(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
+    registerClient(TEST_UNIT);
+    getProxyEMF(TEST_UNIT);    
   }
   
+  @SuppressWarnings("rawtypes")
   @Test
   public void testTranRequired() throws Exception {
-    registerClient("bp-test-unit");
+    registerClient(BP_TEST_UNIT);
     
-    EntityManagerFactory emf = getProxyEMF("bp-test-unit");
+    EntityManagerFactory emf = getProxyEMF(BP_TEST_UNIT);
     
     final EntityManager managedEm = emf.createEntityManager();
     
@@ -139,9 +130,6 @@ public abstract class JPAContextTest ext
     ensureTREBehaviour(false, managedEm, "unwrap", Object.class);
 
     // now test that with a transaction actually active we don't get *any* TransactionRequiredExceptions
-
-    UserTransaction ut = context().getService(UserTransaction.class);
-    
     ut.begin();
     try{
       ensureTREBehaviour(false, managedEm, "contains", new Object());
@@ -196,13 +184,9 @@ public abstract class JPAContextTest ext
   
   @Test
   public void testNonTxEmIsCleared() throws Exception {
-    
-    registerClient("bp-test-unit");
-    
-    EntityManagerFactory emf = getProxyEMF("bp-test-unit");
-    
+    registerClient(BP_TEST_UNIT);
+    EntityManagerFactory emf = getProxyEMF(BP_TEST_UNIT);
     doNonTxEmIsCleared(emf);
-    
   }
 
   private void doNonTxEmIsCleared(EntityManagerFactory emf)
@@ -210,8 +194,6 @@ public abstract class JPAContextTest ext
       HeuristicRollbackException, RollbackException {
     final EntityManager managedEm = emf.createEntityManager();
     
-    UserTransaction ut = context().getService(UserTransaction.class);
-    
     ut.begin();
     try {
       
@@ -258,26 +240,16 @@ public abstract class JPAContextTest ext
   
   @Test
   public void testNonTxEmIsClearedUsingXADataSourceWrapper() throws Exception {
-    
-    registerClient("bp-xa-test-unit");
-    
-    EntityManagerFactory emf = getProxyEMF("bp-xa-test-unit");
-    
+    registerClient(BP_XA_TEST_UNIT);
+    EntityManagerFactory emf = getProxyEMF(BP_XA_TEST_UNIT);
     doNonTxEmIsCleared(emf);
-    
   }
 
   @Test
   public void testNonTxQueries() throws Exception {
-    
-    registerClient("bp-test-unit");
-    
-    EntityManagerFactory emf = getProxyEMF("bp-test-unit");
-    
+    registerClient(BP_TEST_UNIT);
+    EntityManagerFactory emf = getProxyEMF(BP_TEST_UNIT);
     final EntityManager managedEm = emf.createEntityManager();
-    
-    UserTransaction ut = context().getService(UserTransaction.class);
-    
     ut.begin();
     try {
       
@@ -366,18 +338,9 @@ public abstract class JPAContextTest ext
     assertEquals("blue", list.get(1).getColour());
     assertEquals("A1AAA", list.get(1).getNumberPlate());
   }
-  
-  private void registerClient(String name) {
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext(name, bundleContext.getBundle(), props);
-  }
 
   private void ensureTREBehaviour(boolean expectedToFail, EntityManager em, String methodName, Object... args) throws Exception {
-    
-    List<Class> argTypes = new ArrayList<Class>();
+    List<Class<?>> argTypes = new ArrayList<Class<?>>();
     for(Object o : args) {
       if(o instanceof Map)
         argTypes.add(Map.class);
@@ -406,43 +369,5 @@ public abstract class JPAContextTest ext
     }
   }
   
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    return testOptions(
-        paxLogging("DEBUG"),
-        transactionBootDelegation(),
-        
-        // Bundles
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        // Adding blueprint to the runtime is a hack to placate the maven bundle plugin. 
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"),
-        mavenBundle("org.ow2.asm", "asm-all"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context"),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager" ),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.wrappers" ),
-        mavenBundle("org.apache.derby", "derby"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-        mavenBundle("commons-lang", "commons-lang"),
-        mavenBundle("commons-collections", "commons-collections"),
-        mavenBundle("commons-pool", "commons-pool"),
-        
-//        vmOption ("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006"),
-//        waitForFrameworkStartup(),
 
-        // Add in a workaround to get OSGi 4.3 support with the current version of pax-exam
-        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-        equinox().version("3.7.0.v20110613")
-    );
-      
-  }
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/context/itest/OpenjpaContextTest.java Mon Jun 30 16:54:57 2014
@@ -16,21 +16,21 @@
 package org.apache.aries.jpa.context.itest;
 
 import static org.ops4j.pax.exam.CoreOptions.options;
-import static org.apache.aries.itest.ExtraOptions.*;
 
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
 
-@RunWith(JUnit4TestRunner.class)
 public class OpenjpaContextTest extends JPAContextTest {
+
     @Configuration
-    public static Option[] openjpaConfig() {
-        return options(        
-                mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
-                mavenBundle("org.apache.openjpa", "openjpa"),
-                mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle")
+    public Option[] configuration() {
+        return options(
+        		baseOptions(),
+        		ariesJpa(),
+        		transactionWrapper(),
+        		openJpa(),
+                testBundle()
         );
     }
+
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-itest/src/test/java/org/apache/aries/jpa/quiesce/itest/QuiesceJPATest.java Mon Jun 30 16:54:57 2014
@@ -18,641 +18,353 @@ package org.apache.aries.jpa.quiesce.ite
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
-import static org.ops4j.pax.exam.CoreOptions.equinox;
-import org.ops4j.pax.exam.container.def.PaxRunnerOptions;
-
-import static org.apache.aries.itest.ExtraOptions.*;
+import static org.ops4j.pax.exam.CoreOptions.options;
 
 import java.util.Collections;
-import java.util.HashMap;
 
+import javax.inject.Inject;
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceContextType;
 import javax.sql.DataSource;
 import javax.transaction.UserTransaction;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
-import org.apache.aries.jpa.container.PersistenceUnitConstants;
-import org.apache.aries.jpa.container.context.PersistenceContextProvider;
+import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.apache.aries.quiesce.manager.QuiesceCallback;
 import org.apache.aries.quiesce.participant.QuiesceParticipant;
 import org.junit.After;
 import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerMethod;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 
-@RunWith(JUnit4TestRunner.class)
-public class QuiesceJPATest extends AbstractIntegrationTest {
-  
-  private static class TestQuiesceCallback implements QuiesceCallback{
-
-    private int calls = 0;
-    
-    public void bundleQuiesced(Bundle... arg0) {
-      calls++;
-    }
-
-    public boolean bundleClearedUp()
-    {
-      return calls == 1;
-    }
-  }
-  
-  private class MultiQuiesceCallback implements QuiesceCallback{
-
-    private int calls = 0;
-    
-    private boolean contextFirst = true;
-    
-    public void bundleQuiesced(Bundle... arg0) {
-      if(++calls == 1)
-        try {
-          context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-              + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-        } catch (Throwable t){
-          contextFirst = false;
-          if(t instanceof RuntimeException)
-            throw (RuntimeException) t;
-          else if (t instanceof Error)
-            throw (Error) t;
-          else
-            throw new RuntimeException(t);
-        }
-            
-    }
-
-    public boolean bundleClearedUp()
-    {
-      return calls == 2 && contextFirst;
-    }
-  }
-  
-  
-  @After
-  public void restartTestBundles() throws BundleException {
-    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
-    b.stop();
-    b.start();
-    
-    b = context().getBundleByName("org.apache.aries.jpa.container");
-    b.stop();
-    b.start();
-    
-    b = context().getBundleByName("org.apache.aries.jpa.container.context");
-    b.stop();
-    b.start();
-  }
-  
-  @Test
-  public void testSimpleContextQuiesce() throws Exception {
-
-    //Get a managed context registered
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext("test-unit", bundleContext.getBundle(), props);
-    
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    //Quiesce it
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    assertNull("No context should exist",refs);
-    
-    //Restart the bundle to check the context gets re-registered
-    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
-    b.stop();
-    b.start();
-    
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-  }
-
-  @Test
-  public void testComplexContextQuiesce() throws Exception {
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    // Get a managed context registered
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext("test-unit", bundleContext.getBundle(), props);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    //Set up a transaction so we can check the Quiesce waits properly
-    UserTransaction tm = context().getService(UserTransaction.class);
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    tm.commit();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    assertNull("No context should exist",refs);
-    
-    
-    //Restart the bundle to check the context gets re-registered, then ensure it isn't
-    //tidied up immediately again!
-    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
-    b.stop();
-    b.start();
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    tm.commit();
-    
-    Thread.sleep(1000);
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", 100);
-    
-    //Test again to make sure we don't hold state over
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))", 100);
-    
-    tm.commit();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    assertNull("No context should exist",refs);
-    
-  }
-  
-  @Test
-  public void testContextRuntimeQuiesce() throws Exception {
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext("test-unit", bundleContext.getBundle(), props);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    UserTransaction tm = context().getService(UserTransaction.class);
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container.context");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.container.context")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce not finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    tm.commit();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    assertNull("No context should exist",refs);
-  }
-  
-  @Test
-  public void testSimpleUnitQuiesce() throws Exception {
-
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull("No unit should exist",refs);
-    
-    //Restart the bundle to check the unit gets re-registered
-    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
-    b.stop();
-    b.start();
-    
-    context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-  }
-
-  @Test
-  public void testComplexUnitQuiesce() throws Exception {
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    EntityManager em = emf.createEntityManager();
-    
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    em.close();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull("No context should exist",refs);
-    
-    //Restart the bundle to check the unit gets re-registered and is not immediately unregistered
-    Bundle b = context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle");
-    b.stop();
-    b.start();
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    em = emf.createEntityManager();
-    em.close();
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))", 100);
-    
-    //Test a second time to make sure state isn't held
-    
-    em = emf.createEntityManager();
-    
-    callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    em.close();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull("No context should exist",refs);
-  }
-  
-  @Test
-  public void testContainerRuntimeQuiesce() throws Exception {
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    
-    EntityManager em = emf.createEntityManager();
-    
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
-    
-    TestQuiesceCallback callback = new TestQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.container")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished early", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-
-    em.close();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull("No context should exist",refs);
-  }
-  
-  @Test
-  public void testComplexQuiesceInteraction() throws Exception {
-
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    // Get a managed context registered
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext("test-unit", bundleContext.getBundle(), props);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    //Set up a transaction so we can check the Quiesce waits properly
-    UserTransaction tm = context().getService(UserTransaction.class);
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    //Quiesce the Unit, nothing should happen
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
-    
-    TestQuiesceCallback unitCallback = new TestQuiesceCallback();
-    
-    participant.quiesce(unitCallback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", unitCallback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    //Quiesce the context, still nothing
-    
-    participant = getParticipant("org.apache.aries.jpa.container.context");
-    
-    TestQuiesceCallback contextCallback = new TestQuiesceCallback();
-    
-    participant.quiesce(contextCallback, Collections.singletonList(context().getBundleByName(
-    "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", unitCallback.bundleClearedUp());
-    assertFalse("Quiesce finished", contextCallback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    //Keep the unit alive
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-  
-  
-    EntityManager em = emf.createEntityManager();
-    
-    tm.commit();
-    
-    assertTrue("Quiesce not finished", contextCallback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    assertNull("No context should exist",refs);
-    
-    //Still a unit
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    em.close();
-    
-    assertTrue("Quiesce not finished", unitCallback.bundleClearedUp());
-    
-    refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-  
-    assertNull("No unit should exist",refs);
-  }
-  
-  @Test
-  public void testComplexQuiesceInteraction2() throws Exception {
-    //This is load bearing. we have to wait to create the EntityManager until the DataSource is available
-    context().getService(DataSource.class);
-    
-    // Get a managed context registered
-    PersistenceContextProvider provider = context().getService(PersistenceContextProvider.class);
-    
-    HashMap<String, Object> props = new HashMap<String, Object>();
-    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
-    provider.registerContext("test-unit", bundleContext.getBundle(), props);
-    
-    EntityManagerFactory emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-        "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    
-    //Set up a transaction so we can check the Quiesce waits properly
-    UserTransaction tm = context().getService(UserTransaction.class);
-    
-    tm.begin();
-    
-    emf.createEntityManager().getProperties();
-    
-    //Quiesce the Unit, nothing should happen
-    QuiesceParticipant participant = getParticipant("org.apache.aries.jpa.container");
-    
-    MultiQuiesceCallback callback = new MultiQuiesceCallback();
-    
-    participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
-        "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    //Quiesce the context, still nothing
-    participant = getParticipant("org.apache.aries.jpa.container.context");
-    
-    participant.quiesce(callback, Collections.singletonList(
-            context().getBundleByName("org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle")));
-    
-    Thread.sleep(1000);
-    
-    assertFalse("Quiesce finished", callback.bundleClearedUp());
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true)" +
-      "(" + PersistenceContextProvider.PROXY_FACTORY_EMF_ATTRIBUTE + "=*))");
-    
-    emf = context().getService(EntityManagerFactory.class, "(&(osgi.unit.name=test-unit)(" 
-        + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    
-    tm.commit();
-    
-    assertTrue("Quiesce not finished", callback.bundleClearedUp());
-    
-    ServiceReference[] refs = bundleContext.getAllServiceReferences(EntityManagerFactory.class.getName(), "(&(osgi.unit.name=test-unit)(" 
-          + PersistenceUnitConstants.CONTAINER_MANAGED_PERSISTENCE_UNIT + "=true))");
-    
-    assertNull("No context should exist",refs);
-    
-  }
-  
-  
-  
-  private QuiesceParticipant getParticipant(String bundleName) throws InvalidSyntaxException {
-    ServiceReference[] refs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null);
-    
-    if(refs != null) {
-      for(ServiceReference ref : refs) {
-        if(ref.getBundle().getSymbolicName().equals(bundleName))
-          return (QuiesceParticipant) bundleContext.getService(ref);
-      }
-    }
-    
-    
-    return null;
-  }
-
-  @org.ops4j.pax.exam.junit.Configuration
-  public static Option[] configuration() {
-    return testOptions(
-        transactionBootDelegation(),
-        paxLogging("DEBUG"),
-
-        // Bundles
-        mavenBundle("org.osgi", "org.osgi.compendium"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.cglib"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.api"),
-        mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy.impl"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.api"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.core"),
-        mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi.url"),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.testds"),
-        mavenBundle("org.apache.derby", "derby"),
-        mavenBundle("org.apache.aries.quiesce", "org.apache.aries.quiesce.api"),
-        mavenBundle("org.apache.aries", "org.apache.aries.util"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.api"),
-        mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint.core"), 
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.api"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container"),
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.context"),
-        mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
-        mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager"),
-        mavenBundle("commons-lang", "commons-lang"),
-        mavenBundle("commons-collections", "commons-collections"),
-        mavenBundle("commons-pool", "commons-pool"),
-        mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.serp"),
-        mavenBundle("org.apache.openjpa", "openjpa"),
-
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa"),
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.core"),
-//        mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm"),
-        
-        mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle"),
-
-        // Add in a workaround to get OSGi 4.3 support with the current version of pax-exam
-        PaxRunnerOptions.rawPaxRunnerOption("config", "classpath:ss-runner.properties"),
-        equinox().version("3.7.0.v20110613")
-    );
-      
-  }
+@ExamReactorStrategy(PerMethod.class)
+public class QuiesceJPATest extends AbstractJPAItest {
+	private static final int WAIT_TIME = 200;
+	private static final String JPA_CONTAINER = "org.apache.aries.jpa.container";
+	private static final String JPA_CONTEXT = "org.apache.aries.jpa.container.context";
+	private final String TEST_BUNDLE = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
+
+	@Inject
+	UserTransaction tm;
+
+	//This is load bearing. we have to wait to create the EntityManager until the DataSource is available
+	@Inject
+	DataSource ds;
+
+	private class TestQuiesceCallback implements QuiesceCallback{
+
+		protected int calls = 0;
+
+		public void bundleQuiesced(Bundle... arg0) {
+			calls++;
+		}
+
+		public boolean bundleClearedUp()
+		{
+			return calls == 1;
+		}
+	}
+
+	private class MultiQuiesceCallback extends TestQuiesceCallback implements QuiesceCallback{
+
+		private boolean contextFirst = true;
+
+		public void bundleQuiesced(Bundle... arg0) {
+			if(++calls == 1)
+				try {
+					getEMF(TEST_UNIT);
+				} catch (Throwable t){
+					contextFirst = false;
+					if(t instanceof RuntimeException)
+						throw (RuntimeException) t;
+					else if (t instanceof Error)
+						throw (Error) t;
+					else
+						throw new RuntimeException(t);
+				}
+
+		}
+
+		public boolean bundleClearedUp()
+		{
+			return calls == 2 && contextFirst;
+		}
+	}
+
+
+	@After
+	public void restartTestBundles() throws BundleException {
+		restartTestBundle();
+		restartBundle(JPA_CONTAINER);
+		restartBundle(JPA_CONTEXT);
+		try {
+			tm.rollback();
+		} catch (Exception e) {
+			// Ignore
+		}
+	}
+
+	@Test
+	public void testSimpleContextQuiesce() throws Exception {
+		registerClient(TEST_UNIT);
+		getProxyEMF(TEST_UNIT);
+
+		//Quiesce it
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+		Thread.sleep(WAIT_TIME);
+		assertFinished(callback);
+
+		assertNoProxyEMFForTestUnit();
+
+		restartTestBundle();
+
+		getProxyEMF(TEST_UNIT);
+	}
+
+	@Test
+	public void testComplexContextQuiesce() throws Exception {
+		registerClient(TEST_UNIT);
+
+		EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
+		tm.begin();
+		emf.createEntityManager().getProperties();
+
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+		assertNotFinished(callback);
+
+		emf = getProxyEMF(TEST_UNIT);
+		tm.commit();
+		assertTrue("Quiesce not finished", callback.bundleClearedUp());
+		assertNoProxyEMFForTestUnit();
+
+		restartTestBundle();
+
+		emf = getProxyEMF(TEST_UNIT);
+		tm.begin();
+		emf.createEntityManager().getProperties();
+		tm.commit();
+
+		Thread.sleep(WAIT_TIME);
+
+		//Test again to make sure we don't hold state over
+		emf = getProxyEMF(TEST_UNIT);
+		tm.begin();
+		emf.createEntityManager().getProperties();
+
+		callback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+		assertNotFinished(callback);
+
+		emf = getProxyEMF(TEST_UNIT);
+		tm.commit();
+
+		assertFinished(callback);
+		assertNoProxyEMFForTestUnit();
+	}
+
+	@Test
+	public void testContextRuntimeQuiesce() throws Exception {
+		registerClient(TEST_UNIT);
+
+		EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
+		tm.begin();
+		emf.createEntityManager().getProperties();
+
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTEXT, JPA_CONTEXT);
+		assertNotFinished(callback);
+
+		emf = getProxyEMF(TEST_UNIT);
+		tm.commit();
+
+		assertFinished(callback);
+		assertNoProxyEMFForTestUnit();
+	}
+
+	@Test
+	public void testSimpleUnitQuiesce() throws Exception {
+		assertEMFForTestUnit();
+
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
+		Thread.sleep(WAIT_TIME);
+		assertFinished(callback);
+		assertNoEMFForTestUnit();
+
+		restartTestBundle();
+
+		assertEMFForTestUnit();
+	}
+
+	
+	@Test
+	public void testComplexUnitQuiesce() throws Exception {
+		quiesceUnit();
+		restartTestBundle();
+	    getEMF(TEST_UNIT).createEntityManager().close();
+		//Test a second time to make sure state isn't held
+		quiesceUnit();
+	}
+	
+	private void quiesceUnit() throws Exception {
+		EntityManager em = getEMF(TEST_UNIT).createEntityManager();
+
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
+		assertNotFinished(callback);
+
+		assertEMFForTestUnit();
+		em.close();
+		assertFinished(callback);
+		assertNoEMFForTestUnit();
+	}
+
+	@Test
+	public void testContainerRuntimeQuiesce() throws Exception {
+		EntityManagerFactory emf = getEMF(TEST_UNIT);
+		EntityManager em = emf.createEntityManager();
+
+		TestQuiesceCallback callback = getQuiesceCallback(JPA_CONTAINER, JPA_CONTAINER);
+		assertNotFinished(callback);
+
+		assertEMFForTestUnit();
+		em.close();
+		assertFinished(callback);
+		assertNoEMFForTestUnit();
+	}
+
+	@Test
+	public void testComplexQuiesceInteraction() throws Exception {
+		registerClient(TEST_UNIT);
+
+		EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
+		tm.begin();
+		emf.createEntityManager().getProperties();
+
+		//Quiesce the Unit, nothing should happen
+		TestQuiesceCallback unitCallback = getQuiesceCallback(JPA_CONTAINER, TEST_BUNDLE);
+		assertNotFinished(unitCallback);
+
+		emf = getProxyEMF(TEST_UNIT);
+
+		//Quiesce the context, still nothing
+		TestQuiesceCallback contextCallback = getQuiesceCallback(JPA_CONTEXT, TEST_BUNDLE);
+		assertNotFinished(unitCallback, contextCallback);
+
+		emf = getProxyEMF(TEST_UNIT);
+
+		//Keep the unit alive
+		emf = getEMF(TEST_UNIT);
+
+		EntityManager em = emf.createEntityManager();
+		tm.commit();
+		assertFinished(contextCallback);
+		assertNoProxyEMFForTestUnit();
+		assertEMFForTestUnit();
+		em.close();
+
+		assertFinished(unitCallback);
+		assertNoEMFForTestUnit();
+	}
+
+	@Test
+	public void testComplexQuiesceInteraction2() throws Exception {
+		registerClient(TEST_UNIT);
+
+		EntityManagerFactory emf = getProxyEMF(TEST_UNIT);
+
+		tm.begin();
+
+		emf.createEntityManager().getProperties();
+
+		MultiQuiesceCallback callback = new MultiQuiesceCallback();
+
+		//Quiesce the Unit, nothing should happen
+		QuiesceParticipant participant = getParticipant(JPA_CONTAINER);
+		participant.quiesce(callback, Collections.singletonList(context().getBundleByName(
+				TEST_BUNDLE)));
+
+		//Quiesce the context, still nothing
+		participant = getParticipant(JPA_CONTEXT);
+		participant.quiesce(callback, Collections.singletonList(
+				context().getBundleByName(TEST_BUNDLE)));
+		assertNotFinished(callback);
+
+		emf = getProxyEMF(TEST_UNIT);
+		assertEMFForTestUnit();
+
+		tm.commit();
+
+		assertFinished(callback);
+		assertNoEMFForTestUnit();
+	}
+
+	private void assertFinished(TestQuiesceCallback callback) {
+		assertTrue("Quiesce not finished", callback.bundleClearedUp());
+	}
+
+	private void assertNotFinished(TestQuiesceCallback... callbacks)
+			throws InterruptedException {
+		Thread.sleep(WAIT_TIME);
+		for (TestQuiesceCallback callback : callbacks) {
+			assertFalse("Quiesce finished", callback.bundleClearedUp());
+		}
+	}
+
+	private void assertNoEMFForTestUnit() throws InvalidSyntaxException {
+		assertNull("No unit should exist", getEMFRefs(TEST_UNIT));
+	}
+
+	private void assertEMFForTestUnit() {
+		getEMF(TEST_UNIT);
+	}
+
+	private void assertNoProxyEMFForTestUnit() throws InvalidSyntaxException {
+		assertNull("No context should exist", getProxyEMFRefs(TEST_UNIT));
+	}
+
+	private TestQuiesceCallback getQuiesceCallback(String participantName, String bundleName) throws InvalidSyntaxException {
+		QuiesceParticipant participant = getParticipant(participantName);
+		TestQuiesceCallback callback = new TestQuiesceCallback();
+		participant.quiesce(callback, Collections.singletonList(context().getBundleByName(bundleName)));
+		return callback;
+	}
+
+	@SuppressWarnings({ "rawtypes", "unchecked" })
+	private QuiesceParticipant getParticipant(String bundleName) throws InvalidSyntaxException {
+		ServiceReference[] refs = bundleContext.getServiceReferences(QuiesceParticipant.class.getName(), null);
+
+		if(refs != null) {
+			for(ServiceReference ref : refs) {
+				if(ref.getBundle().getSymbolicName().equals(bundleName))
+					return (QuiesceParticipant) bundleContext.getService(ref);
+			}
+		}
+
+
+		return null;
+	}
+
+	private void restartTestBundle() throws BundleException {
+		restartBundle(TEST_BUNDLE_NAME);
+	}
+
+	private void restartBundle(String bundleName) throws BundleException {
+		Bundle b = context().getBundleByName(bundleName);
+		b.stop();
+		b.start();
+	}
+
+	@Configuration
+	public Option[] configuration() {
+		return options(
+				baseOptions(),
+				ariesJpa(),
+				openJpa(),
+				testDs(),
+				testBundle()
+				);
+	}
+
 }

Modified: aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml
URL: http://svn.apache.org/viewvc/aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml?rev=1606837&r1=1606836&r2=1606837&view=diff
==============================================================================
--- aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml (original)
+++ aries/branches/subsystemsR6/jpa/jpa-container-testbundle-eclipselink/pom.xml Mon Jun 30 16:54:57 2014
@@ -1,45 +1,47 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!--
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
 -->
 <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">
+
+    <modelVersion>4.0.0</modelVersion>
+
     <parent>
         <groupId>org.apache.aries</groupId>
-        <artifactId>java5-parent</artifactId>
-        <version>1.0.0</version>
-        <relativePath />
+        <artifactId>parent</artifactId>
+        <version>2.0.0-SNAPSHOT</version>
+        <relativePath>../../parent/pom.xml</relativePath>
     </parent>
-    <modelVersion>4.0.0</modelVersion>
+
     <groupId>org.apache.aries.jpa</groupId>
     <artifactId>org.apache.aries.jpa.container.itest.bundle.eclipselink</artifactId>
     <version>0.3.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
     <name>Test Bundle for Aries JPA Container iTests</name>
 
-     <scm>
-         <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-testbundle-eclipselink</connection>
-         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-testbundle-eclipselink</developerConnection>
-         <url>http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-testbundle-eclipselink</url>
-     </scm>
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-testbundle-eclipselink</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/aries/trunk/jpa/jpa-container-testbundle-eclipselink</developerConnection>
+        <url>http://svn.apache.org/viewvc/aries/trunk/jpa/jpa-container-testbundle-eclipselink</url>
+    </scm>
 
     <properties>
         <!-- Export package versions are maintained in packageinfo files -->
-
         <aries.osgi.export.pkg>
             org.apache.aries.jpa.container.itest*
         </aries.osgi.export.pkg>
@@ -47,9 +49,10 @@
             javax.persistence;version="[1.0.0,3.0.0)",
             *
         </aries.osgi.import>
-        <aries.osgi.private.pkg />
+        <aries.osgi.private.pkg/>
         <aries.osgi.symbolic.name>${project.artifactId}</aries.osgi.symbolic.name>
     </properties>
+
     <dependencies>
         <dependency>
             <groupId>org.osgi</groupId>
@@ -62,20 +65,20 @@
             <version>1.1</version>
         </dependency>
         <dependency>
-          <groupId>org.eclipse.persistence</groupId>
-          <artifactId>org.eclipse.persistence.jpa</artifactId>
-          <version>2.1.0</version>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.jpa</artifactId>
+            <version>2.1.0</version>
         </dependency>
         <dependency>
-          <groupId>org.eclipse.persistence</groupId>
-          <artifactId>org.eclipse.persistence.core</artifactId>
-          <version>2.1.0</version>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.core</artifactId>
+            <version>2.1.0</version>
         </dependency>
 
         <dependency>
-          <groupId>org.eclipse.persistence</groupId>
-          <artifactId>org.eclipse.persistence.asm</artifactId>
-          <version>2.1.0</version>
+            <groupId>org.eclipse.persistence</groupId>
+            <artifactId>org.eclipse.persistence.asm</artifactId>
+            <version>2.1.0</version>
         </dependency>
     </dependencies>
 
@@ -91,23 +94,25 @@
                 </configuration>
             </plugin>
             <plugin>
-              <artifactId>maven-antrun-plugin</artifactId>
-              <executions>
-                <execution>
-                  <phase>process-classes</phase>
-                  <configuration>
-                    <tasks>
-                      <java classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave" classpathref="maven.runtime.classpath" fork="true">
-                        <arg line="-persistenceinfo src/main/resources target/classes target/classes"/>
-                      </java>
-                    </tasks>
-                  </configuration>
-                  <goals>
-                    <goal>run</goal>
-                  </goals>
-                </execution>
-              </executions>
+                <artifactId>maven-antrun-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>process-classes</phase>
+                        <configuration>
+                            <tasks>
+                                <java classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave"
+                                      classpathref="maven.runtime.classpath" fork="true">
+                                    <arg line="-persistenceinfo src/main/resources target/classes target/classes"/>
+                                </java>
+                            </tasks>
+                        </configuration>
+                        <goals>
+                            <goal>run</goal>
+                        </goals>
+                    </execution>
+                </executions>
             </plugin>
         </plugins>
     </build>
+
 </project>