aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r1748528 - in /aries/trunk/tx-control: tx-control-itests/ tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/ tx-control-jpa-itests/ tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/
Date Wed, 15 Jun 2016 09:04:32 GMT
Author: timothyjward
Date: Wed Jun 15 09:04:32 2016
New Revision: 1748528

URL: http://svn.apache.org/viewvc?rev=1748528&view=rev
Log:
[tx-control] Switch dependencies to release versions

Modified:
    aries/trunk/tx-control/tx-control-itests/pom.xml
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
    aries/trunk/tx-control/tx-control-jpa-itests/pom.xml
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleEclipseLink_2_6_0_Test.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleHibernate_5_0_9_Test.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleOpenJPA_2_4_1_Test.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAEclipseLink_2_6_0_Test.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAJPATransactionTest.java
    aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAOpenJPA_2_4_1_Test.java

Modified: aries/trunk/tx-control/tx-control-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/pom.xml?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-itests/pom.xml Wed Jun 15 09:04:32 2016
@@ -124,12 +124,6 @@
 			<version>3.1.4.RELEASE</version>
 			<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>
 
 		<!-- pax exam -->
 		<dependency>

Modified: aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
(original)
+++ aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
Wed Jun 15 09:04:32 2016
@@ -29,10 +29,14 @@ import java.io.IOException;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.NoSuchElementException;
 import java.util.Properties;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
+import javax.inject.Inject;
+
 import org.h2.tools.Server;
 import org.junit.After;
 import org.junit.Before;
@@ -43,30 +47,41 @@ import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.jdbc.DataSourceFactory;
 import org.osgi.service.transaction.control.TransactionControl;
 import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider;
 import org.osgi.service.transaction.control.jdbc.JDBCConnectionProviderFactory;
+import org.osgi.util.tracker.ServiceTracker;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public abstract class AbstractTransactionTest extends AbstractIntegrationTest {
-
+public abstract class AbstractTransactionTest {
+	
 	private static final String TX_CONTROL_FILTER = "org.apache.aries.tx.control.itests.filter";
 	private static final String REMOTE_DB_PROPERTY = "org.apache.aries.tx.control.itests.remotedb";
 	private static final String CONFIGURED_PROVIDER_PROPERTY = "org.apache.aries.tx.control.itests.configured";
 
+	@Inject
+	BundleContext context;
+	
 	protected TransactionControl txControl;
 
 	protected Connection connection;
 
 	private Server server;
+	
+	private final List<ServiceTracker<?,?>> trackers = new ArrayList<>();
 
 	@Before
 	public void setUp() throws Exception {
 		
-		txControl = context().getService(TransactionControl.class, 
+		txControl = getService(TransactionControl.class, 
 				System.getProperty(TX_CONTROL_FILTER), 5000);
 		
 		Properties jdbc = new Properties();
@@ -99,12 +114,43 @@ public abstract class AbstractTransactio
 			});
 	}
 
+	private <T> T getService(Class<T> clazz, long timeout) {
+		try {
+			return getService(clazz, null, timeout);
+		} catch (InvalidSyntaxException e) {
+			throw new IllegalArgumentException(e);
+		}
+	}
+
+	private <T> T getService(Class<T> clazz, String filter, long timeout) throws
InvalidSyntaxException {
+		Filter f = FrameworkUtil.createFilter(filter == null ? "(|(foo=bar)(!(foo=bar)))" : filter);

+		
+		ServiceTracker<T, T> tracker = new ServiceTracker<T, T>(context, clazz, null)
{
+			@Override
+			public T addingService(ServiceReference<T> reference) {
+				return f.match(reference) ? super.addingService(reference) : null;
+			}
+		};
+
+		tracker.open();
+		try {
+			T t = tracker.waitForService(timeout);
+			if(t == null) {
+				throw new NoSuchElementException(clazz.getName());
+			}
+			return t;
+		} catch (InterruptedException e) {
+			throw new RuntimeException("Error waiting for service " + clazz.getName(), e);
+		} finally {
+			trackers.add(tracker);
+		}
+	}
+	
 	private Connection programaticConnection(Properties jdbc) {
 		
-		JDBCConnectionProviderFactory resourceProviderFactory = context()
-				.getService(JDBCConnectionProviderFactory.class, 5000);
+		JDBCConnectionProviderFactory resourceProviderFactory = getService(JDBCConnectionProviderFactory.class,
5000);
 		
-		DataSourceFactory dsf = context().getService(DataSourceFactory.class, 5000);
+		DataSourceFactory dsf = getService(DataSourceFactory.class, 5000);
 		
 		return resourceProviderFactory.getProviderFor(dsf, jdbc, null).getResource(txControl);
 	}
@@ -115,7 +161,7 @@ public abstract class AbstractTransactio
 		String type = System.getProperty(CONFIGURED_PROVIDER_PROPERTY);
 		
 		jdbc.setProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "org.h2.Driver");
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		
 		String pid = "local".equals(type) ? "org.apache.aries.tx.control.jdbc.local" 
 				: "org.apache.aries.tx.control.jdbc.xa";
