Skip to content

Commit d37299d

Browse files
committed
Boxlang compatibility
1 parent 9e6ace9 commit d37299d

11 files changed

+28
-128
lines changed

.cfconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
{}
1+
{
2+
"debuggingEnabled" : true
3+
}

.env.template

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FR_ENABLE=false
2+
FR_LICENSE_KEY=

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ build/workbench/*
3131
changelog-latest.md
3232

3333
# test environment secrets
34-
test-harness/.env
34+
test-harness/.env
35+
.env

models/SearchBuilder.cfc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1263,8 +1263,8 @@ component accessors="true" {
12631263
}
12641264

12651265
if ( !isNull( variables.sorting ) ) {
1266-
// we used a linked hashmap for sorting to maintain order
1267-
dsl[ "sort" ] = createObject( "java", "java.util.LinkedHashMap" ).init();
1266+
// we used an ordered struct so that the sort directives are in the order they were added
1267+
dsl[ "sort" ] = structNew( "ordered" );
12681268

12691269
for ( var sort in variables.sorting ) {
12701270
dsl.sort.putAll( sort );

models/io/HyperClient.cfc

+1-1
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ component accessors="true" threadSafe singleton {
503503
return structReduce(
504504
arguments.index,
505505
function( indexMap, key, value ){
506-
indexMap.put( key, value );
506+
indexMap[ key ] = value;
507507
return indexMap;
508508
},
509509
{}

models/mappings/AbstractMapping.cfc

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ component accessors="true" {
3232
}
3333

3434
function onMissingMethod( missingMethodName, missingMethodArguments ){
35-
variables.parameters[ snakeCase( missingMethodName ) ] = missingMethodArguments[ 1 ];
35+
variables.parameters[ variables.snakeCase( missingMethodName ) ] = missingMethodArguments[ 1 ];
3636
return this;
3737
}
3838

models/migrations/Manager.cfc

+1-2
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,13 @@ component {
110110
.term( "name", arguments.componentName )
111111
);
112112
} else {
113-
var formatter = createObject( "java", "java.text.SimpleDateFormat" ).init( "yyyy-MM-dd'T'HH:mm:ssXXX" );
114113
wirebox
115114
.getInstance( "Document@cbelasticsearch" )
116115
.new(
117116
index = variables.migrationsIndex,
118117
properties = {
119118
"name" : arguments.componentName,
120-
"migrationRan" : formatter.format( now() ).replace( "Z", "+00:00" )
119+
"migrationRan" : dateTimeFormat( now(), "yyyy-mm-dd'T'HH:nn:ssZZ" )
121120
}
122121
)
123122
.save( true );

models/util/Util.cfc

-47
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,6 @@ component accessors="true" singleton {
33
property name="appEnvironment" inject="box:setting:environment";
44
property name="interceptorService" inject="coldbox:InterceptorService";
55

6-
/**
7-
* Ensures a CF native struct is returned ( allowing for dot-notation )
8-
*
9-
* @memento A struct to ensure
10-
*/
11-
function ensureNativeStruct( required struct memento ){
12-
// deserialize/serialize JSON is currently the only way to to ensure deeply nested items are converted without deep recursion
13-
return deserializeJSON(
14-
serializeJSON(
15-
memento,
16-
false,
17-
listFindNoCase( "Lucee", server.coldfusion.productname ) ? "utf-8" : false
18-
)
19-
);
20-
}
21-
22-
/**
23-
* Creates a new java.util.HashMap with an optional struct to populate
24-
*
25-
* @memento a struct to populate the memento with
26-
*/
27-
function newHashMap( struct memento ){
28-
var hashMap = createObject( "java", "java.util.HashMap" ).init();
29-
30-
if ( !isNull( arguments.memento ) ) {
31-
// make sure we detach any references
32-
hashMap.putAll( ensureBooleanCasting( duplicate( arguments.memento ) ) );
33-
for ( var key in hashMap ) {
34-
if ( isNull( hashMap[ key ] ) ) continue;
35-
36-
if ( isStruct( hashMap[ key ] ) && !isInstanceOf( hashMap[ key ], "java.util.HashMap" ) ) {
37-
hashMap[ key ] = newHashMap( ensureBooleanCasting( hashMap[ key ] ) );
38-
} else if ( isArray( hashMap[ key ] ) ) {
39-
// scope this in for CF's compiler
40-
var segment = hashMap[ key ];
41-
segment.each( function( item, index ){
42-
if ( isStruct( item ) && !isInstanceOf( item, "java.util.HashMap" ) ) {
43-
hashMap[ key ][ index ] = newHashMap( ensureBooleanCasting( item ) );
44-
}
45-
} );
46-
}
47-
}
48-
}
49-
50-
return hashMap;
51-
}
52-
536
/**
547
* Workaround for Adobe 2018 metadata mutation bug with GSON: https://tracker.adobe.com/#/view/CF-4206423
558
* @deprecated As soon as the bug above is fixed

[email protected]

+14-11
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"app":{
3-
"cfengine":"boxlang@be",
3+
"cfengine":"boxlang@1.0.0-snapshot",
44
"serverHomeDirectory":".engine/boxlang"
55
},
6+
"runwar":{
7+
"console":{
8+
"appenderLayout":"JSONTemplateLayout"
9+
}
10+
},
611
"name":"cbelasticsearch-boxlang@1",
712
"force":true,
813
"openBrowser":false,
@@ -19,18 +24,16 @@
1924
"/moduleroot/cbelasticsearch":"./"
2025
}
2126
},
22-
"JVM":{
23-
"heapSize":"1024",
24-
"javaVersion":"openjdk21_jdk",
25-
"args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999"
27+
"fusionreactor":{
28+
"enable":"${FR_ENABLE:false}",
29+
"port":"8088",
30+
"licenseKey":"${FR_LICENSE_KEY}"
2631
},
27-
"cfconfig":{
28-
"file":".cfconfig.json"
29-
},
30-
"env":{
31-
"BOXLANG_DEBUG":true
32+
"JVM":{
33+
"javaVersion":"openjdk21_jdk_x64",
34+
"args":"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9999 -Dboxlang.debugMode=true"
3235
},
3336
"scripts":{
34-
"onServerInitialInstall":"install bx-mail,bx-mysql,bx-derby,bx-compat-cfml@be,bx-unsafe-evaluate,bx-esapi --noSave"
37+
"onServerInitialInstall":"install bx-compat-cfml@be,bx-esapi --noSave"
3538
}
3639
}

test-harness/tests/specs/unit/SearchBuilderTest.cfc

+2-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ component extends="coldbox.system.testing.BaseTestCase" {
361361
it( "Tests the sort() method by providing an array", function(){
362362
var searchBuilder = variables.model.new( variables.testIndexName, "testdocs" );
363363

364-
var sort = [ { "lastName" : { "order" : "asc" } } ];
364+
var sort = [ { "lastName" : { "order" : "asc" } }, { "firstName" : { "order" : "asc" } } ];
365365

366366
searchBuilder.sort( sort );
367367

@@ -373,8 +373,8 @@ component extends="coldbox.system.testing.BaseTestCase" {
373373
expect( dsl ).toHaveKey( "sort" );
374374
expect( dsl.sort ).toBeStruct();
375375
expect( dsl.sort ).toHaveKey( "lastName" );
376+
expect( dsl.sort.keyArray().last() ).toBe( "firstName" );
376377

377-
expect( getMetadata( dsl.sort ).name ).toBe( "java.util.LinkedHashMap" );
378378
} );
379379

380380
it( "Tests the sort() method by providing a simple SQL-type string", function(){

test-harness/tests/specs/unit/UtilTest.cfc

-60
Original file line numberDiff line numberDiff line change
@@ -14,66 +14,6 @@ component extends="coldbox.system.testing.BaseTestCase" {
1414

1515
function run(){
1616
describe( "Runs core util tests", function(){
17-
it( "tests ensureNativeStruct", function(){
18-
var ref = {
19-
"foo" : "bar",
20-
"baz" : { "foo" : "bar" },
21-
"numeric" : 1,
22-
"booleanArray" : [
23-
{ "foo" : true },
24-
{ "foo" : false },
25-
{ "foo" : "yes" },
26-
{ "foo" : "no" }
27-
]
28-
};
29-
var hashMap = variables.model.newHashMap( ref );
30-
31-
expect( function(){
32-
var bar = hashMap.baz;
33-
} ).toThrow();
34-
expect( function(){
35-
var bar = hashMap[ "baz" ].foo;
36-
} ).toThrow();
37-
38-
debug( hashMap );
39-
40-
var nativeStruct = variables.model.ensureNativeStruct( hashMap );
41-
42-
debug( nativeStruct );
43-
44-
expect( nativeStruct.foo ).toBe( "bar" );
45-
expect( nativeStruct.baz ).toBeStruct();
46-
expect( nativeStruct.baz.foo ).toBe( "bar" );
47-
} );
48-
49-
it( "tests newHashMap with no arguments", function(){
50-
expect( getMetadata( variables.model.newHashMap() ).name ).toBe( "java.util.HashMap" );
51-
} );
52-
53-
it( "tests newHashMap with a nested struct and arrays", function(){
54-
var ref = {
55-
"foo" : "bar",
56-
"baz" : { "foo" : "bar" },
57-
"bazooms" : [ { "foo" : "bar" }, { "foo" : "baz" } ]
58-
};
59-
var hashMap = variables.model.newHashMap( ref );
60-
61-
expect( getMetadata( hashMap ).name ).toBe( "java.util.HashMap" );
62-
63-
expect( function(){
64-
var baz = hashMap.baz;
65-
} ).toThrow();
66-
67-
expect( function(){
68-
var baz = hashMap[ "baz" ].foo;
69-
} ).toThrow();
70-
71-
expect( hashMap[ "foo" ] ).toBe( "bar" );
72-
expect( hashMap[ "baz" ][ "foo" ] ).toBe( "bar" );
73-
for ( var zoom in hashMap[ "bazooms" ] ) {
74-
expect( getMetadata( zoom ).name ).toBe( "java.util.HashMap" );
75-
}
76-
} );
7717

7818
it( "tests handleResponseError with a simple error string", function(){
7919
var mockResponse = getMockBox().createMock( className = "Hyper.models.HyperResponse" );

0 commit comments

Comments
 (0)