How to set up test?

Using commandbox embedded server I cannot run my test if I enable url rewriting usign --rewritesEnable flag.

If I try to run a test: 127.0.0.1:49343/tests/specs/integration/HomeBDDTest.cfc?method=runRemote I got this error:

`

Event: tests.specs
Routed URL: tests/specs/integration/HomeBDDTest.cfc/
Layout: N/A (Module: )
View: N/A
Timestamp: 04/08/2015 05:40:49 AM

This is an unfortunate limitation of Tuckey URL rewrites. The project hasn’t had a new version in a while so I’m not sure if it will ever get fixed.

You can see our default rewrite configuration here:
https://github.com/Ortus-Solutions/commandbox/blob/master/src/cfml/system/config/urlrewrite.xml

The rewrite engine is not supposed to kick in if the path points to an actual file or folder. However, that feature seems to not be working correctly according to Luis’ tests…

Here is the commit that supposedly added that feature:
https://code.google.com/p/urlrewritefilter/source/detail?r=287

Glancing at the code, there is debugging you can enable to figure out what’s happening. Feel free to dig in and try to figure out why it’s not working.

https://code.google.com/p/urlrewritefilter/source/browse/trunk/src/java/org/tuckey/web/filters/urlrewrite/Condition.java?spec=svn287&r=287#264
https://code.google.com/p/urlrewritefilter/source/browse/trunk/src/java/org/tuckey/web/filters/urlrewrite/Condition.java?spec=svn287&r=287#336

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Francesco,

I ran into this same issue a while back and the way I got around it was by doing the following. It may be a hack and ultimately not the way to go, but it at least got me around this issue until I could look into it in more detail.

In config/Routes.cfm I added:

if ( structKeyExists( url, ‘testRunner’ ) && url.testRunner ) {
setEnabled(false);
setAutoReload(false);
}

Then in my integration tests I added:

beforeEach(function( currentSpec ){
// Setup as a new ColdBox request for this suite, VERY IMPORTANT. ELSE EVERYTHING LOOKS LIKE THE SAME REQUEST.
setup();
URL.testRunner = true;
});

Hope that helps a little.

Thanks,
Ben

You can add a custom rewrite config file that will exclude the “tests” directory. I have attached a sample one.

<?xml version="1.0" encoding="utf-8"?> ContentBox Media URLs ^/__media/.*$ ^/(.*)$ /index.cfm/$1 Generic Front-Controller URLs /(index.cfm|tests|robots.txt|osd.xml|flex2gateway|cfide|cfformgateway|railo-context|lucee|admin-context|modules/contentbox-dsncreator|modules/contentbox-installer|modules/contentbox|files|images|js|javascripts|css|styles|config).* \.(bmp|gif|jpe?g|png|css|js|txt|xls|ico|swf|woff|ttf|otf)$ ^/(.+)$ /index.cfm/$1

Luis Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
P/F: 1-888-557-8057
Direct: (909) 248-3408

ColdBox Platform: http://www.coldbox.org

ContentBox Platform: http://www.gocontentbox.org
Linked In: http://www.linkedin.com/pub/3/731/483

Social: twitter.com/ortussolutions | twitter.com/coldbox | twitter.com/lmajano | twitter.com/gocontentbox

Thanks Luis, this configuration is the same generated by commandbox except the tests condition. Probably should be added to the template by default.

Unfortunately, I think that would then disallow the possibility of a handler called “tests”. We had quite a discussion over what to include by default in this JiRA ticket.

https://ortussolutions.atlassian.net/browse/COMMANDBOX-75

Everyone had a slightly different idea of what to do for default, so we left it pretty open and generic. I’d like to have the ability to ship CommandBox several default rewrite rule sets customized for ColdBox, CFWheels, ContentBox, etc. Once we implement server.json, it should be a little easier to declare a default rewrite file to use. Actually, I think THINK it will remember your last rewrite file automatically right now but I haven’t tested that specifically.

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com