This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch jpa3.2
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/jpa3.2 by this push:
new 02dc58dcee Add twi tests for Hibernate 6 and 7 with JPA 3.2
02dc58dcee is described below
commit 02dc58dcee033b9af86760bf7956da1792f20337
Author: Richard Zowalla <[email protected]>
AuthorDate: Thu Jul 17 10:47:32 2025 +0200
Add twi tests for Hibernate 6 and 7 with JPA 3.2
---
.../arquillian/tests/jpa32/Hibernate6Test.java | 95 +++++++++++++++++++++
.../arquillian/tests/jpa32/Hibernate7Test.java | 96 ++++++++++++++++++++++
.../src/test/resources/hibernate6-pom.xml | 58 +++++++++++++
.../src/test/resources/hibernate7-pom.xml | 58 +++++++++++++
4 files changed, 307 insertions(+)
diff --git
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate6Test.java
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate6Test.java
new file mode 100644
index 0000000000..976c5f8d94
--- /dev/null
+++
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate6Test.java
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.arquillian.tests.jpa32;
+
+import jakarta.persistence.EntityManagerFactory;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.ResolutionException;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class Hibernate6Test {
+
+ @Deployment
+ public static WebArchive war() {
+ File[] hibernate;
+ try { // try offline first since it is generally faster
+ hibernate = Maven.configureResolver()
+ .workOffline()
+ .loadPomFromClassLoaderResource("hibernate6-pom.xml")
+
.importCompileAndRuntimeDependencies().resolve().withTransitivity()
+ .asFile();
+ } catch (ResolutionException re) { // try on central
+ hibernate = Maven.resolver()
+ .loadPomFromClassLoaderResource("hibernate6-pom.xml")
+
.importCompileAndRuntimeDependencies().resolve().withTransitivity()
+ .asFile();
+ }
+
+ return ShrinkWrap.create(WebArchive.class, "hibernate-app.war")
+ .addAsWebInfResource(new StringAsset("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<persistence version=\"3.0\"\n" +
+ " xmlns=\"http://java.sun.com/xml/ns/persistence\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ "
xsi:schemaLocation=\"ttps://jakarta.ee/xml/ns/persistence
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd\">\n" +
+ " <persistence-unit name=\"hibernate\">\n" +
+ "
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>\n" +
+ "
<exclude-unlisted-classes>true</exclude-unlisted-classes>\n" +
+ " <properties>\n" +
+ " <property name=\"hibernate.hbm2ddl.auto\"
value=\"create-drop\" />\n" +
+ " </properties>\n" +
+ " </persistence-unit>\n" +
+ "</persistence>"),
ArchivePaths.create("persistence.xml"))
+ .addAsLibraries(hibernate)
+
.addAsLibraries(JarLocation.jarLocation(ResolutionException.class))
+
.addAsLibraries(JarLocation.jarLocation(org.jboss.shrinkwrap.resolver.api.maven.filter.MavenResolutionFilter.class));
+ }
+
+ @Test // using an internal lookup because in tomee embedded new
InitialContext() is not guaranteed
+ public void checkEmIsHibernateOne() throws Exception {
+ AppInfo info = null;
+ for (final AppInfo app :
SystemInstance.get().getComponent(Assembler.class).getDeployedApplications()) {
+ if (app.appId.endsWith("hibernate-app")) {
+ info = app;
+ break;
+ }
+ }
+
+ assertNotNull(info);
+ final EntityManagerFactory emf = (EntityManagerFactory)
+ SystemInstance.get().getComponent(ContainerSystem.class)
+
.getJNDIContext().lookup(Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT +
info.persistenceUnits.iterator().next().id);
+ assertTrue(((ReloadableEntityManagerFactory)
emf).getDelegate().getClass().getName().startsWith("org.hibernate."));
+ }
+}
diff --git
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate7Test.java
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate7Test.java
new file mode 100644
index 0000000000..c1597d9766
--- /dev/null
+++
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/jpa32/Hibernate7Test.java
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.arquillian.tests.jpa32;
+
+import jakarta.persistence.EntityManagerFactory;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ReloadableEntityManagerFactory;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.spi.ContainerSystem;
+import org.apache.ziplock.JarLocation;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.jboss.shrinkwrap.resolver.api.ResolutionException;
+import org.jboss.shrinkwrap.resolver.api.maven.Maven;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Arquillian.class)
+public class Hibernate7Test {
+
+ @Deployment
+ public static WebArchive war() {
+ File[] hibernate;
+ try { // try offline first since it is generally faster
+ hibernate = Maven.configureResolver()
+ .workOffline()
+ .loadPomFromClassLoaderResource("hibernate7-pom.xml")
+
.importCompileAndRuntimeDependencies().resolve().withTransitivity()
+ .asFile();
+ } catch (ResolutionException re) { // try on central
+ hibernate = Maven.resolver()
+ .loadPomFromClassLoaderResource("hibernate7-pom.xml")
+
.importCompileAndRuntimeDependencies().resolve().withTransitivity()
+ .asFile();
+ }
+
+ return ShrinkWrap.create(WebArchive.class, "hibernate-app.war")
+ .addAsWebInfResource(new StringAsset("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
+ "<persistence version=\"3.0\"\n" +
+ " xmlns=\"http://java.sun.com/xml/ns/persistence\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ "
xsi:schemaLocation=\"ttps://jakarta.ee/xml/ns/persistence
https://jakarta.ee/xml/ns/persistence/persistence_3_0.xsd\">\n" +
+ " <persistence-unit name=\"hibernate\">\n" +
+ "
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>\n" +
+ "
<exclude-unlisted-classes>true</exclude-unlisted-classes>\n" +
+ " <properties>\n" +
+ " <property name=\"hibernate.hbm2ddl.auto\"
value=\"create-drop\" />\n" +
+ " </properties>\n" +
+ " </persistence-unit>\n" +
+ "</persistence>"),
ArchivePaths.create("persistence.xml"))
+ .addAsLibraries(hibernate)
+
.addAsLibraries(JarLocation.jarLocation(ResolutionException.class))
+
.addAsLibraries(JarLocation.jarLocation(org.jboss.shrinkwrap.resolver.api.maven.filter.MavenResolutionFilter.class));
+ }
+
+ @Test // using an internal lookup because in tomee embedded new
InitialContext() is not guaranteed
+ public void checkEmIsHibernateOne() throws Exception {
+ AppInfo info = null;
+ for (final AppInfo app :
SystemInstance.get().getComponent(Assembler.class).getDeployedApplications()) {
+ if (app.appId.endsWith("hibernate-app")) {
+ info = app;
+ break;
+ }
+ }
+
+ assertNotNull(info);
+ final EntityManagerFactory emf = (EntityManagerFactory)
+ SystemInstance.get().getComponent(ContainerSystem.class)
+
.getJNDIContext().lookup(Assembler.PERSISTENCE_UNIT_NAMING_CONTEXT +
info.persistenceUnits.iterator().next().id);
+ assertTrue(((ReloadableEntityManagerFactory)
emf).getDelegate().getClass().getName().startsWith("org.hibernate."));
+ }
+}
diff --git
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate6-pom.xml
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate6-pom.xml
new file mode 100644
index 0000000000..fd216811da
--- /dev/null
+++
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate6-pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openejb.arquillian.tests</groupId>
+ <version>1.0.0</version>
+ <artifactId>hibernate-deps</artifactId>
+
+ <properties>
+ <version.hibernate.orm>6.6.21.Final</version.hibernate.orm>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.orm</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version.hibernate.orm}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.persistence</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.transaction</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.inject</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate7-pom.xml
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate7-pom.xml
new file mode 100644
index 0000000000..33089812d6
--- /dev/null
+++
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/resources/hibernate7-pom.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+<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/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.openejb.arquillian.tests</groupId>
+ <version>1.0.0</version>
+ <artifactId>hibernate-deps</artifactId>
+
+ <properties>
+ <version.hibernate.orm>7.0.6.Final</version.hibernate.orm>
+ </properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.orm</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version.hibernate.orm}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>jakarta.persistence</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.transaction</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.activation</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.xml.bind</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>jakarta.inject</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ </dependencies>
+</project>