help please! MXUnit Environment Problems

Some background. I’m running ACF on linux using apache.

My main application is running at the root of a domain. In my application.cfc, I have a mapping to / for the application and a mapping to /vtmo for the application.

I have added a global mapping for /mxunit and a directory mapping in apache to the correct path. Accessing /mxunit behaves as expected.

I’m using the standard htaccess file for redirects.

I couldn’t figure out why accessing /test on my application was failing so miserably until I started digging in the BaseTestCase.cfc file. Basically, expandPath() has problems with mod_rewrite in apache. Here are some relevant links: http://www.google.com/search?q=expandpath+mod_rewrite

I found that if I added “NS” to my last mod_rewrite line in .htaccess, expandPath behaved as expected. (http://old.nabble.com/Re%3A-expandPath()-and-mod_rewrite-td15057484.html)

BUT, now I’m having a problem when accessing the test through my browser that the exception handler as defined in my coldbox app is fired (and the page is redirected) instead of triggering a failed test.

Anyone have ANY clue what to do here??

I’m really at a loss and extremely frustrated with the difficulties I’ve had trying to get coldbox/mxunit working in my environment.

While this may or may not be related… I also can’t seem to get the mxunit runner to work with my setup in cfbuilder. It installs correctly and the remote facade test works as expected. But it doesn’t seem to be able to auto-find my tests, and when I add my tests manually to the mxunit runner, and attempt to run the tests I get:

Running method testcheck…

RemoteException: coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.AbortException : null]

finished.

If I comment out my “execute(‘some.event’)” line (with a valid event), the test passes correctly. I have tried changing the appMapping on my test case to “/” or “/vtmo” and both seem to behave the same.

I would really appreciate any suggestions or guidance here.

Thanks in advance you extremely smart, talented, helpful community :slight_smile:

-Ben

Ben,

The MXUnit and ColdBox testing tools that integrate with MXUnit have no need for rewriting. The quickest path to resolution is to stop URL rewriting for all requests under your /test directory. For example, I have two environments I work with that use URL rewriting. One is IIS and another is Tukey URLRewrite for Tomcat. I’m currently not using Apache 2+ but the following rule should be the same. Just place it somewhere near the top–and, actually–you should have a similar rule for your CFIDE or other administration directories already.

Here is my rule for IIS:

You basically want to match “^/test/” and stop processing if that condition is met.

Aaron Greenlee
http://aarongreenlee.com/

Thanks for that. I removed the ‘NS’ directive for the last url rewrite and excluded test from the rewrite. I’m still having the problem where executing an event is redirecting to the
event itself instead of finishing the test.

e.g., I have executeEvent(‘company.check’) and it redirects to /company/check and i get my exception page. It is not staying within the test runner.

any thoughts on this?

Thanks!

Ben

Clarification: I have ‘execute(‘company.check’)’ not executeEvent…

Also, I think it would make sense to add the exclusion for test to the default .htaccess file if this is how it should be set up.

Thanks!

Do you have a setNextEvent() call in your handler under test?

So, I’m still seeing the url change and the page redirect when running ‘execute’ inside my test case.

I’m not sure why, but what I’m seeing is that the url is being redirected when this line of code is executed in the basetestcase execute method:

cbController.getInterceptorService().processState(“preProcess”);

It never gets to the next line of code.

My handler doesn’t have any redirect or set next event code in the method being tested.

Just commented that line out for the heck of it and the test operated mostly as expected. Though it isn’t auto wiring my dependencies. (probably related to the preprocess event never being handled).

I don’t have any custom intercepters, so that shouldn’t be the issue.

Ben

AHA… found out WHERE the problem is… SES is trying to intercept the event and rewrite the URL… anyone have any ideas on how to fix it?

Can you post your test case? Also, what version of ColdBox are you using?

Aaron Greenlee

I’m running the latest version from the development branch on github.

component extends=“coldbox.system.testing.BaseTestCase” appMapping="/" {

/**

  • You can remove this setup method if you do not have anything to setup

*/

void function setup(){

//Call the super setup method to setup the app.

super.setup();

// Your own setup here if needed

}

function listCompanyLogsByDateRange(){

var event = “”;

var startDay = createDate(2011,1,1);

var endDay = createDate(2011,9,1);

URL.startDate = startDay;

URL.endDate = endDay;

event = super.execute(“services.commuteLog.listCompanyLogsByDateRange”);

//Do your asserts below

}

}