Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ jobs:
box server start serverConfigFile="server-${{ matrix.cfengine }}.json" --noSaveSettings --debug
curl http://127.0.0.1:60299

- name: Run Adobe Full Null Regression
if: ${{ matrix.cfengine == 'adobe@2025' }}
run: |
curl --fail-with-body http://127.0.0.1:60299/tests/full-null/index.cfm

- name: Run Tests
run: |
mkdir -p test-harness/tests/results
Expand Down
8 changes: 4 additions & 4 deletions models/BaseORMService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ component accessors="true" {
* @return cborm.models.util.IORMUtil
*/
function getOrm(){
if ( isNull( variables.orm ) ) {
if ( !structKeyExists( variables, "orm" ) || isNull( variables.orm ) ) {
variables.orm = new cborm.models.util.ORMUtilFactory().getORMUtil();
}
return variables.orm;
Expand All @@ -180,7 +180,7 @@ component accessors="true" {
* @return cborm.models.EventHandler|cborm.models.BXEventHandler
*/
function getORMEventHandler(){
if ( isNull( variables.ORMEventHandler ) ) {
if ( !structKeyExists( variables, "ORMEventHandler" ) || isNull( variables.ORMEventHandler ) ) {
variables.ORMEventHandler = server.keyExists( "boxlang" ) ? new cborm.models.BXEventHandler() : new cborm.models.EventHandler()
}
return variables.ORMEventHandler
Expand All @@ -192,7 +192,7 @@ component accessors="true" {
* @return cborm.models.util.DynamicProcessor
*/
function getDynamicProcessor(){
if ( isNull( variables.dynamicProcessor ) ) {
if ( !structKeyExists( variables, "dynamicProcessor" ) || isNull( variables.dynamicProcessor ) ) {
variables.dynamicProcessor = variables.wirebox.getInstance( "cborm.models.util.DynamicProcessor" )
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ component accessors="true" {
* @return coldbox.system.core.dynamic.ObjectPopulator
*/
function getObjectPopulator(){
if ( !isNull( variables.objectPopulator ) ) {
if ( structKeyExists( variables, "objectPopulator" ) && !isNull( variables.objectPopulator ) ) {
return variables.objectPopulator
}
variables.objectPopulator = variables.wirebox.getObjectPopulator()
Expand Down
13 changes: 13 additions & 0 deletions test-harness/tests/full-null/Application.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
component {

moduleRoot = createObject( "java", "java.io.File" )
.init( getDirectoryFromPath( getCurrentTemplatePath() ) & "../../../" )
.getCanonicalPath();

this.name = "cborm-full-null-regression-#hash( moduleRoot )#";
this.enableNullSupport = true;
this.mappings[ "/cborm" ] = moduleRoot;
this.mappings[ "/coldbox" ] = moduleRoot & "/test-harness/coldbox";
this.mappings[ "/fullnull" ] = getDirectoryFromPath( getCurrentTemplatePath() );

}
33 changes: 33 additions & 0 deletions test-harness/tests/full-null/FakeWireBox.cfc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
component {

variables.instanceCalls = 0;
variables.objectPopulatorCalls = 0;
variables.dynamicProcessor = { type : "dynamicProcessor" };
variables.objectPopulator = { type : "objectPopulator" };

function getInstance(){
variables.instanceCalls++;
return variables.dynamicProcessor;
}

function getLogBox(){
return this;
}

function getLogger(){
return {};
}

function getObjectPopulator(){
variables.objectPopulatorCalls++;
return variables.objectPopulator;
}

function getCallCounts(){
return {
instance : variables.instanceCalls,
objectPopulator : variables.objectPopulatorCalls
};
}

}
37 changes: 37 additions & 0 deletions test-harness/tests/full-null/index.cfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<cfsetting showDebugOutput="false">
<cfscript>
wirebox = new fullnull.FakeWireBox();
application.wirebox = wirebox;
service = new cborm.models.BaseORMService( datasource = "unused" );

orm = service.getOrm();
sameOrm = service.getOrm();
eventHandler = service.getORMEventHandler();
sameHandler = service.getORMEventHandler();

dynamicProcessor = service.getDynamicProcessor();
sameDynamicProcessor = service.getDynamicProcessor();
objectPopulator = service.getObjectPopulator();
sameObjectPopulator = service.getObjectPopulator();
callCounts = wirebox.getCallCounts();
system = createObject( "java", "java.lang.System" );

if (
!isInstanceOf( orm, "cborm.models.util.support.AdobeORMUtil" ) ||
!isInstanceOf( sameOrm, "cborm.models.util.support.AdobeORMUtil" ) ||
system.identityHashCode( orm ) != system.identityHashCode( sameOrm ) ||
!isInstanceOf( eventHandler, "cborm.models.EventHandler" ) ||
!isInstanceOf( sameHandler, "cborm.models.EventHandler" ) ||
system.identityHashCode( eventHandler ) != system.identityHashCode( sameHandler ) ||
!isStruct( dynamicProcessor ) ||
!isStruct( sameDynamicProcessor ) ||
!isStruct( objectPopulator ) ||
!isStruct( sameObjectPopulator ) ||
callCounts.instance != 1 ||
callCounts.objectPopulator != 1
) {
throw( type = "RegressionFailure", message = "cbORM public lazy dependencies did not initialize exactly once." );
}

writeOutput( "PASS" );
</cfscript>
16 changes: 16 additions & 0 deletions test-harness/tests/specs/BaseORMServiceTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
assert( 1 eq t, "CountBylastName" );
}

function testLazyDependenciesThroughPublicAPI(){
var service = new cborm.models.BaseORMService().init();
var system = createObject( "java", "java.lang.System" );

expect( system.identityHashCode( service.getOrm() ) ).toBe( system.identityHashCode( service.getOrm() ) );
expect( system.identityHashCode( service.getORMEventHandler() ) ).toBe(
system.identityHashCode( service.getORMEventHandler() )
);
expect( system.identityHashCode( service.getDynamicProcessor() ) ).toBe(
system.identityHashCode( service.getDynamicProcessor() )
);
expect( system.identityHashCode( service.getObjectPopulator() ) ).toBe(
system.identityHashCode( service.getObjectPopulator() )
);
}

function testFindAllByDynamically(){
// Using Conditionals
t = ormservice.findAllByLastNameLessThan( "User", "Majano" );
Expand Down