From 96c648bdc078084bca791937536c521c03b25dc3 Mon Sep 17 00:00:00 2001 From: Luis Majano Date: Tue, 7 May 2024 16:23:51 +0200 Subject: [PATCH] lots of improvements but still way to go --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .gitignore | 3 +- CONTRIBUTING.md | 2 +- box.json | 86 ++++++++++--------- readme.md | 2 +- src/main/bx/interceptors/AdobeServerScope.bx | 2 +- src/main/bx/interceptors/LuceeServerScope.bx | 2 +- .../modules/compat/IntegrationTest.java | 75 ++++++++++++++++ .../compat/bifs/cache/BaseCacheTest.java | 2 +- .../cache/CacheGetMetadataReportTest.java | 2 +- .../bifs/cache/CacheGetMetadataTest.java | 2 +- .../{ => modules}/compat/components/.gitkeep | 0 12 files changed, 129 insertions(+), 51 deletions(-) create mode 100644 src/test/java/ortus/boxlang/modules/compat/IntegrationTest.java rename src/test/java/ortus/boxlang/{ => modules}/compat/bifs/cache/BaseCacheTest.java (97%) rename src/test/java/ortus/boxlang/{ => modules}/compat/bifs/cache/CacheGetMetadataReportTest.java (97%) rename src/test/java/ortus/boxlang/{ => modules}/compat/bifs/cache/CacheGetMetadataTest.java (98%) rename src/test/java/ortus/boxlang/{ => modules}/compat/components/.gitkeep (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 879639e..3aff392 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -11,7 +11,7 @@ IMPORTANT: Please review the [CONTRIBUTING.md](../CONTRIBUTING.md) file for deta All PRs must have an accompanied Jira issue. Please make sure you created it and linked it here. BoxLang Jira: https://ortussolutions.atlassian.net/browse/BL/issues -Module Issues: https://github.com/boxlang-modules/bx-compat/issues +Module Issues: https://github.com/ortus-boxlang/bx-compat/issues ## Type of change diff --git a/.gitignore b/.gitignore index 1e2684b..a8f0a71 100644 --- a/.gitignore +++ b/.gitignore @@ -5,12 +5,11 @@ build/** ### IntelliJ IDEA ### .idea/ - - ### Mac OS ### .DS_Store ### BOXLANG ### +grapher/** /libs/ src/test/resources/libs/ grapher/* diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 56c06d1..abccf8b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,7 @@ This project is open source, and as such, the maintainers give their free time t BoxLang tracks its issues in Jira and each module track it's own issues in its repo. - BoxLang JIra : https://ortussolutions.atlassian.net/browse/BL/issues -- Module Issues: https://github.com/boxlang-modules/bx-compat/issues +- Module Issues: https://github.com/ortus-boxlang/bx-compat/issues If you file a bug report, your issue should contain a title, a clear description of the issue, a way to replicate the issue, and any support files that we might need to replicate your issue. The goal of a bug report is to make it easy for yourself - and others - to replicate the bug and develop a fix for it. All issues that do not contain a way to replicate will not be addressed. diff --git a/box.json b/box.json index f40c420..be37a75 100644 --- a/box.json +++ b/box.json @@ -1,46 +1,50 @@ { - "name":"BoxLang Compat Module", - "version":"@build.version@+@build.number@", - "location" : "https://downloads.ortussolutions.com/ortussolutions/boxlang-modules/bx-compat/@build.version@/bx-compat-@build.version@.zip", - "author":"Ortus Solutions", - "homepage":"https://github.com/boxlang-modules/bx-compat", - "documentation":"https://github.com/boxlang-modules/bx-compat", - "repository":{ - "type":"git", - "URL":"https://github.com/boxlang-modules/bx-compat" - }, - "bugs":"https://github.com/boxlang-modules/bx-compat/issues", - "slug":"bx-compat", - "shortDescription":"Module template for BoxLang modules", - "type":"boxlang-modules", - "keywords":[ - "boxlang" - ], - "private":false, - "license":[ - { - "type":"Apache-2.0", - "URL":"https://www.apache.org/licenses/LICENSE-2.0" - } - ], - "devDependencies" :{ - "commandbox-cfformat":"*", - "commandbox-docbox":"*", - "commandbox-dotenv":"*", - "commandbox-cfconfig":"*", + "name": "BoxLang Compat Module", + "version": "@build.version@+@build.number@", + "location": "https://downloads.ortussolutions.com/ortussolutions/boxlang-modules/bx-compat/@build.version@/bx-compat-@build.version@.zip", + "author": "Ortus Solutions", + "homepage": "https://github.com/ortus-boxlang/bx-compat", + "documentation": "https://github.com/ortus-boxlang/bx-compat", + "repository": { + "type": "git", + "URL": "https://github.com/ortus-boxlang/bx-compat" + }, + "bugs": "https://github.com/ortus-boxlang/bx-compat/issues", + "slug": "bx-compat", + "shortDescription": "Module template for BoxLang modules", + "type": "boxlang-modules", + "keywords": [ + "boxlang" + ], + "private": false, + "license": [ + { + "type": "Apache-2.0", + "URL": "https://www.apache.org/licenses/LICENSE-2.0" + } + ], + "devDependencies": { + "commandbox-cfformat": "*", + "commandbox-docbox": "*", + "commandbox-dotenv": "*", + "commandbox-cfconfig": "*", "testbox": "*" }, - "ignore": [ - "**/.*", - "settings.gradle", - "gradlew.bat", - "gradlew", - "build.gradle", - "/src/**", - "gradle/**" - ], - "scripts":{ + "ignore": [ + "**/.*", + "settings.gradle", + "gradlew.bat", + "gradlew", + "build.gradle", + "/src/**", + "gradle/**" + ], + "scripts": { "setupTemplate": "task run taskFile=src/build/SetupTemplate.cfc", - "onRelease":"publish" - } + "onRelease": "publish" + }, + "boxlang": { + "moduleName": "compat", + "minimumVersion": "1.0.0" + } } diff --git a/readme.md b/readme.md index bce4621..45f11d8 100644 --- a/readme.md +++ b/readme.md @@ -20,7 +20,7 @@ This module will allow your ColdFusion (CFML) applications under Adobe or Lucee to run under BoxLang. This module will provide the necessary compatibility layer to run your applications under BoxLang. -If there are any issues, please report them to the [BoxLang JIRA](https://ortussolutions.atlassian.net/browse/BL/issues) or the [Module Issues](https://github.com/boxlang-modules/bx-compat/issues) repository. +If there are any issues, please report them to the [BoxLang JIRA](https://ortussolutions.atlassian.net/browse/BL/issues) or the [Module Issues](https://github.com/ortus-boxlang/bx-compat/issues) repository. ## Ortus Sponsors diff --git a/src/main/bx/interceptors/AdobeServerScope.bx b/src/main/bx/interceptors/AdobeServerScope.bx index 9a27609..f00f1ce 100644 --- a/src/main/bx/interceptors/AdobeServerScope.bx +++ b/src/main/bx/interceptors/AdobeServerScope.bx @@ -22,7 +22,7 @@ import java:ortus.boxlang.runtime.scopes.Key; /** * Adds collaborations to the server scope as per the Adobe server */ -component{ +class{ function configure(){ // Nothing to do here diff --git a/src/main/bx/interceptors/LuceeServerScope.bx b/src/main/bx/interceptors/LuceeServerScope.bx index d1f6dd7..53ce4b2 100644 --- a/src/main/bx/interceptors/LuceeServerScope.bx +++ b/src/main/bx/interceptors/LuceeServerScope.bx @@ -22,7 +22,7 @@ import java:ortus.boxlang.runtime.scopes.Key; /** * Adds collaborations to the server scope as per the lucee server */ -component{ +class{ function configure(){ // Nothing to do here diff --git a/src/test/java/ortus/boxlang/modules/compat/IntegrationTest.java b/src/test/java/ortus/boxlang/modules/compat/IntegrationTest.java new file mode 100644 index 0000000..09fdec1 --- /dev/null +++ b/src/test/java/ortus/boxlang/modules/compat/IntegrationTest.java @@ -0,0 +1,75 @@ +package ortus.boxlang.modules.compat; + +import static com.google.common.truth.Truth.assertThat; + +import java.nio.file.Paths; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import ortus.boxlang.runtime.BoxRuntime; +import ortus.boxlang.runtime.context.IBoxContext; +import ortus.boxlang.runtime.context.ScriptingRequestBoxContext; +import ortus.boxlang.runtime.modules.ModuleRecord; +import ortus.boxlang.runtime.scopes.IScope; +import ortus.boxlang.runtime.scopes.Key; +import ortus.boxlang.runtime.scopes.VariablesScope; +import ortus.boxlang.runtime.services.ModuleService; + +/** + * This loads the module and runs an integration test on the module. + */ +public class IntegrationTest { + + @DisplayName( "Test the module loads in BoxLang" ) + @Test + public void testModuleLoads() { + // Given + Key moduleName = new Key( "compat" ); + String physicalPath = Paths.get( "./build/module" ).toAbsolutePath().toString(); + ModuleRecord moduleRecord = new ModuleRecord( physicalPath ); + IBoxContext context = new ScriptingRequestBoxContext(); + BoxRuntime runtime = BoxRuntime.getInstance( true ); + ModuleService moduleService = runtime.getModuleService(); + IScope variables = context.getScopeNearby( VariablesScope.name ); + + // When + moduleRecord + .loadDescriptor( context ) + .register( context ) + .activate( context ); + + moduleService.getRegistry().put( moduleName, moduleRecord ); + + // Then + assertThat( moduleService.getRegistry().containsKey( moduleName ) ).isTrue(); + + // Verify things got registered + // assertThat( datasourceService.hasDriver( Key.of( "derby" ) ) ).isTrue(); + + // Register a named datasource + // runtime.getConfiguration().runtime.datasources.put( + // Key.of( "derby" ), + // DatasourceConfig.fromStruct( Struct.of( + // "name", "derby", + // "driver", "derby", + // "properties", Struct.of( + // "database", "testDB", + // "protocol", "memory" + // ) + // ) ) + // ); + + // @formatter:off + runtime.executeSource( + """ + // Testing code here + """, + context + ); + // @formatter:on + + // Asserts here + + } +} diff --git a/src/test/java/ortus/boxlang/compat/bifs/cache/BaseCacheTest.java b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/BaseCacheTest.java similarity index 97% rename from src/test/java/ortus/boxlang/compat/bifs/cache/BaseCacheTest.java rename to src/test/java/ortus/boxlang/modules/compat/bifs/cache/BaseCacheTest.java index 65d5d56..967bf1c 100644 --- a/src/test/java/ortus/boxlang/compat/bifs/cache/BaseCacheTest.java +++ b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/BaseCacheTest.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package ortus.boxlang.compat.bifs.cache; +package ortus.boxlang.modules.compat.bifs.cache; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; diff --git a/src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataReportTest.java b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataReportTest.java similarity index 97% rename from src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataReportTest.java rename to src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataReportTest.java index 277dca9..b171fca 100644 --- a/src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataReportTest.java +++ b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataReportTest.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package ortus.boxlang.compat.bifs.cache; +package ortus.boxlang.modules.compat.bifs.cache; import static com.google.common.truth.Truth.assertThat; diff --git a/src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataTest.java b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataTest.java similarity index 98% rename from src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataTest.java rename to src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataTest.java index ee735c3..1c74dde 100644 --- a/src/test/java/ortus/boxlang/compat/bifs/cache/CacheGetMetadataTest.java +++ b/src/test/java/ortus/boxlang/modules/compat/bifs/cache/CacheGetMetadataTest.java @@ -15,7 +15,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package ortus.boxlang.compat.bifs.cache; +package ortus.boxlang.modules.compat.bifs.cache; import static com.google.common.truth.Truth.assertThat; diff --git a/src/test/java/ortus/boxlang/compat/components/.gitkeep b/src/test/java/ortus/boxlang/modules/compat/components/.gitkeep similarity index 100% rename from src/test/java/ortus/boxlang/compat/components/.gitkeep rename to src/test/java/ortus/boxlang/modules/compat/components/.gitkeep