Skip to content

Commit

Permalink
updates to shutdown factories correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed Nov 2, 2023
1 parent 445f727 commit 0649b67
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
4 changes: 2 additions & 2 deletions system/cache/providers/CacheBoxProvider.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ component
variables.cacheFactory
.getTaskScheduler()
.newTask(
name : "cachebox-reap-#getName()#",
name : "cachebox-reap-#getName()#-#getCacheId()#",
task : this,
method: "reap"
)
.inMinutes()
.delay( getConfiguration().reapFrequency ) // Don't start immediately, give it a breathing room
.spacedDelay( getConfiguration().reapFrequency ) // Runs again, after this spaced delay once each reap finalizes
.inMinutes()
.start();

variables.logger.info(
Expand Down
4 changes: 4 additions & 0 deletions tests/specs/cache/CacheBoxStandalone.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ component extends="testbox.system.BaseSpec" {
function run( testResults, testBox ){
// all your suites go here.
describe( "CacheBox Standalone", function(){
afterEach( function( currentSpec ){
cachebox.shutdown();
} );

it( "can be configured with a standalone configuration object", function(){
cacheBox = new coldbox.system.cache.CacheFactory(
config = "tests.resources.StandaloneCacheBoxConfig"
Expand Down
4 changes: 4 additions & 0 deletions tests/specs/cache/CacheFactoryTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
cacheFactory.init();
}

function afterTests(){
cacheFactory.shutdown();
}

function testGetConfig(){
// debug( cacheFactory.getConfig() );
}
Expand Down
8 changes: 4 additions & 4 deletions tests/specs/cache/config/CacheBoxConfigWithDataCFCTest.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<cfcomponent extends="coldbox.system.testing.BaseModelTest">
<cfscript>
component extends="coldbox.system.testing.BaseModelTest" {

function setup(){
// cacheBox = createMock(className="coldbox.system.logging.LogBox" );
dataConfigPath = "coldbox.tests.resources.CacheBoxConfigData";
Expand Down Expand Up @@ -51,5 +51,5 @@

config.validate();
}
</cfscript>
</cfcomponent>

}
8 changes: 4 additions & 4 deletions tests/specs/cache/config/DefaultConfigurationTest.cfc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<cfcomponent extends="coldbox.system.testing.BaseModelTest">
<cfscript>
component extends="coldbox.system.testing.BaseModelTest" {

function setup(){
config = createMock( "coldbox.system.cache.config.DefaultConfiguration" );
}

function testConfigure(){
config.configure();
}
</cfscript>
</cfcomponent>

}
12 changes: 8 additions & 4 deletions tests/specs/cache/listeners/CacheFactoryListenersTest.cfc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<cfcomponent extends="coldbox.system.testing.BaseModelTest">
<cfscript>
component extends="coldbox.system.testing.BaseModelTest" {

function setup(){
// init with defaults
cacheFactory = createMock( "coldbox.system.cache.CacheFactory" );
Expand All @@ -13,12 +13,16 @@
cacheFactory.init( config = config );
}

function afterTests(){
cacheFactory.shutdown();
}

function testRegisterListeners(){
eventContainers = cacheFactory.getEventManager().getEventPoolContainer();

assertEquals( true, structKeyExists( eventContainers, "afterCacheElementInsert" ) );
assertEquals( true, structKeyExists( eventContainers, "beforeCacheShutdown" ) );
assertEquals( true, structKeyExists( eventContainers, "afterCacheFactoryConfiguration" ) );
}
</cfscript>
</cfcomponent>

}
1 change: 1 addition & 0 deletions tests/specs/logging/appenders/FileAppenderTest.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ component extends="coldbox.system.testing.BaseModelTest" {
}

// sleep to let threads write to disk.
writeDump( var = "Sleeping for 5 seconds waiting for log file...", output = "console" );
sleep( 5000 );

var content = fileRead( fileAppender.getLogFullPath() );
Expand Down

0 comments on commit 0649b67

Please sign in to comment.