views:

29

answers:

2

How do I access the Errors-object created by spring when validation fails from a Spring Webflow 2.0 test (inherits from AbstractXmlFlowExecutionTests)?

I tried using the FormObjectAccessor.getCurrentFormErrors() but I couldn't get a reference to the RequestContext.

A: 

I am wondering about this myself. I create a mock RequestContext for each of my tests. How do you get a FormObjectAccessor?

MockExternalContext context = new MockExternalContext();
context.setEventId("submit");
... some assertions/expectations...
resumeFlow(context);
assertCurrentStateEquals("some-state");
... here is where I want to access my errors object 
atroutt
I also asked this question on the spring forums just now. (no answer yet) http://forum.springsource.org/showthread.php?t=96740
atroutt
I like the answer from Rossen above.
atroutt
+1  A: 

What is the reason you want to access the errors? Wouldn't it be simpler to write unit tests for your validation methods?

Rossen Stoyanchev