Skip to content

Tests - Drop OLD committed bx-derby; install bx-derby upon build - #360

Open
michaelborn wants to merge 24 commits into
developmentfrom
patch/jdbc-tests-derby-switch-to-bx-derby
Open

Tests - Drop OLD committed bx-derby; install bx-derby upon build#360
michaelborn wants to merge 24 commits into
developmentfrom
patch/jdbc-tests-derby-switch-to-bx-derby

Conversation

@michaelborn

@michaelborn michaelborn commented Oct 12, 2025

Copy link
Copy Markdown
Contributor

Description

The BoxLang Core repo relies on the bx-derby module to provide a packaged version of Apache Derby for most JDBC tests. This bx-derby version has previously been committed to the repository, but this causes numerous issues:

  1. The committed bx-derby version is old and out of date
  2. We are not testing updated versions of bx-derby

Hence, this PR updates the gradle build to install bx-derby during test compilation. The bx-derby module is then loaded into the boxlang runtime via a custom function in BaseJDBCTest.java.

Note we have special treatment here for bx-derby as it is the only DB driver required to run JDBC tests. The MySQL tests, MSSQL tests, etc. all use @EnableIf() to auto-disable if the module is present; whereas the vast majority JDBC tests rely on apache derby and do not use @EnableIf().

Checklist

  • My code follows the style guidelines of this project cfformat
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes the JDBC testing infrastructure by removing an outdated committed version of the bx-derby module and implementing automatic installation during build time. The change ensures JDBC tests always use the latest version of the Derby database driver rather than a stale committed version.

Key changes:

  • Automatic installation of bx-derby module during test compilation via Gradle
  • Dynamic module loading functionality in test base class
  • Complete removal of old committed bx-derby module files

Reviewed Changes

Copilot reviewed 8 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/test/java/tools/JDBCTestUtils.java Adds utility method to check for Derby module presence
src/test/java/ortus/boxlang/runtime/bifs/global/jdbc/BaseJDBCTest.java Implements dynamic Derby module loading with fallback error handling
modules/bx-derby/* Removes all old committed Derby module files
gradle.properties Adds Derby module version configuration
CONTRIBUTING.md Updates documentation to include Derby module installation

Comment thread src/test/java/tools/JDBCTestUtils.java Outdated
Comment thread src/test/java/ortus/boxlang/runtime/bifs/global/jdbc/BaseJDBCTest.java Outdated
@bdw429s

bdw429s commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

Feedback left in Slack. Also, please resolve any co-pilot comments above which are no longer relevant.

@bdw429s

bdw429s commented Oct 20, 2025

Copy link
Copy Markdown
Contributor

The dump failure can be resolved by rebasing with dev. There are still other failures, however.

@michaelborn
michaelborn force-pushed the patch/jdbc-tests-derby-switch-to-bx-derby branch from fd213bd to 885e3b1 Compare October 21, 2025 20:09
@michaelborn

Copy link
Copy Markdown
Contributor Author

I rebased against development and dropped all custom derby logic from the build.gradle. Seeing if tests pass.

@lmajano

lmajano commented Nov 1, 2025

Copy link
Copy Markdown
Contributor

@michaelborn status on this?

@michaelborn
michaelborn force-pushed the patch/jdbc-tests-derby-switch-to-bx-derby branch from 8db85fd to a7fb428 Compare November 7, 2025 21:32
@michaelborn

Copy link
Copy Markdown
Contributor Author

Ok, I'm stuck now on the setUp() and teardown methods in BaseJDBCTest. Both these methods expect a derby database to be available:

ortus.boxlang.runtime.types.exceptions.BoxRuntimeException: Unable to create datasource connection to URL [jdbc:derby:memory:0f0ba54a-4126-4547-99d0-0638b0c4d3d0;create=true] : Failed to get driver instance for jdbcUrl=jdbc:derby:memory:0f0ba54a-4126-4547-99d0-0638b0c4d3d0;create=true
	at app//ortus.boxlang.runtime.jdbc.DataSource.<init>(DataSource.java:94)
	at app//ortus.boxlang.runtime.jdbc.DataSource.fromStruct(DataSource.java:119)
	at app//ortus.boxlang.runtime.jdbc.DataSource.fromStruct(DataSource.java:107)
	at app//tools.JDBCTestUtils.constructTestDataSource(JDBCTestUtils.java:216)
	at app//ortus.boxlang.runtime.bifs.global.jdbc.BaseJDBCTest.setUp(BaseJDBCTest.java:39)

Needs some thought on a path forward.

datasource = JDBCTestUtils.constructTestDataSource( uniqueName, setUpContext );

@michaelborn

Copy link
Copy Markdown
Contributor Author

Ready for review and merge, as long as this CI run passes with bx-derby installed.

@michaelborn

Copy link
Copy Markdown
Contributor Author

Stuck on these test failures:

🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | ortus.boxlang.runtime.types.exceptions.DatabaseException: Unable to read foreign key info
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | ortus.boxlang.runtime.types.exceptions.DatabaseException: Unable to read foreignkeys metadata
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: ortus.boxlang.runtime.types.exceptions.DatabaseException: No current connection.
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected to be true
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected to be true
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | value of: getNames().asList().onlyElement()
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected instance of: ortus.boxlang.runtime.jdbc.DataSource

@michaelborn
michaelborn force-pushed the patch/jdbc-tests-derby-switch-to-bx-derby branch from e02aed1 to 65a7fab Compare November 12, 2025 21:07
@michaelborn
michaelborn force-pushed the patch/jdbc-tests-derby-switch-to-bx-derby branch from 65a7fab to c75e5b2 Compare December 2, 2025 16:19
Comment thread src/test/bx/Scheduler.bx
// Setup Scheduler Properties
scheduler.setSchedulerName( "My-Scheduler" )
scheduler.setTimezone( "UTC" )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lmajano @michaelborn Why the removals in this file? Is this related to Derby?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to Derby, just related to the fact that the scheduler completely filled the CI log to where you couldn't find any useful test output from the junit tests.

I did get approval from Luis before doing this, see here: https://ortussolutions.slack.com/archives/C04UF3E09MH/p1762800683473899

Comment thread CONTRIBUTING.md
1. MSSQL: `box install id=bx-mssql directory=~/.boxlang/modules`
2. MySQL: `box install id=bx-mysql directory=~/.boxlang/modules`
3. Oracle: `box install id=bx-oracle directory=~/.boxlang/modules`
1. MSSQL: `box install id=bx-mssql directory=~/.boxlang/modules --nosave`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to save these?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would they save them to? We don't have a box.json file in the boxlang repo root.

There's not a strong reason to include the --nosave command, but also not a great reason to create a box.json file that we haven't yet needed, IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants