Skip to content

Commit

Permalink
Maven build: H2 database profile added to execute tests against H2
Browse files Browse the repository at this point in the history
Database default storage (persistent) specified in db.url property is ~/h2/ecltests directory.
Not all tests passing now.
  • Loading branch information
rfelcman authored and lukasj committed Dec 20, 2023
1 parent 1ef011f commit e758900
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<junit.bug.version>${junit.version}</junit.bug.version>

<derby.bug.version>${derby.version}</derby.bug.version>
<h2.bug.version>2.2.224</h2.bug.version>
<h2.bug.version>${h2.version}</h2.bug.version>
<mssql.bug.version>${mssql.version}</mssql.bug.version>
<mysql.bug.version>${mysql.version}</mysql.bug.version>
<oracle.jdbc.bug.version>${oracle.jdbc.version}</oracle.jdbc.bug.version>
Expand Down
28 changes: 28 additions & 0 deletions etc/el-test.h2.properties
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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<String> execStatements(AbstractSession session, Vector<ArrayRecord> records) {
List<String> failures = new ArrayList<>();
for (ArrayRecord ar : records) {
Expand Down
19 changes: 19 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<installation.checksum.md5>56e2dd6f54e65603ada5659a06ad782b</installation.checksum.md5>

<!--Test DB property file names-->
<test.h2.properties.file>el-test.h2.properties</test.h2.properties.file>
<test.mysql.properties.file>el-test.mysql.properties</test.mysql.properties.file>
<test.mariadb.properties.file>el-test.mariadb.properties</test.mariadb.properties.file>
<test.oracle.properties.file>el-test.oracle.properties</test.oracle.properties.file>
Expand Down Expand Up @@ -225,6 +226,7 @@
<commonj.sdo.version>2.1.1</commonj.sdo.version>
<derby.version>10.17.1.0</derby.version>
<db2.version>11.5.8.0</db2.version>
<h2.version>2.2.224</h2.version>
<!-- CQ #21134, 21135, 21136, 21137 -->
<exam.version>4.13.4</exam.version>
<hamcrest.version>1.3</hamcrest.version>
Expand Down Expand Up @@ -982,6 +984,11 @@
<version>${springframework.version}</version>
</dependency>
<!--JDBC drivers-->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
Expand Down Expand Up @@ -1856,6 +1863,18 @@
<test.skip.in-memory.db>true</test.skip.in-memory.db>
</properties>
</profile>
<profile>
<id>h2</id>
<properties>
<test.properties.file>${user.home}/${test.h2.properties.file}</test.properties.file>
<test.properties.fileName>${test.h2.properties.file}</test.properties.fileName>
<!--Used by sql-maven-plugin-->
<db.driver.groupId>com.h2database</db.driver.groupId>
<db.driver.artifactId>h2</db.driver.artifactId>
<db.driver.version>${h2.version}</db.driver.version>
<test.skip.in-memory.db>true</test.skip.in-memory.db>
</properties>
</profile>
<profile>
<id>mysql</id>
<properties>
Expand Down

0 comments on commit e758900

Please sign in to comment.