Hi all,
I am using Stripes 1.4.3, Spring 2.5.3 and TestNG 5.7.
I am trying to unit test some action beans using the Stripes Mock
container, and Spring's AbstractTransactionalTestNGSpringContextTests,
but the transactions are not rolled back after the test execution.
The problem occurs only when I am using the Stripes Mock container.
Below is how I setup the mock container:
public void setup() {
if (context == null) {
XmlWebApplicationContext applicationContext = new
XmlWebApplicationContext();
applicationContext.setConfigLocations(new String[] {
"classpath:/**/applicationContext.xml",
"classpath:/**/applicationContext.xmlclasspath:/**/dataSource.xml" });
applicationContext.refresh();
context = new MockServletContext("stripes-travel");
context.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_
ATTRIBUTE, applicationContext);
// Add the Stripes Filter along with it's init-params
Map<String, String> filterParams = new HashMap<String, String>();
filterParams.put("Interceptor.Classes",
"net.sourceforge.stripes.integration.spring.SpringInterceptor,net.source
forge.stripes.controller.BeforeAfterMethodInterceptor");
filterParams.put("ActionResolver.PackageFilters",
"com.accenture.ukdc.ai.stripes.booking.*");
filterParams.put("ActionResolver.UrlFilters", "classes");
filterParams.put("ActionBeanContext.Class",
"com.accenture.ukdc.ai.stripes.booking.web.action.BaseActionBeanContext"
);
filterParams.put("ExceptionHandler.Class",
"com.accenture.ukdc.ai.stripes.booking.web.ErrorHandler");
filterParams.put("LocalePicker.Locales", "en_GB:UTF-8");
context.addFilter(StripesFilter.class, "StripesFilter", filterParams);
// Add the Stripes Dispatcher
context.setServlet(DispatcherServlet.class, "StripesDispatcher", null);
}
}
All the test classes extend BaseTransactionalTestNGClass which in turn
is defined as follows:
@ContextConfiguration(locations = { "/WEB-INF/applicationContext.xml",
"/WEB-INF/dataSource.xml" })
public class BaseTransactionalTestNGClass extends
AbstractTransactionalTestNGSpringContextTests { }
In the logs I can see that Spring is rolling back the transaction, but
the data is still persisted in the database:
17:06:26,890 INFO TransactionalTestExecutionListener:279 - Rolled back
transaction after test execution for test context [EMAIL PROTECTED]
testClass = ManageAccountsActionBeanTest, locations =
array<String>['classpath:/WEB-INF/applicationContext.xml',
'classpath:/WEB-INF/dataSource.xml'], testInstance =
com.accenture.ukdc.ai.stripes.booking.web.action.ManageAccountsActionBea
[EMAIL PROTECTED], testMethod = [EMAIL PROTECTED],
testException = [null]]]
For the record, the exact behavior is experienced when using the
AbstractTransactionalJUnitSpringContextTests.
This message is for the designated recipient only and may contain privileged,
proprietary, or otherwise private information. If you have received it in
error, please notify the sender immediately and delete the original. Any other
use of the email by you is prohibited.
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Stripes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-users