aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1684173 - in /aries/trunk/jpa/itests/jpa-container-itest: ./ src/test/java/org/apache/aries/jpa/blueprint/aries/itest/ src/test/java/org/apache/aries/jpa/container/itest/ src/test/java/org/apache/aries/jpa/itest/
Date Mon, 08 Jun 2015 12:54:50 GMT
Author: cschneider
Date: Mon Jun  8 12:54:50 2015
New Revision: 1684173

URL: http://svn.apache.org/r1684173
Log:
[ARIES-1332] Cleaning up versions

Modified:
    aries/trunk/jpa/itests/jpa-container-itest/pom.xml
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
    aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java

Modified: aries/trunk/jpa/itests/jpa-container-itest/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/pom.xml?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/pom.xml (original)
+++ aries/trunk/jpa/itests/jpa-container-itest/pom.xml Mon Jun  8 12:54:50 2015
@@ -296,34 +296,28 @@
         <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.container.itest.bundle</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.container.advanced.itest.bundle</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jpa.itest</groupId>
             <artifactId>org.apache.aries.jpa.container.itest.bundle.blueprint</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jpa.itest</groupId>
             <artifactId>org.apache.aries.jpa.container.itest.bundle.blueprint</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.aries.quiesce</groupId>
-            <artifactId>org.apache.aries.quiesce.api</artifactId>
-            <version>1.0.0</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.aries.transaction</groupId>
             <artifactId>org.apache.aries.transaction.manager</artifactId>
             <version>1.0.0</version>
@@ -356,13 +350,13 @@
         <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.eclipselink.adapter</artifactId>
-            <version>1.0.0-SNAPSHOT</version>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.aries.jpa</groupId>
             <artifactId>org.apache.aries.jpa.container.itest.bundle.eclipselink</artifactId>
-            <version>1.0.3-SNAPSHOT</version>
+            <version>${project.version}</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -372,12 +366,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>org.apache.aries.testsupport</groupId>
-            <artifactId>org.apache.aries.testsupport.unit</artifactId>
-            <version>2.0.0-SNAPSHOT</version>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
             <groupId>org.apache.derby</groupId>
             <artifactId>derby</artifactId>
             <version>10.10.2.0</version>

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmTest.java
Mon Jun  8 12:54:50 2015
@@ -34,7 +34,7 @@ public class BlueprintWithEmTest extends
     public void testEmfAddQuery() throws Exception {
 		Map<String,String> filters = new HashMap<String,String>();
 		filters.put("type", "em");
-		carService = getServie(CarService.class, filters);
+		carService = getService(CarService.class, "(type=em)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -51,9 +51,7 @@ public class BlueprintWithEmTest extends
 
 	@Test
     public void testEmAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "em");
-		carService = getServie(CarService.class, filters);
+		carService = getService(CarService.class, "(type=em)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -70,9 +68,7 @@ public class BlueprintWithEmTest extends
 	
 	@Test
     public void testSupplierAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "supplier");
-		carService = getServie(CarService.class, filters);
+		carService = getService(CarService.class, "(type=supplier)");
 		
 		resolveBundles();
         Car c = new Car();

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithEmfTest.java
Mon Jun  8 12:54:50 2015
@@ -28,13 +28,9 @@ import org.ops4j.pax.exam.Option;
 
 public class BlueprintWithEmfTest extends AbstractJPAItest {
     
-	CarService carService;
-
 	@Test
     public void testEmfAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "emf");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=emf)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -51,9 +47,7 @@ public class BlueprintWithEmfTest extend
 
 	@Test
     public void testEmAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "em");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=emf)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -70,9 +64,7 @@ public class BlueprintWithEmfTest extend
 	
 	@Test
     public void testSupplierAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "supplier");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=supplier)");
 		
 		resolveBundles();
         Car c = new Car();

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/blueprint/aries/itest/BlueprintWithSupplierTest.java
Mon Jun  8 12:54:50 2015
@@ -15,9 +15,6 @@
  */
 package org.apache.aries.jpa.blueprint.aries.itest;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.aries.jpa.itest.AbstractJPAItest;
 import org.apache.aries.jpa.itest.testbundle.entities.Car;
 import org.apache.aries.jpa.itest.testbundle.service.CarService;
@@ -27,14 +24,10 @@ import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 
 public class BlueprintWithSupplierTest extends AbstractJPAItest {
-    
-	CarService carService;
 
 	@Test
     public void testEmfAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "supplier");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=supplier)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -51,9 +44,7 @@ public class BlueprintWithSupplierTest e
 
 	@Test
     public void testEmAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "em");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=em)");
 		
 		resolveBundles();
         Car c = new Car();
