[CB 4.0][CBORM 1.0.3][testbox2.1.0] "The coldbox main controller has not been initialized"

62 views
Skip to first unread message

Brian Harcourt

unread,
Mar 17, 2015, 9:24:48 PM3/17/15
to col...@googlegroups.com
Hi all,
I've just started playing with Coldbox and am thrilled at the depth and breadth of the tool.
I've managed to fight my way thru several little stumbles up the learning curve but find myself at a loss at the moment.  I'm hoping someone will be able to point me in the right direction.

All seemed to be working.  I had the ormSettings incorrectly configured and was getting postgresql error "cross-database references are not implemented"
I fixed the ormSettings such that the query would hit 'test2.public' and now get "ColdBox Controller Not Found"

Googling this I find https://groups.google.com/forum/#!topic/coldbox/gMIRpXlY1Zc but I can't seem to make heads or tails of what that is about.


------------------------------ My testbox 'application.cfc' ------------------------------------
<cfcomponent output="false">
<!--- APPLICATION CFC PROPERTIES --->
<cfset this.name = "ColdBoxTestingSuite" & hash(getCurrentTemplatePath())>
<cfset this.sessionManagement = true>
<cfset this.sessionTimeout = createTimeSpan(0,0,30,0)>
<cfset this.setClientCookies = true>
<!--- Create testing mapping --->
<cfset this.mappings[ "/tests" ] = getDirectoryFromPath( getCurrentTemplatePath() )>
<cfset this.mappings[ "/coldbox" ] = "/var/www/coldbox">
<cfset this.mappings[ "/models" ] = "/var/www/curator/models">
<cfset this.mappings[ "/testbox" ] = "/var/www/coldbox/testbox">
<cfset this.mappings[ "/cborm" ] = "/var/www/coldbox/modules/cborm">
<!--- Map back to its root --->
<cfset rootPath = REReplaceNoCase( this.mappings[ "/tests" ], "tests(\\|/)", "" )>
<cfset this.mappings[ "/root" ]   = rootPath>
<cfscript>
this.javaSettings = { loadPaths = [ "lib" ], reloadOnChange = false };
this.datasource = "curator";
this.ormenabled = true;
this.ormSettings = {
datasource = "curator",
cfclocation = this.mappings[ "/models" ],
catalog = "test2",
schema = "public",
dbcreate = "none",
dialect = "PostgreSQL",
logSQL = true,
// Enable event handling
eventHandler = "cborm.models.EventHandler"
// Set the event handler to use, which will be inside our application.
};
</cfscript>
</cfcomponent>

--------------------------- My 'articleTest.cfc' --------------------------------
component extends="testbox.system.BaseSpec"{
/*********************************** LIFE CYCLE Methods ***********************************/
// executes before all suites+specs in the run() method
function beforeAll(){
aService = createObject('component', 'models.article.articleService').init();
mockArticle = getMockBox().createMock("models.article.article").init(aService);
mockArticle.$property(propertyName="ArticleID",mock="123456");
mockArticle.$property(propertyName="Headline",mock="A Sample Headline");
}

// executes after all suites+specs in the run() method
function afterAll(){
}

/*********************************** BDD SUITES ***********************************/
function run( testResults, testBox ){
// all your suites go here.
describe( "An article", function(){
it("should be an object", function(){
expect(mockArticle).toBeComponent();
});
it("should be able to be created", function(){
oA = aService.get(0);
expect(oA).toBeComponent();
});


});
}
}

---------------------- My articleService.cfc ----------------------------------------------
/**
* Article service
*/
component extends="cborm.models.VirtualEntityService" singleton{
/**
* Constructor
*/
function init(){
// init super class
super.init(entityName="article");
// Use Query Caching
   setUseQueryCaching( false );
   // Query Cache Region
   setQueryCacheRegion( 'query.article' );
   // EventHandling
   setEventHandling( true );
   
   return this;
}
}

Brian Harcourt

unread,
Mar 17, 2015, 9:51:07 PM3/17/15
to col...@googlegroups.com
At this point I'm guessing I need to bootstrap coldbox in my testbox application.cfc.  Does that sound like the right direction?

