You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Rich Thornett (JIRA)" <ji...@apache.org> on 2007/04/02 21:12:52 UTC
[jira] Created: (WW-1868) Struts 2 validation testing fails because
ObjectFactory is null
Struts 2 validation testing fails because ObjectFactory is null
---------------------------------------------------------------
Key: WW-1868
URL: https://issues.apache.org/struts/browse/WW-1868
Project: Struts 2
Issue Type: Bug
Affects Versions: 2.0.6
Reporter: Rich Thornett
Recenly upgraded from Struts 2.0.1 to Struts 2.0.6 and my unit tests of Struts2 validation now fail. Unit tests followed the pattern described here:
http://struts.apache.org/2.x/docs/how-do-i-unit-test-my-actions-validation-logic.html
The issue has been noticed by others and is described in more detail here:
http://www.nabble.com/Struts-2-and-Validation-Testing-t3451623.html
Core problem seems to be that ObjectFactory is not getting set by the time it is referenced in
ValidatorFileParser.parseValidatorDefinitions() // xwork-2.0.1
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (WW-1868) Struts 2 validation testing fails because
ObjectFactory is null
Posted by "Thomas Ferris Nicolaisen (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-1868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Ferris Nicolaisen updated WW-1868:
-----------------------------------------
Attachment: TestValidation.patch
Attached a testcase that demonstrates the example from the wiki-link above.
As stated, the test-case works if StrutsTestcase or XWorkTestCase is extended.
I don't know whether it is an issue that we are dependant on StrutsTestCase for doing validation testing, but I end up with an NPE when running the StrutsTestCase.setup method in my own code because of dependance to the Spring objectFactory not being set in this test-case. I tried replacing the strutsSpringObjectFactory with my own subclass of SpringProxyableObjectFactory that overrides with a manual applicationContext lookup, but the SpringObjectFactory attempts to use appContext before getApplicationContext has been called.
Anyhow, I'm sure the spring-integration with StrutsTestCase has been raised somewhere else, just a bit too tired to figure out right now.
But the issue remains: Validation unit tests depend on StrutsTestCase. Is this a wontfix?
> Struts 2 validation testing fails because ObjectFactory is null
> ---------------------------------------------------------------
>
> Key: WW-1868
> URL: https://issues.apache.org/struts/browse/WW-1868
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.0.6
> Reporter: Rich Thornett
> Attachments: TestValidation.patch
>
>
> Recenly upgraded from Struts 2.0.1 to Struts 2.0.6 and my unit tests of Struts2 validation now fail. Unit tests followed the pattern described here:
> http://struts.apache.org/2.x/docs/how-do-i-unit-test-my-actions-validation-logic.html
> The issue has been noticed by others and is described in more detail here:
> http://www.nabble.com/Struts-2-and-Validation-Testing-t3451623.html
> Core problem seems to be that ObjectFactory is not getting set by the time it is referenced in
> ValidatorFileParser.parseValidatorDefinitions() // xwork-2.0.1
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (WW-1868) Struts 2 validation testing fails
because ObjectFactory is null
Posted by "Don Brown (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/struts/browse/WW-1868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Don Brown resolved WW-1868.
---------------------------
Resolution: Fixed
Fix Version/s: 2.0.8
Assignee: Don Brown
I modified xwork to throw a more helpful error message if it detects the object factory to be null. You should only need to add "ObjectFactory.setObjectFactory(new ObjectFactory())" to your setup() method if you don't want to extend StrutsTestCase. The error message says as much.
> Struts 2 validation testing fails because ObjectFactory is null
> ---------------------------------------------------------------
>
> Key: WW-1868
> URL: https://issues.apache.org/struts/browse/WW-1868
> Project: Struts 2
> Issue Type: Bug
> Affects Versions: 2.0.6
> Reporter: Rich Thornett
> Assigned To: Don Brown
> Fix For: 2.0.8
>
> Attachments: TestValidation.patch
>
>
> Recenly upgraded from Struts 2.0.1 to Struts 2.0.6 and my unit tests of Struts2 validation now fail. Unit tests followed the pattern described here:
> http://struts.apache.org/2.x/docs/how-do-i-unit-test-my-actions-validation-logic.html
> The issue has been noticed by others and is described in more detail here:
> http://www.nabble.com/Struts-2-and-Validation-Testing-t3451623.html
> Core problem seems to be that ObjectFactory is not getting set by the time it is referenced in
> ValidatorFileParser.parseValidatorDefinitions() // xwork-2.0.1
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.