@@ -70,9 +61,7 @@ public class BlueprintWithSupplierTest e
 	
 	@Test
     public void testSupplierAddQuery() throws Exception {
-		Map<String,String> filters = new HashMap<String,String>();
-		filters.put("type", "supplier");
-		carService = getServie(CarService.class, filters);
+		CarService carService = getService(CarService.class, "(type=supplier)");
 		
 		resolveBundles();
         Car c = new Car();

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/EclipseLinkStartupTest.java
Mon Jun  8 12:54:50 2015
@@ -19,16 +19,18 @@ import org.apache.aries.jpa.itest.Abstra
 import org.junit.Test;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.options.AbstractProvisionControl;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 
 public class EclipseLinkStartupTest extends AbstractJPAItest {
 
     @Test
     public void testContextCreationWithStartingBundle() throws Exception {
-        context().getBundleByName("org.apache.aries.jpa.container.itest.bundle.eclipselink").start();
+        getBundleByName("org.apache.aries.jpa.container.itest.bundle.eclipselink").start();
         getEMF("script-test-unit");
     }
 
-    @Configuration
+	@Configuration
     public Option[] configuration() {
         return new Option[] {//
             baseOptions(),//

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerDataSourceFactoryTest.java
Mon Jun  8 12:54:50 2015
@@ -41,6 +41,9 @@ public class JPAContainerDataSourceFacto
     @Filter("(osgi.unit.name=" + DSF_XA_TEST_UNIT + ")")
     EntityManagerFactory emfDSFXA;
     
+    @Inject
+    UserTransaction ut;
+    
 
     @Test
     public void testDataSourceFactoryLifecycle() throws Exception {
@@ -65,7 +68,6 @@ public class JPAContainerDataSourceFacto
         EntityManager em = emfDSFXA.createEntityManager();
 
         // Use a JTA transaction to show integration
-        UserTransaction ut = context().getService(UserTransaction.class);
         ut.begin();
         em.joinTransaction();
         Car c = createCar();

Modified: aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
URL: http://svn.apache.org/viewvc/aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java?rev=1684173&r1=1684172&r2=1684173&view=diff
==============================================================================
--- aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
(original)
+++ aries/trunk/jpa/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
Mon Jun  8 12:54:50 2015
@@ -8,28 +8,37 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.vmOption;
 import static org.ops4j.pax.exam.CoreOptions.when;
 
-import java.util.Map;
-
+import javax.inject.Inject;
 import javax.persistence.EntityManagerFactory;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.options.AbstractProvisionControl;
 import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public abstract class AbstractJPAItest extends AbstractIntegrationTest {
+public abstract class AbstractJPAItest {
     protected static final String TEST_UNIT = "test-unit";
     protected static final String BP_TEST_UNIT = "bp-test-unit";
     protected static final String BP_XA_TEST_UNIT = "bp-xa-test-unit";
     protected static final String TEST_BUNDLE_NAME = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
     
+    @Inject
+    protected BundleContext bundleContext;
+
     /**
      * TODO check calls to this. Eventually switch to EmSupplier 
      */
@@ -38,22 +47,62 @@ public abstract class AbstractJPAItest e
     }
     
     protected EntityManagerFactory getEMF(String name) {
-        return context().getService(EntityManagerFactory.class, "osgi.unit.name=" + name);
+        return getService(EntityManagerFactory.class, "osgi.unit.name=" + name);
     }
 
-    protected <T> T getServie(Class<T> type, Map<String, String> filters)
{
-		if (filters.size() > 0) {
-			String filterS = "(&";
-			for (String key : filters.keySet()) {
-				String value = filters.get(key);
-				filterS += String.format("(%s=%s)", key, value);
+    @SuppressWarnings({ "rawtypes", "unchecked" })
+	public <T> T getService(Class<T> type, String filter) {
+        ServiceTracker tracker = null;
+        try {
+            String flt;
+            if (filter != null) {
+                if (filter.startsWith("(")) {
+                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")"
+ filter + ")";
+                } else {
+                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")("
+ filter + "))";
+                }
+            } else {
+                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+            }
+            Filter osgiFilter = FrameworkUtil.createFilter(flt);
+            tracker = new ServiceTracker(bundleContext, osgiFilter, null);
+            tracker.open();
+
+            Object svc = type.cast(tracker.waitForService(10000));
+            if (svc == null) {
+                throw new RuntimeException("Gave up waiting for service " + flt);
+            }
+            return type.cast(svc);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException("Invalid filter", e);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+	/**
+	 * Helps to diagnose bundles that are not resolved as it will throw a detailed exception
+	 * 
+	 * @throws BundleException
+	 */
+	public void resolveBundles() throws BundleException {
+		Bundle[] bundles = bundleContext.getBundles();
+		for (Bundle bundle : bundles) {
+			if (bundle.getState() == Bundle.INSTALLED) {
+				System.out.println("Found non resolved bundle " + bundle.getBundleId() + ":" + bundle.getSymbolicName()
+ ":" + bundle.getVersion());
+				bundle.start();
 			}
-			filterS += ")";
-			return context().getService(type, filterS);
-		} else {
-			return context().getService(type);
 		}
 	}
+	
+    public Bundle getBundleByName(String symbolicName) {
+        for (Bundle b : bundleContext.getBundles()) {
+            if (b.getSymbolicName().equals(symbolicName)) {
+                return b;
+            }
+        }
+        return null;
+    }
 
     @SuppressWarnings("rawtypes")
     protected ServiceReference[] getEMFRefs(String name) throws InvalidSyntaxException {
@@ -73,7 +122,6 @@ public abstract class AbstractJPAItest e
         return composite(junitBundles(),
                 mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.7.2"),
                 mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.7.2"),
-                mvnBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit"),
                 // this is how you set the default log level when using pax
                 // logging (logProfile)
                 systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),



Mime
View raw message