Luis Majano

unread,
Mar 17, 2015, 10:16:34 PM3/17/15
to col...@googlegroups.com, col...@googlegroups.com
Are you having errors in your integration tests?


--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/64d8aeb6-5041-4f87-8f22-126eb2681399%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Majano

unread,
Mar 17, 2015, 10:16:45 PM3/17/15
to col...@googlegroups.com, col...@googlegroups.com
Can you post your testss

On Tue, Mar 17, 2015 at 6:24 PM, Brian Harcourt <brian.k....@gmail.com> wrote:

--

Luis Majano

unread,
Mar 17, 2015, 10:18:48 PM3/17/15
to col...@googlegroups.com, col...@googlegroups.com
Oops. I just saw them. 

Yes the problem is you are doing A integration test to load the orm extensions. Therefore instead of extending from base spec exten from the ColdBox base testing class
ColdBox.system.testing.BaseTestCase

This way you can load the virtual application into memory. 

On Tue, Mar 17, 2015 at 6:24 PM, Brian Harcourt <brian.k....@gmail.com> wrote:

--

Brian Harcourt

unread,
Mar 17, 2015, 11:25:49 PM3/17/15
to col...@googlegroups.com
Hi Luis - 
Not sure what you are asking . . .
I'm just running the /tests/runner.cfm from the browser.

I have the sample tests in the /tests/specs/integration folder and they are not giving me errors but both the "MainTest" and the MainBDDTest" are each giving me one failure in the 'doSomething' (some kind of 'relocation test'?).

The error I see is in my own test in the /tests/specs/unit/articleTest.cfc (code above).

The specific error message is 
ColdBox Controller Not Found
and he detail is 
The coldbox main controller has not been initialized

I guess one would call it an 'integration test' because it is integrating my code with the database system.

Brian Harcourt

unread,
Mar 17, 2015, 11:27:04 PM3/17/15
to col...@googlegroups.com
The test code is posted in the original message.  Would you like me to post some other way?  

Brian Harcourt

unread,
Mar 17, 2015, 11:28:01 PM3/17/15
to col...@googlegroups.com
heh - finally reading your whole post.  Thanks for the ideas - off to play with them - I'll report back.
B.

Brian Harcourt

unread,
Mar 17, 2015, 11:53:20 PM3/17/15
to col...@googlegroups.com
Seems to make a lot of sense but - unfortunately - no joy.
My message is just the same  . . . 
"The coldbox main controller has not been initialized"

my only change was the 'extends' attribute . . . here's the new code.
-----------------------------------------------------------------
/**
* Article tests
*/
component extends="coldbox.system.testing.BaseTestCase"{
/*********************************** LIFE CYCLE Methods ***********************************/

// executes before all suites+specs in the run() method
function beforeAll(){
aService = createObject('component', 'models.article.articleService').init();
mockArticle = getMockBox().createMock("models.article.article").init(aService);
mockArticle.$property(propertyName="ArticleID",mock="123456");
mockArticle.$property(propertyName="Headline",mock="A Sample Headline");
}

// executes after all suites+specs in the run() method
function afterAll(){
}

/*********************************** BDD SUITES ***********************************/

function run( testResults, testBox ){
// all your suites go here.
describe( "An article", function(){
it("should be an object", function(){
expect(mockArticle).toBeComponent();
});
it("should be able to be created", function(){
oA = aService.get(0);
expect(oA).toBeComponent();
});


});
}
}
---------------------------------------------

Was my supposition of needing to bootstrap in the /tests/application.cfc correct?
Perhaps I should dig there.



On Tuesday, March 17, 2015 at 7:18:48 PM UTC-7, Luis Majano wrote:

Luis Majano

unread,
Mar 18, 2015, 12:32:43 AM3/18/15
to col...@googlegroups.com, col...@googlegroups.com
You need a call to Boostrap the framework in your before all method. Do a call to setup(); in there before any code
Reply all
Reply to author
Forward
0 new messages