You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/04/18 12:55:42 UTC
[50/50] aries-jpa git commit: [ARIES-1716] Upgrade to pax-jdbc 1.1.0
[ARIES-1716] Upgrade to pax-jdbc 1.1.0
git-svn-id: https://svn.apache.org/repos/asf/aries/trunk/jpa@1791222 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/aries-jpa/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jpa/commit/a5df7f6c
Tree: http://git-wip-us.apache.org/repos/asf/aries-jpa/tree/a5df7f6c
Diff: http://git-wip-us.apache.org/repos/asf/aries-jpa/diff/a5df7f6c
Branch: refs/heads/master
Commit: a5df7f6c13b7c89d157e576054cf556ef55e75dc
Parents: 0421a9a
Author: cschneider <cs...@13f79535-47bb-0310-9956-ffa450edef68>
Authored: Thu Apr 13 08:48:55 2017 +0000
Committer: cschneider <cs...@13f79535-47bb-0310-9956-ffa450edef68>
Committed: Thu Apr 13 08:48:55 2017 +0000
----------------------------------------------------------------------
itests/jpa-container-itest/pom.xml | 8 +-
.../jpa/container/itest/JPAContainerTest.java | 21 +----
.../aries/jpa/itest/AbstractJPAItest.java | 82 +++++++-------------
.../config/org.ops4j.datasource-testds.cfg | 3 +
.../config/org.ops4j.datasource-testdsxa.cfg | 5 ++
.../resources/config/org.ops4j.pax.logging.cfg | 7 ++
.../src/main/resources/META-INF/persistence.xml | 10 +--
itests/pom.xml | 2 +-
8 files changed, 59 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/pom.xml
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/pom.xml b/itests/jpa-container-itest/pom.xml
index 15e23bc..bd7b75a 100644
--- a/itests/jpa-container-itest/pom.xml
+++ b/itests/jpa-container-itest/pom.xml
@@ -352,6 +352,12 @@
<!-- pax exam -->
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-cm</artifactId>
+ <version>${exam.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<version>${exam.version}</version>
<scope>test</scope>
@@ -383,7 +389,7 @@
<dependency>
<groupId>org.ops4j.pax.tinybundles</groupId>
<artifactId>tinybundles</artifactId>
- <version>2.0.0</version>
+ <version>2.1.1</version>
<exclusions>
<exclusion>
<artifactId>org.osgi.core</artifactId>
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
index 607e09e..73c12f6 100644
--- a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/container/itest/JPAContainerTest.java
@@ -30,7 +30,6 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
-import javax.sql.DataSource;
import org.apache.aries.jpa.container.itest.entities.Car;
import org.apache.aries.jpa.itest.AbstractCarJPAITest;
@@ -167,25 +166,14 @@ public abstract class JPAContainerTest extends AbstractCarJPAITest {
@Test
public void testCarEMFBuilderExternalDSXA() throws Exception {
- DataSource ds = getService(DataSource.class,
- "(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver-pool-xa)");
-
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
-
-
+
Map<String, Object> props = new HashMap<String, Object>();
props.put("javax.persistence.jtaDataSource", ds);
props.put("javax.persistence.transactionType", JTA.name());
-
//EclipseLink also needs a non-jta-datasource
- DataSourceFactory dsf = getService(DataSourceFactory.class,
- "(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver)");
- Properties jdbcProps = new Properties();
- jdbcProps.setProperty("url", "jdbc:derby:memory:TEST1;create=true");
- props.put("javax.persistence.nonJtaDataSource", dsf.createDataSource(jdbcProps));
-
-
+ props.put("javax.persistence.nonJtaDataSource", ds);
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleXA(ut, emf.createEntityManager());
}
@@ -195,15 +183,10 @@ public abstract class JPAContainerTest extends AbstractCarJPAITest {
EntityManagerFactoryBuilder emfBuilder = getService(EntityManagerFactoryBuilder.class,
"(osgi.unit.name=" + EXTERNAL_TEST_UNIT + ")");
-
Map<String, Object> props = new HashMap<String, Object>();
- //EclipseLink also needs a non-jta-datasource
- DataSourceFactory dsf = getService(DataSourceFactory.class,
- "(" + OSGI_JDBC_DRIVER_CLASS + "=org.apache.derby.jdbc.EmbeddedDriver)");
Properties jdbcProps = new Properties();
jdbcProps.setProperty("url", "jdbc:derby:memory:TESTNOJTA;create=true");
props.put("javax.persistence.dataSource", dsf.createDataSource(jdbcProps));
-
EntityManagerFactory emf = emfBuilder.createEntityManagerFactory(props);
carLifecycleRL(emf.createEntityManager());
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
index 6fc36ae..42ebc2b 100644
--- a/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
+++ b/itests/jpa-container-itest/src/test/java/org/apache/aries/jpa/itest/AbstractJPAItest.java
@@ -22,16 +22,15 @@ import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import static org.ops4j.pax.exam.CoreOptions.vmOption;
import static org.ops4j.pax.exam.CoreOptions.when;
+import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.configurationFolder;
-import java.io.IOException;
-import java.util.Dictionary;
-import java.util.Hashtable;
+import java.io.File;
import javax.inject.Inject;
import javax.persistence.EntityManagerFactory;
+import javax.sql.DataSource;
import javax.transaction.UserTransaction;
-import org.junit.Before;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
@@ -47,18 +46,12 @@ 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.Configuration;
-import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.jdbc.DataSourceFactory;
import org.osgi.util.tracker.ServiceTracker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public abstract class AbstractJPAItest {
- private static Logger LOG = LoggerFactory.getLogger(AbstractJPAItest.class);
-
protected static final String TEST_UNIT = "test-unit";
protected static final String XA_TEST_UNIT = "xa-test-unit";
protected static final String DSF_TEST_UNIT = "dsf-test-unit";
@@ -67,18 +60,23 @@ public abstract class AbstractJPAItest {
protected static final String TEST_BUNDLE_NAME = "org.apache.aries.jpa.org.apache.aries.jpa.container.itest.bundle";
- protected static final String BLUE_CAR_PLATE = "A1AAA";
- protected static final String GREEN_CAR_PLATE = "B2BBB";
-
@Inject
protected BundleContext bundleContext;
@Inject
protected UserTransaction ut;
-
+
@Inject
- protected ConfigurationAdmin configAdmin;
- private static Configuration config;
+ @org.ops4j.pax.exam.util.Filter("(osgi.jndi.service.name=testds)")
+ protected DataSource ds;
+
+ @Inject
+ @org.ops4j.pax.exam.util.Filter("(osgi.jndi.service.name=testdsxa)")
+ protected DataSource dsXa;
+
+ @Inject
+ @org.ops4j.pax.exam.util.Filter("(osgi.jdbc.driver.class=org.apache.derby.jdbc.EmbeddedDriver)")
+ protected DataSourceFactory dsf;
/**
* TODO check calls to this. Eventually switch to EmSupplier
@@ -119,7 +117,7 @@ public abstract class AbstractJPAItest {
}
}
- public String sanitizeFilter(String filter) {
+ private String sanitizeFilter(String filter) {
return filter.startsWith("(") ? filter : "(" + filter + ")";
}
@@ -158,22 +156,26 @@ public abstract class AbstractJPAItest {
}
protected Option baseOptions() {
- String localRepo = System.getProperty("maven.repo.local");
-
- if (localRepo == null) {
- localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
- }
+ String localRepo = getLocalRepo();
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"),
- // this is how you set the default log level when using pax
- // logging (logProfile)
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
- when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo))
- //,
+ //systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+ when(localRepo != null).useOptions(vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + localRepo)),
+ configurationFolder(new File("src/test/resources/config"))
);
}
+ private String getLocalRepo() {
+ String localRepo = System.getProperty("maven.repo.local");
+
+ if (localRepo == null) {
+ localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+ }
+ return localRepo;
+ }
+
protected Option debug() {
return vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
}
@@ -278,6 +280,7 @@ public abstract class AbstractJPAItest {
mvnBundle("org.apache.commons", "commons-dbcp2"), //
mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-pool-common"), //
mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-pool-dbcp2"), //
+ mvnBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.jasypt"), //
mvnBundle("org.ops4j.pax.jdbc", "pax-jdbc-config")
);
}
@@ -310,31 +313,4 @@ public abstract class AbstractJPAItest {
return mvnBundle("org.apache.aries.jpa", "org.apache.aries.jpa.container.itest.bundle.eclipselink");
}
- @Before
- public void createConfigForDataSource() throws Exception {
- if (config == null) {
- createConfigForLogging();
- config = configAdmin.createFactoryConfiguration("org.ops4j.datasource", null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "org.apache.derby.jdbc.EmbeddedDriver-pool-xa");
- props.put(DataSourceFactory.JDBC_URL, "jdbc:derby:memory:TEST1;create=true");
- props.put("dataSourceName", "testds");
- config.update(props);
- LOG.info("Created DataSource config testds");
- }
- }
-
- public void createConfigForLogging() throws IOException {
- Configuration logConfig = configAdmin.getConfiguration("org.ops4j.pax.logging", null);
- Dictionary<String, String> props = new Hashtable<String, String>();
- props.put("log4j.rootLogger", "INFO, stdout");
- props.put("log4j.logger.org.apache.aries.transaction", "DEBUG");
- props.put("log4j.logger.org.apache.aries.transaction.parsing", "DEBUG");
- props.put("log4j.logger.org.apache.aries.jpa.blueprint.impl", "DEBUG");
- props.put("log4j.appender.stdout", "org.apache.log4j.ConsoleAppender");
- props.put("log4j.appender.stdout.layout", "org.apache.log4j.PatternLayout");
- props.put("log4j.appender.stdout.layout.ConversionPattern", "%d{ISO8601} | %-5.5p | %-16.16t | %c | %m%n");
- logConfig.update(props);
- }
-
}
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testds.cfg
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testds.cfg b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testds.cfg
new file mode 100644
index 0000000..af4bce9
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testds.cfg
@@ -0,0 +1,3 @@
+osgi.jdbc.driver.class=org.apache.derby.jdbc.EmbeddedDriver
+url=jdbc:derby:memory:TEST1;create=true
+dataSourceName=testds
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testdsxa.cfg
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testdsxa.cfg b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testdsxa.cfg
new file mode 100644
index 0000000..9d3b0eb
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.datasource-testdsxa.cfg
@@ -0,0 +1,5 @@
+osgi.jdbc.driver.class=org.apache.derby.jdbc.EmbeddedDriver
+pool=dbcp2
+xa=true
+url=jdbc:derby:memory:TESTXA;create=true
+dataSourceName=testdsxa
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-itest/src/test/resources/config/org.ops4j.pax.logging.cfg
----------------------------------------------------------------------
diff --git a/itests/jpa-container-itest/src/test/resources/config/org.ops4j.pax.logging.cfg b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.pax.logging.cfg
new file mode 100644
index 0000000..ebbf43b
--- /dev/null
+++ b/itests/jpa-container-itest/src/test/resources/config/org.ops4j.pax.logging.cfg
@@ -0,0 +1,7 @@
+log4j.rootLogger=INFO, stdout
+#log4j.logger.org.apache.aries.transaction=DEBUG
+#log4j.logger.org.apache.aries.transaction.parsing=DEBUG
+#log4j.logger.org.apache.aries.jpa.blueprint.impl=DEBUG
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ISO8601} | %-5.5p | %-16.16t | %c | %m%n
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml b/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
index dd96ff2..6d4fd63 100644
--- a/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
+++ b/itests/jpa-container-testbundle/src/main/resources/META-INF/persistence.xml
@@ -25,7 +25,7 @@
<persistence-unit name="test-unit" transaction-type="RESOURCE_LOCAL">
<description>Test persistence unit for the JPA Container and Context iTests</description>
- <non-jta-data-source>osgi:service/javax.sql.DataSource</non-jta-data-source>
+ <non-jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testds)</non-jta-data-source>
<properties>
<!-- This is to avoid compile time enhancement which would conflict with hibernate -->
<property name="openjpa.RuntimeUnenhancedClasses" value="supported"/>
@@ -43,10 +43,9 @@
<persistence-unit name="xa-test-unit" transaction-type="JTA">
<description>Test persistence unit for the JPA Container advanced iTests</description>
+
+ <jta-data-source>osgi:service/javax.sql.DataSource/(osgi.jndi.service.name=testdsxa)</jta-data-source>
<properties>
- <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver-pool-xa" />
- <property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:XATEST;create=true" />
-
<!-- These properties are creating the database on the fly. We are using them to avoid the tests having to create a database -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)" />
<property name="openjpa.jdbc.DBDictionary" value="derby" />
@@ -76,7 +75,8 @@
<persistence-unit name="dsf-xa-test-unit" transaction-type="JTA">
<description>Test persistence unit for the JPA Container DataSourceFactory iTests</description>
<properties>
- <!-- These properties are creating the database on the fly. We are using them to avoid the tests having to create a database --> <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver-pool-xa"/>
+ <!-- These properties are creating the database on the fly. We are using them to avoid the tests having to create a database -->
+ <property name="javax.persistence.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:derby:memory:DSFXATEST;create=true"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
http://git-wip-us.apache.org/repos/asf/aries-jpa/blob/a5df7f6c/itests/pom.xml
----------------------------------------------------------------------
diff --git a/itests/pom.xml b/itests/pom.xml
index c27c498..a852755 100644
--- a/itests/pom.xml
+++ b/itests/pom.xml
@@ -45,7 +45,7 @@
<serp.bundle.version>1.14.1_1</serp.bundle.version>
<eclipselink.version>2.6.0</eclipselink.version>
<openjpa.version>2.3.0</openjpa.version>
- <paxjdbc.version>0.7.0</paxjdbc.version>
+ <paxjdbc.version>1.1.0</paxjdbc.version>
</properties>
<modules>