(no commit message)
authorErik Brakkee <erik@brakkee.org>
Wed, 12 May 2010 16:39:11 +0000 (16:39 +0000)
committerErik Brakkee <erik@brakkee.org>
Wed, 12 May 2010 16:39:11 +0000 (16:39 +0000)
20 files changed:
test/README.txt
test/jpatest-eclipselink/pom.xml [new file with mode: 0644]
test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkJpaCustomizer.java [new file with mode: 0644]
test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkTables.java [new file with mode: 0644]
test/jpatest-eclipselink/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer [new file with mode: 0644]
test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java [new file with mode: 0644]
test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java [new file with mode: 0644]
test/jpatest-hibernate/pom.xml [new file with mode: 0644]
test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java [new file with mode: 0644]
test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java [new file with mode: 0644]
test/jpatest-hibernate/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer [new file with mode: 0644]
test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java [new file with mode: 0644]
test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java [new file with mode: 0644]
test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/TransactionProxyFactoryTest.java [new file with mode: 0644]
test/jpatest-toplink-essentials/pom.xml [new file with mode: 0644]
test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java [new file with mode: 0644]
test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java [new file with mode: 0644]
test/jpatest-toplink-essentials/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer [new file with mode: 0644]
test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java [new file with mode: 0644]
test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java [new file with mode: 0644]

index 48a58473c7e0736675f42551f310ecf6f1a0ee99..6879926d8336b7555bc3e809f94bca980d3fef96 100644 (file)
@@ -2,3 +2,6 @@
 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. 
diff --git a/test/jpatest-eclipselink/pom.xml b/test/jpatest-eclipselink/pom.xml
new file mode 100644 (file)
index 0000000..d7de88f
--- /dev/null
@@ -0,0 +1,62 @@
+<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&amp;nf=1&amp;file=/rt/eclipselink/maven.repo</url>
+               </repository>
+
+       </repositories>
+
+
+</project>
diff --git a/test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkJpaCustomizer.java b/test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkJpaCustomizer.java
new file mode 100644 (file)
index 0000000..1679942
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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();
+    }
+}
diff --git a/test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkTables.java b/test/jpatest-eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/EclipselinkTables.java
new file mode 100644 (file)
index 0000000..29872d0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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);
+    }
+}
diff --git a/test/jpatest-eclipselink/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer b/test/jpatest-eclipselink/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer
new file mode 100644 (file)
index 0000000..35638de
--- /dev/null
@@ -0,0 +1 @@
+org.wamblee.support.persistence.eclipselink.EclipselinkJpaCustomizer
diff --git a/test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java b/test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/DatabaseUtilsTest.java
new file mode 100644 (file)
index 0000000..3fbf2f2
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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
+}
diff --git a/test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java b/test/jpatest-eclipselink/src/test/java/org/wamblee/support/persistence/eclipselink/MyEntityExampleTest.java
new file mode 100644 (file)
index 0000000..e95afb8
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
+}
diff --git a/test/jpatest-hibernate/pom.xml b/test/jpatest-hibernate/pom.xml
new file mode 100644 (file)
index 0000000..a13fe25
--- /dev/null
@@ -0,0 +1,48 @@
+<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>
diff --git a/test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java b/test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateJpaCustomizer.java
new file mode 100644 (file)
index 0000000..71bbb18
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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();
+    }
+}
diff --git a/test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java b/test/jpatest-hibernate/src/main/java/org/wamblee/support/persistence/hibernate/HibernateTables.java
new file mode 100644 (file)
index 0000000..f58ea8e
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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);
+    }
+}
diff --git a/test/jpatest-hibernate/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer b/test/jpatest-hibernate/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer
new file mode 100644 (file)
index 0000000..d057634
--- /dev/null
@@ -0,0 +1 @@
+org.wamblee.support.persistence.hibernate.HibernateJpaCustomizer
diff --git a/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java b/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/DatabaseUtilsTest.java
new file mode 100644 (file)
index 0000000..6059c95
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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
+}
diff --git a/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java b/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/MyEntityExampleTest.java
new file mode 100644 (file)
index 0000000..3ac32a5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
+}
diff --git a/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/TransactionProxyFactoryTest.java b/test/jpatest-hibernate/src/test/java/org/wamblee/support/persistence/hibernate/TransactionProxyFactoryTest.java
new file mode 100644 (file)
index 0000000..df057b5
--- /dev/null
@@ -0,0 +1,8 @@
+package org.wamblee.support.persistence.hibernate;
+
+import org.wamblee.support.persistence.TransactionProxyFactoryTestBase;
+
+public class TransactionProxyFactoryTest extends
+    TransactionProxyFactoryTestBase {
+
+}
diff --git a/test/jpatest-toplink-essentials/pom.xml b/test/jpatest-toplink-essentials/pom.xml
new file mode 100644 (file)
index 0000000..df6c33a
--- /dev/null
@@ -0,0 +1,58 @@
+<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>
diff --git a/test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java b/test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkJpaCustomizer.java
new file mode 100644 (file)
index 0000000..1b3808f
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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();
+    }
+}
diff --git a/test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java b/test/jpatest-toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/ToplinkTables.java
new file mode 100644 (file)
index 0000000..4a99d7d
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * 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);
+    }
+}
diff --git a/test/jpatest-toplink-essentials/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer b/test/jpatest-toplink-essentials/src/main/resources/META-INF/services/org.wamblee.support.persistence.JpaCustomizer
new file mode 100644 (file)
index 0000000..82d1265
--- /dev/null
@@ -0,0 +1 @@
+org.wamblee.support.persistence.toplink.ToplinkJpaCustomizer
diff --git a/test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java b/test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/DatabaseUtilsTest.java
new file mode 100644 (file)
index 0000000..c45ea93
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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
+}
diff --git a/test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java b/test/jpatest-toplink-essentials/src/test/java/org/wamblee/support/persistence/toplink/MyEntityExampleTest.java
new file mode 100644 (file)
index 0000000..8d60e75
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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
+}