@@ -126,7 +172,7 @@ public abstract class AbstractTransactio
 				pid, null);
 		config.update((Hashtable)jdbc);
 		
-		return context().getService(JDBCConnectionProvider.class, 5000).getResource(txControl);
+		return getService(JDBCConnectionProvider.class, 5000).getResource(txControl);
 	}
 	
 	@After
@@ -143,12 +189,14 @@ public abstract class AbstractTransactio
 		if(server != null) {
 			server.stop();
 		}
+		
+		trackers.stream().forEach(ServiceTracker::close);
 
 		connection = null;
 	}
 
 	private void clearConfiguration() {
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		org.osgi.service.cm.Configuration[] cfgs = null;
 		try {
 			cfgs = cm.listConfigurations(null);
@@ -184,7 +232,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 						.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				localTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				when(testSpecificOptions != null).useOptions(testSpecificOptions),
@@ -207,7 +254,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				localTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
@@ -231,7 +277,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				localTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
@@ -257,7 +302,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 						.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				xaTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				when(testSpecificOptions != null).useOptions(testSpecificOptions),
@@ -280,7 +324,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				xaTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
@@ -304,7 +347,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				xaTxControlService(),
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
@@ -330,7 +372,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				xaTxControlService(),
 				xaJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
@@ -354,7 +395,6 @@ public abstract class AbstractTransactio
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				xaTxControlService(),
 				xaJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),

Modified: aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
(original)
+++ aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
Wed Jun 15 09:04:32 2016
@@ -38,7 +38,6 @@ import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
 import org.h2.tools.Server;
 import org.junit.After;
 import org.junit.Before;
@@ -58,7 +57,7 @@ import org.osgi.service.transaction.cont
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public class XATransactionTest extends AbstractIntegrationTest {
+public class XATransactionTest {
 
 	@Inject
 	@Filter("(osgi.xa.enabled=true)")
@@ -67,6 +66,10 @@ public class XATransactionTest extends A
 	@Inject
 	@Filter("(osgi.xa.enabled=true)")
 	private JDBCConnectionProviderFactory factory;
+
+	@Inject
+	@Filter("(osgi.jdbc.driver.class=org.h2.Driver)")
+	private DataSourceFactory dsf;
 	
 	protected Connection connection1;
 	protected Connection connection2;
@@ -88,10 +91,10 @@ public class XATransactionTest extends A
 		String jdbcUrl2 = "jdbc:h2:tcp://127.0.0.1:" + server2.getPort() + "/" + getRemoteDBPath("db2");
 		
 		jdbc.setProperty(DataSourceFactory.JDBC_URL, jdbcUrl1);
-		connection1 = programaticConnection(jdbc);
+		connection1 = factory.getProviderFor(dsf, jdbc, null).getResource(txControl);
 		
 		jdbc.setProperty(DataSourceFactory.JDBC_URL, jdbcUrl2);
-		connection2 = programaticConnection(jdbc);
+		connection2 = factory.getProviderFor(dsf, jdbc, null).getResource(txControl);
 		
 		txControl.required(() -> {
 				Statement s = connection1.createStatement();
@@ -111,16 +114,6 @@ public class XATransactionTest extends A
 			});
 	}
 
-	private Connection programaticConnection(Properties jdbc) {
-		
-		JDBCConnectionProviderFactory resourceProviderFactory = context()
-				.getService(JDBCConnectionProviderFactory.class, 5000);
-		
-		DataSourceFactory dsf = context().getService(DataSourceFactory.class, 5000);
-		
-		return resourceProviderFactory.getProviderFor(dsf, jdbc, null).getResource(txControl);
-	}
-
 	@After
 	public void tearDown() {
 
@@ -230,7 +223,6 @@ public class XATransactionTest extends A
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-service-xa").versionAsInProject(),
 				mavenBundle("com.h2database", "h2").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-provider-jdbc-xa").versionAsInProject(),

Modified: aries/trunk/tx-control/tx-control-jpa-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/pom.xml?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/pom.xml Wed Jun 15 09:04:32 2016
@@ -94,12 +94,6 @@
 			<version>1.4.191</version>
 			<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>
 
 		<!-- pax exam -->
 		<dependency>

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractJPATransactionTest.java
Wed Jun 15 09:04:32 2016
@@ -27,12 +27,15 @@ import static org.ops4j.pax.exam.CoreOpt
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.NoSuchElementException;
 
+import javax.inject.Inject;
 import javax.persistence.EntityManager;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
 import org.h2.tools.Server;
 import org.junit.After;
 import org.junit.Before;
@@ -45,30 +48,41 @@ import org.ops4j.pax.exam.TestProbeBuild
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
 import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.jdbc.DataSourceFactory;
 import org.osgi.service.jpa.EntityManagerFactoryBuilder;
 import org.osgi.service.transaction.control.TransactionControl;
 import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider;
+import org.osgi.util.tracker.ServiceTracker;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public abstract class AbstractJPATransactionTest extends AbstractIntegrationTest {
+public abstract class AbstractJPATransactionTest {
 
 	protected static final String TX_CONTROL_FILTER = "tx.control.filter";
 	protected static final String ARIES_EMF_BUILDER_TARGET_FILTER = "aries.emf.builder.target.filter";
 	protected static final String IS_XA = "aries.test.is.xa";
 
+	@Inject
+	BundleContext context;
+	
 	protected TransactionControl txControl;
 
 	protected EntityManager em;
 
 	private Server server;
+	
+	private final List<ServiceTracker<?,?>> trackers = new ArrayList<>();
 
 	@Before
 	public void setUp() throws Exception {
 		
-		txControl = context().getService(TransactionControl.class, System.getProperty(TX_CONTROL_FILTER),
5000);
+		txControl = getService(TransactionControl.class, System.getProperty(TX_CONTROL_FILTER),
5000);
 		
 		server = Server.createTcpServer("-tcpPort", "0");
 		server.start();
@@ -78,6 +92,38 @@ public abstract class AbstractJPATransac
 		em = configuredEntityManager(jdbcUrl);
 	}
 
+	private <T> T getService(Class<T> clazz, long timeout) {
+		try {
+			return getService(clazz, null, timeout);
+		} catch (InvalidSyntaxException e) {
+			throw new IllegalArgumentException(e);
+		}
+	}
+
+	private <T> T getService(Class<T> clazz, String filter, long timeout) throws
InvalidSyntaxException {
+		Filter f = FrameworkUtil.createFilter(filter == null ? "(|(foo=bar)(!(foo=bar)))" : filter);

+		
+		ServiceTracker<T, T> tracker = new ServiceTracker<T, T>(context, clazz, null)
{
+			@Override
+			public T addingService(ServiceReference<T> reference) {
+				return f.match(reference) ? super.addingService(reference) : null;
+			}
+		};
+
+		tracker.open();
+		try {
+			T t = tracker.waitForService(timeout);
+			if(t == null) {
+				throw new NoSuchElementException(clazz.getName());
+			}
+			return t;
+		} catch (InterruptedException e) {
+			throw new RuntimeException("Error waiting for service " + clazz.getName(), e);
+		} finally {
+			trackers.add(tracker);
+		}
+	}
+	
 	private String getRemoteDBPath() {
 		String fullResourceName = getClass().getName().replace('.', '/') + ".class";
 		
@@ -102,7 +148,7 @@ public abstract class AbstractJPATransac
 			props.put(ARIES_EMF_BUILDER_TARGET_FILTER, filter);
 		}
 		
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		
 		String pid = getBoolean(IS_XA) ? "org.apache.aries.tx.control.jpa.xa" :
 				"org.apache.aries.tx.control.jpa.local"; 
@@ -113,7 +159,7 @@ public abstract class AbstractJPATransac
 				pid, null);
 		config.update(props);
 		
-		return context().getService(JPAEntityManagerProvider.class, 5000).getResource(txControl);
+		return getService(JPAEntityManagerProvider.class, 5000).getResource(txControl);
 	}
 
 	protected Dictionary<String, Object> getBaseProperties() {
@@ -129,11 +175,13 @@ public abstract class AbstractJPATransac
 			server.stop();
 		}
 
+		trackers.stream().forEach(ServiceTracker::close);
+		
 		em = null;
 	}
 
 	private void clearConfiguration() {
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		org.osgi.service.cm.Configuration[] cfgs = null;
 		try {
 			cfgs = cm.listConfigurations(null);
@@ -174,7 +222,6 @@ public abstract class AbstractJPATransac
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				localTxControlService(),
 				localJpaResourceProviderWithH2(),
 				jpaProvider(),
@@ -197,7 +244,6 @@ public abstract class AbstractJPATransac
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				systemProperty(IS_XA).value(Boolean.TRUE.toString()),
 				xaTxControlService(),
 				xaJpaResourceProviderWithH2(),

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleEclipseLink_2_6_0_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleEclipseLink_2_6_0_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleEclipseLink_2_6_0_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleEclipseLink_2_6_0_Test.java
Wed Jun 15 09:04:32 2016
@@ -44,7 +44,7 @@ public class SimpleEclipseLink_2_6_0_Tes
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm", "2.6.0"),
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr", "2.6.0"),
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa.jpql", "2.6.0"),
-				mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter", "2.4.0-SNAPSHOT"));
+				mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter", "2.4.0"));
 	}
 
 }

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleHibernate_5_0_9_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleHibernate_5_0_9_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleHibernate_5_0_9_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleHibernate_5_0_9_Test.java
Wed Jun 15 09:04:32 2016
@@ -29,7 +29,7 @@ import org.ops4j.pax.exam.Option;
 public class SimpleHibernate_5_0_9_Test extends AbstractSimpleTransactionTest {
 
 	protected String ariesJPAVersion() {
-		return "2.4.0-SNAPSHOT";
+		return "2.4.0";
 	}
 	
 	@Override

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleOpenJPA_2_4_1_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleOpenJPA_2_4_1_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleOpenJPA_2_4_1_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleOpenJPA_2_4_1_Test.java
Wed Jun 15 09:04:32 2016
@@ -32,7 +32,7 @@ import org.ops4j.pax.exam.Option;
 public class SimpleOpenJPA_2_4_1_Test extends AbstractSimpleTransactionTest {
 
 	protected String ariesJPAVersion() {
-		return "2.4.0-SNAPSHOT";
+		return "2.4.0";
 	}
 	
 	protected Dictionary<String, Object> getBaseProperties() {

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAEclipseLink_2_6_0_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAEclipseLink_2_6_0_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAEclipseLink_2_6_0_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAEclipseLink_2_6_0_Test.java
Wed Jun 15 09:04:32 2016
@@ -44,7 +44,7 @@ public class XAEclipseLink_2_6_0_Test ex
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.asm", "2.6.0"),
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.antlr", "2.6.0"),
 				mavenBundle("org.eclipse.persistence", "org.eclipse.persistence.jpa.jpql", "2.6.0"),
-				mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter", "2.4.0-SNAPSHOT"));
+				mavenBundle("org.apache.aries.jpa", "org.apache.aries.jpa.eclipselink.adapter", "2.4.0"));
 	}
 
 }

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAHibernate_5_0_9_Test.java
Wed Jun 15 09:04:32 2016
@@ -29,7 +29,7 @@ import org.ops4j.pax.exam.Option;
 public class XAHibernate_5_0_9_Test extends XAJPATransactionTest {
 
 	protected String ariesJPAVersion() {
-		return "2.4.0-SNAPSHOT";
+		return "2.4.0";
 	}
 	
 	@Override

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAJPATransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAJPATransactionTest.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAJPATransactionTest.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAJPATransactionTest.java
Wed Jun 15 09:04:32 2016
@@ -28,12 +28,14 @@ import static org.ops4j.pax.exam.CoreOpt
 import static org.ops4j.pax.exam.CoreOptions.when;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Dictionary;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.NoSuchElementException;
 
 import javax.inject.Inject;
 import javax.persistence.EntityManager;
@@ -43,7 +45,6 @@ import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
 import javax.transaction.xa.Xid;
 
-import org.apache.aries.itest.AbstractIntegrationTest;
 import org.apache.aries.tx.control.itests.entity.Message;
 import org.h2.tools.Server;
 import org.junit.After;
@@ -60,16 +61,21 @@ import org.ops4j.pax.exam.spi.reactors.E
 import org.ops4j.pax.exam.spi.reactors.PerClass;
 import org.ops4j.pax.exam.util.Filter;
 import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.jdbc.DataSourceFactory;
 import org.osgi.service.jpa.EntityManagerFactoryBuilder;
 import org.osgi.service.transaction.control.TransactionControl;
 import org.osgi.service.transaction.control.TransactionRolledBackException;
 import org.osgi.service.transaction.control.jpa.JPAEntityManagerProvider;
+import org.osgi.util.tracker.ServiceTracker;
 
 @RunWith(PaxExam.class)
 @ExamReactorStrategy(PerClass.class)
-public abstract class XAJPATransactionTest  extends AbstractIntegrationTest {
+public abstract class XAJPATransactionTest {
 
 	static final String XA_TEST_UNIT_1 = "xa-test-unit-1";
 	static final String XA_TEST_UNIT_2 = "xa-test-unit-2";
@@ -77,6 +83,9 @@ public abstract class XAJPATransactionTe
 	protected static final String ARIES_EMF_BUILDER_TARGET_FILTER = "aries.emf.builder.target.filter";
 	
 	@Inject
+	BundleContext context;
+	
+	@Inject
 	@Filter("(osgi.xa.enabled=true)")
 	protected TransactionControl txControl;
 
@@ -85,6 +94,8 @@ public abstract class XAJPATransactionTe
 
 	private Server server1;
 	private Server server2;
+	
+	private final List<ServiceTracker<?,?>> trackers = new ArrayList<>();
 
 	@Before
 	public void setUp() throws Exception {
@@ -111,7 +122,7 @@ public abstract class XAJPATransactionTe
 		return new File(testClassesDir.getParentFile(), "testdb/" + dbName).getAbsolutePath();
 	}
 	
-	private EntityManager configuredEntityManager(String jdbcUrl, String unit) throws IOException
{
+	private EntityManager configuredEntityManager(String jdbcUrl, String unit) throws Exception
{
 		
 		Dictionary<String, Object> props = getBaseProperties();
 		
@@ -125,17 +136,49 @@ public abstract class XAJPATransactionTe
 			props.put(ARIES_EMF_BUILDER_TARGET_FILTER, "(&(osgi.unit.name=" + unit + ")" + filter
+ ")");
 		}
 		
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		
 		org.osgi.service.cm.Configuration config = cm.createFactoryConfiguration(
 				"org.apache.aries.tx.control.jpa.xa", null);
 		config.update(props);
 		
-		return context().getService(JPAEntityManagerProvider.class,
+		return getService(JPAEntityManagerProvider.class,
 				"(" + EntityManagerFactoryBuilder.JPA_UNIT_NAME + "=" + unit + ")",
 				5000).getResource(txControl);
 	}
 
+	private <T> T getService(Class<T> clazz, long timeout) {
+		try {
+			return getService(clazz, null, timeout);
+		} catch (InvalidSyntaxException e) {
+			throw new IllegalArgumentException(e);
+		}
+	}
+
+	private <T> T getService(Class<T> clazz, String filter, long timeout) throws
InvalidSyntaxException {
+		org.osgi.framework.Filter f = FrameworkUtil.createFilter(filter == null ? "(|(foo=bar)(!(foo=bar)))"
: filter); 
+		
+		ServiceTracker<T, T> tracker = new ServiceTracker<T, T>(context, clazz, null)
{
+			@Override
+			public T addingService(ServiceReference<T> reference) {
+				return f.match(reference) ? super.addingService(reference) : null;
+			}
+		};
+
+		tracker.open();
+		try {
+			T t = tracker.waitForService(timeout);
+			if(t == null) {
+				throw new NoSuchElementException(clazz.getName());
+			}
+			return t;
+		} catch (InterruptedException e) {
+			throw new RuntimeException("Error waiting for service " + clazz.getName(), e);
+		} finally {
+			trackers.add(tracker);
+		}
+	}
+	
 	protected Dictionary<String, Object> getBaseProperties() {
 		return new Hashtable<>();
 	}
@@ -152,12 +195,14 @@ public abstract class XAJPATransactionTe
 			server2.stop();
 		}
 
+		trackers.stream().forEach(ServiceTracker::close);
+		
 		em1 = null;
 		em2 = null;
 	}
 
 	private void clearConfiguration() {
-		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
+		ConfigurationAdmin cm = getService(ConfigurationAdmin.class, 5000);
 		org.osgi.service.cm.Configuration[] cfgs = null;
 		try {
 			cfgs = cm.listConfigurations(null);
@@ -196,7 +241,6 @@ public abstract class XAJPATransactionTe
 		return options(junitBundles(), systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
 				when(localRepo != null)
 				.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
-				mavenBundle("org.apache.aries.testsupport", "org.apache.aries.testsupport.unit").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-service-xa").versionAsInProject(),
 				mavenBundle("com.h2database", "h2").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-provider-jpa-xa").versionAsInProject(),
@@ -308,8 +352,16 @@ public abstract class XAJPATransactionTe
 	}
 	
 	Object getMessageEntityFrom(String unit) throws Exception {
-		Class<?> clz = context().getBundleByName(unit).loadClass(
-				"org.apache.aries.tx.control.itests.entity.Message");
+		Class<?> clz = Arrays.stream(context.getBundles())
+					.filter(b -> unit.equals(b.getSymbolicName()))
+					.map(b -> {
+							try {
+								return b.loadClass("org.apache.aries.tx.control.itests.entity.Message");
+							} catch (ClassNotFoundException e) {
+								throw new RuntimeException(e);
+							}
+						})
+					.findFirst().orElseThrow(() -> new IllegalArgumentException(unit));
 		return clz.newInstance();
 	}
 	

Modified: aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAOpenJPA_2_4_1_Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAOpenJPA_2_4_1_Test.java?rev=1748528&r1=1748527&r2=1748528&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAOpenJPA_2_4_1_Test.java
(original)
+++ aries/trunk/tx-control/tx-control-jpa-itests/src/test/java/org/apache/aries/tx/control/itests/XAOpenJPA_2_4_1_Test.java
Wed Jun 15 09:04:32 2016
@@ -33,7 +33,7 @@ public class XAOpenJPA_2_4_1_Test extend
 
 	@Override
 	protected String ariesJPAVersion() {
-		return "2.4.0-SNAPSHOT";
+		return "2.4.0";
 	}
 	
 	@Override



Mime
View raw message