You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Paul Grove (JIRA)" <ji...@apache.org> on 2010/04/19 15:45:49 UTC

[jira] Created: (WW-3443) StrutsSpringTestCase does not support multiple spring xml configuration files

StrutsSpringTestCase does not support multiple spring xml configuration files
-----------------------------------------------------------------------------

                 Key: WW-3443
                 URL: https://issues.apache.org/jira/browse/WW-3443
             Project: Struts 2
          Issue Type: Bug
    Affects Versions: 2.1.8.1
            Reporter: Paul Grove


Spring has a great concept that you can load the xml configuration and define beans with the same name multiple times and the convention is that the lasr definition takes precedence. This is great for testing as we usually load the normal (production) application context xml then load a test application context xml which just overides the beans that need to be changed for that test.

Currently the StrutsSpringTestCase does not support defining multiple application context xml files for a test. I rewrote the class so that the method protected String getContextLocations() is now protected String[] getContextLocations(). We can now load multiple application context xml files.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-3443) StrutsSpringTestCase does not support multiple spring xml configuration files

Posted by "Ty Connell (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/WW-3443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12910360#action_12910360 ] 

Ty Connell commented on WW-3443:
--------------------------------

I was able to overcome this by overriding the protected method setupBeforeInitDispatcher like so:

    @Override
    protected void setupBeforeInitDispatcher() throws Exception {
		String[] contextLocations = new String[]{ "classpath:applicationContext-security.xml", 
				"classpath:applicationContext.xml",	"classpath:junitApplicationContext.xml" };
		
        GenericXmlContextLoader xmlContextLoader = new GenericXmlContextLoader();
        applicationContext = xmlContextLoader.loadContext(contextLocations);
        servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
    }

> StrutsSpringTestCase does not support multiple spring xml configuration files
> -----------------------------------------------------------------------------
>
>                 Key: WW-3443
>                 URL: https://issues.apache.org/jira/browse/WW-3443
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.1.8.1
>            Reporter: Paul Grove
>
> Spring has a great concept that you can load the xml configuration and define beans with the same name multiple times and the convention is that the lasr definition takes precedence. This is great for testing as we usually load the normal (production) application context xml then load a test application context xml which just overides the beans that need to be changed for that test.
> Currently the StrutsSpringTestCase does not support defining multiple application context xml files for a test. I rewrote the class so that the method protected String getContextLocations() is now protected String[] getContextLocations(). We can now load multiple application context xml files.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (WW-3443) StrutsSpringTestCase does not support multiple spring xml configuration files

Posted by "Lukasz Lenart (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/WW-3443?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart closed WW-3443.
-----------------------------

         Assignee: Lukasz Lenart
    Fix Version/s: 2.2.2
       Resolution: Fixed

Done, now you can override getContextLocations() method to specify as many context locations you want ;-)

    protected String[] getContextLocations() {
        return new String[] {DEFAULT_CONTEXT_LOCATION};
    }

> StrutsSpringTestCase does not support multiple spring xml configuration files
> -----------------------------------------------------------------------------
>
>                 Key: WW-3443
>                 URL: https://issues.apache.org/jira/browse/WW-3443
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 2.1.8.1
>            Reporter: Paul Grove
>            Assignee: Lukasz Lenart
>             Fix For: 2.2.2
>
>
> Spring has a great concept that you can load the xml configuration and define beans with the same name multiple times and the convention is that the lasr definition takes precedence. This is great for testing as we usually load the normal (production) application context xml then load a test application context xml which just overides the beans that need to be changed for that test.
> Currently the StrutsSpringTestCase does not support defining multiple application context xml files for a test. I rewrote the class so that the method protected String getContextLocations() is now protected String[] getContextLocations(). We can now load multiple application context xml files.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.