From e758900fb60b55a9125b744e0183eeb464dc1758 Mon Sep 17 00:00:00 2001 From: Radek Felcman Date: Thu, 14 Dec 2023 12:10:22 +0100 Subject: [PATCH] Maven build: H2 database profile added to execute tests against H2 Database default storage (persistent) specified in db.url property is ~/h2/ecltests directory. Not all tests passing now. --- .../resources/archetype-resources/pom.xml | 2 +- etc/el-test.h2.properties | 28 +++++++++++++++++++ .../tests/ClearDatabaseSchemaTest.java | 8 +++++- pom.xml | 19 +++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 etc/el-test.h2.properties diff --git a/etc/archetypes/bug_test_case/jpa/src/main/resources/archetype-resources/pom.xml b/etc/archetypes/bug_test_case/jpa/src/main/resources/archetype-resources/pom.xml index 4c7cc101cf2..3fdfd107fe2 100644 --- a/etc/archetypes/bug_test_case/jpa/src/main/resources/archetype-resources/pom.xml +++ b/etc/archetypes/bug_test_case/jpa/src/main/resources/archetype-resources/pom.xml @@ -35,7 +35,7 @@ ${junit.version} ${derby.version} - 2.2.224 + ${h2.version} ${mssql.version} ${mysql.version} ${oracle.jdbc.version} diff --git a/etc/el-test.h2.properties b/etc/el-test.h2.properties new file mode 100644 index 00000000000..cd8a24bb19a --- /dev/null +++ b/etc/el-test.h2.properties @@ -0,0 +1,28 @@ +# +# Copyright (c) 2023 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0 which is available at +# http://www.eclipse.org/legal/epl-2.0, +# or the Eclipse Distribution License v. 1.0 which is available at +# http://www.eclipse.org/org/documents/edl-v10.php. +# +# SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause +# + +# DB Connection properties +db.driver=org.h2.Driver +db.xa.driver=org.h2.Driver +db.url=jdbc:h2:~/h2/ecltests +db.user= +db.pwd= +db.platform=org.eclipse.persistence.platform.database.H2Platform +db.properties=url=jdbc:h2:~/h2/ecltests +#db.ddl.debug=true +datasource.type=java.sql.Driver +#datasource.type=javax.sql.XADataSource +datasource.transactionsupport=LOCAL_TRANSACTION +#datasource.transactionsupport=XA_TRANSACTION + +# Logging option for debugging +logging.level=info diff --git a/foundation/org.eclipse.persistence.core.test.framework/src/main/java/org/eclipse/persistence/testing/tests/ClearDatabaseSchemaTest.java b/foundation/org.eclipse.persistence.core.test.framework/src/main/java/org/eclipse/persistence/testing/tests/ClearDatabaseSchemaTest.java index cf0c3edb4b6..88d5c170960 100644 --- a/foundation/org.eclipse.persistence.core.test.framework/src/main/java/org/eclipse/persistence/testing/tests/ClearDatabaseSchemaTest.java +++ b/foundation/org.eclipse.persistence.core.test.framework/src/main/java/org/eclipse/persistence/testing/tests/ClearDatabaseSchemaTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2023 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at @@ -56,6 +56,8 @@ public void test() { resetDerby(session); } else if (platform.isSQLServer()) { resetMSSQL(session); + } else if (platform.isH2()) { + resetH2(session); } else if (platform.isHSQL()) { resetHsql(session); } else if (platform.isPostgreSQL()) { @@ -194,6 +196,10 @@ private void resetPostgres(AbstractSession session) { assertTrue(toRetry + " statements failed", toRetry.isEmpty()); } + private void resetH2(AbstractSession session) { + session.executeNonSelectingSQL("DROP ALL OBJECTS;"); + } + private List execStatements(AbstractSession session, Vector records) { List failures = new ArrayList<>(); for (ArrayRecord ar : records) { diff --git a/pom.xml b/pom.xml index f3fb3c04a3c..d7cf3de20f8 100644 --- a/pom.xml +++ b/pom.xml @@ -139,6 +139,7 @@ 56e2dd6f54e65603ada5659a06ad782b + el-test.h2.properties el-test.mysql.properties el-test.mariadb.properties el-test.oracle.properties @@ -225,6 +226,7 @@ 2.1.1 10.17.1.0 11.5.8.0 + 2.2.224 4.13.4 1.3 @@ -982,6 +984,11 @@ ${springframework.version} + + com.h2database + h2 + ${h2.version} + com.mysql mysql-connector-j @@ -1856,6 +1863,18 @@ true + + h2 + + ${user.home}/${test.h2.properties.file} + ${test.h2.properties.file} + + com.h2database + h2 + ${h2.version} + true + + mysql