Behavior which requires a persistence provider but does not use the persistence provider
extensively is only tested with hibernate.
+Test code for each of the JPA providers is in a separate 'jpatest-' project. This is
+required to remove the dependence on the JPA provider from the pom, allowing them to
+be deployed to the central maven repo.
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-utils</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-jpatest-eclipselink</artifactId>
+ <packaging>jar</packaging>
+ <name>/test/eclipselink</name>
+ <url>http://wamblee.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>EclipseLink Repo</id>
+ <url>http://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/rt/eclipselink/maven.repo</url>
+ </repository>
+
+ </repositories>
+
+
+</project>
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.eclipselink;
+
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+import org.wamblee.io.FileSystemUtils;
+import org.wamblee.support.persistence.JpaCustomizer;
+import org.wamblee.support.persistence.PersistenceUnitDescription;
+
+import java.io.File;
+import java.util.Map;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class EclipselinkJpaCustomizer implements JpaCustomizer {
+ /**
+ * Creates a new EclipselinkJpaCustomizer object.
+ */
+ public EclipselinkJpaCustomizer() {
+ // Empty
+ }
+
+ @Override
+ public void customize(PersistenceUnitDescription aPersistenceUnit,
+ Map<String, String> aJpaProperties) {
+
+ // DDL generation
+ aJpaProperties.put("eclipselink.ddl-generation", "create-tables");
+
+ // DDL generation
+ FileSystemUtils.createDir(new File("target/sql"));
+ aJpaProperties.put("eclipselink.application-location", "target/sql");
+ aJpaProperties.put("eclipselink.create-ddl-jdbc-file-name", "create-schema.sql");
+ aJpaProperties.put("eclipselink.drop-ddl-jdbc-file-name", "drop-schema.sql");
+ aJpaProperties.put("eclipselink.ddl-generation.output-mode", "both");
+ }
+
+ @Override
+ public ITableFilterSimple getJpaTables() {
+ return new EclipselinkTables();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.eclipselink;
+
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Toplink-specific tables.
+ */
+public class EclipselinkTables implements ITableFilterSimple {
+ private static final List<String> TABLES = Arrays
+ .asList(new String[] { "SEQUENCE" });
+
+ public boolean accept(String aTableName) throws DataSetException {
+ return TABLES.contains(aTableName);
+ }
+}
--- /dev/null
+org.wamblee.support.persistence.eclipselink.EclipselinkJpaCustomizer
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.eclipselink;
+
+import org.wamblee.support.persistence.DatabaseUtilsTestBase;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class DatabaseUtilsTest extends DatabaseUtilsTestBase {
+ // Empty, all tests inherited
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.eclipselink;
+
+import org.wamblee.support.persistence.MyEntityExampleTestBase;
+
+/**
+ * This class shows an example of how to test an entity using jpa.
+ */
+public class MyEntityExampleTest extends MyEntityExampleTestBase {
+ // Empty, all tests are inherited
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-utils</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-jpatest-hibernate</artifactId>
+ <packaging>jar</packaging>
+ <name>/test/hibernate</name>
+ <url>http://wamblee.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-hibernate-jpa</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.hibernate;
+
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+import org.wamblee.support.persistence.JpaCustomizer;
+import org.wamblee.support.persistence.PersistenceUnitDescription;
+
+import java.util.Map;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class HibernateJpaCustomizer implements JpaCustomizer {
+ /**
+ * Creates a new HibernateJpaCustomizer object.
+ */
+ public HibernateJpaCustomizer() {
+ // Empty
+ }
+
+ @Override
+ public void customize(PersistenceUnitDescription aPersistenceUnit,
+ Map<String, String> aJpaProperties) {
+
+ System.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "true");
+
+ // Set non-JPA connection properties for older versions of hibernate
+ System.getProperties().remove("hibernate.connection.datasource");
+ if (System.getProperty("hibernate.connection.datasource") != null ) {
+ throw new RuntimeException("ERROR");
+ }
+ System.setProperty("hibernate.connection.url", aJpaProperties.get("javax.persistence.jdbc.url"));
+ System.setProperty("hibernate.connection.username", aJpaProperties.get("javax.persistence.jdbc.user"));
+ System.setProperty("hibernate.connection.password", aJpaProperties.get("javax.persistence.jdbc.password"));
+
+ // Hibernate schema generation
+ aJpaProperties.put("hibernate.hbm2ddl.auto", "create");
+ }
+
+ @Override
+ public ITableFilterSimple getJpaTables() {
+ return new HibernateTables();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.hibernate;
+
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Toplink-specific tables.
+ */
+public class HibernateTables implements ITableFilterSimple {
+ private static final List<String> TABLES = Arrays
+ .asList(new String[] { "" });
+
+ public boolean accept(String aTableName) throws DataSetException {
+ return TABLES.contains(aTableName);
+ }
+}
--- /dev/null
+org.wamblee.support.persistence.hibernate.HibernateJpaCustomizer
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.hibernate;
+
+import org.wamblee.support.persistence.DatabaseUtilsTestBase;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class DatabaseUtilsTest extends DatabaseUtilsTestBase {
+ // Empty, all tests inherited
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.hibernate;
+
+import org.wamblee.support.persistence.MyEntityExampleTestBase;
+
+/**
+ * This class shows an example of how to test an entity using jpa.
+ */
+public class MyEntityExampleTest extends MyEntityExampleTestBase {
+ // Empty, all tests are inherited
+}
--- /dev/null
+package org.wamblee.support.persistence.hibernate;
+
+import org.wamblee.support.persistence.TransactionProxyFactoryTestBase;
+
+public class TransactionProxyFactoryTest extends
+ TransactionProxyFactoryTestBase {
+
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <parent>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-utils</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-jpatest-toplink-essentials</artifactId>
+ <packaging>jar</packaging>
+ <name>/test/toplinkessentials</name>
+ <url>http://wamblee.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.wamblee</groupId>
+ <artifactId>wamblee-test-enterprise</artifactId>
+ <version>0.2.4-SNAPSHOT</version>
+ <type>test-jar</type>
+ </dependency>
+
+ <dependency>
+ <groupId>org.dbunit</groupId>
+ <artifactId>dbunit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>toplink.essentials</groupId>
+ <artifactId>toplink-essentials</artifactId>
+ </dependency>
+
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>javaee</id>
+ <name>Java EE repo at SUN</name>
+ <url>http://download.java.net/maven/1</url>
+ <layout>legacy</layout>
+ </repository>
+
+ </repositories>
+
+</project>
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.toplink;
+
+import java.io.File;
+import java.util.Map;
+
+import org.dbunit.dataset.filter.ITableFilterSimple;
+import org.wamblee.io.FileSystemUtils;
+import org.wamblee.support.persistence.JpaCustomizer;
+import org.wamblee.support.persistence.PersistenceUnitDescription;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class ToplinkJpaCustomizer implements JpaCustomizer {
+ /**
+ * Creates a new ToplinkJpaCustomizer object.
+ */
+ public ToplinkJpaCustomizer() {
+ // Empty
+ }
+
+ @Override
+ public void customize(PersistenceUnitDescription aPersistenceUnit,
+ Map<String, String> aJpaProperties) {
+
+ // Custom datasource properties.
+ aJpaProperties.put("toplink.jdbc.url", aJpaProperties.get("javax.persistence.jdbc.url"));
+ aJpaProperties.put("toplink.jdbc.user", aJpaProperties.get("javax.persistence.jdbc.user"));
+ aJpaProperties.put("toplink.jdbc.password", aJpaProperties.get("javax.persistence.jdbc.password"));
+
+ // DDL generation for toplink
+ aJpaProperties.put("toplink.ddl-generation", "create-tables");
+
+ // DDL generation
+ FileSystemUtils.createDir(new File("target/sql"));
+ aJpaProperties.put("toplink.create-ddl-jdbc-file-name", "target/sql/create-schema.sql");
+ aJpaProperties.put("toplink.drop-ddl-jdbc-file-name", "target/sql/drop-schema.sql");
+ }
+
+ @Override
+ public ITableFilterSimple getJpaTables() {
+ return new ToplinkTables();
+ }
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.toplink;
+
+import org.dbunit.dataset.DataSetException;
+import org.dbunit.dataset.filter.ITableFilterSimple;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Toplink-specific tables.
+ */
+public class ToplinkTables implements ITableFilterSimple {
+ private static final List<String> TABLES = Arrays
+ .asList(new String[] { "SEQUENCE" });
+
+ public boolean accept(String aTableName) throws DataSetException {
+ return TABLES.contains(aTableName);
+ }
+}
--- /dev/null
+org.wamblee.support.persistence.toplink.ToplinkJpaCustomizer
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.toplink;
+
+import org.wamblee.support.persistence.DatabaseUtilsTestBase;
+
+/**
+ *
+ * @author $author$
+ * @version $Revision$
+ */
+public class DatabaseUtilsTest extends DatabaseUtilsTestBase {
+ // Empty, all tests inherited
+}
--- /dev/null
+/*
+ * Copyright 2005-2010 the original author or authors.
+ *
+ * Licensed 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.
+ */
+package org.wamblee.support.persistence.toplink;
+
+import org.wamblee.support.persistence.MyEntityExampleTestBase;
+
+/**
+ * This class shows an example of how to test an entity using jpa.
+ */
+public class MyEntityExampleTest extends MyEntityExampleTestBase {
+ // Empty, all tests are inherited
+}