On 9/14/06, Jeff Mutonho <[EMAIL PROTECTED]> wrote:

On 9/14/06, Bobby Quinne <[EMAIL PROTECTED]> wrote:
>
> The current preferred method my team use is the following :
>
> The applicationContext.xml is loaded via the BeanFactoryLocator from a beanRefFactory.xml which is pickup from the classpath. It contains the following:
>  <beans>
>     <bean id="za.co"
>           class="org.springframework.context.support.ClassPathXmlApplicationContext">
>         <constructor-arg>
>             <list>
>                 <value>spring.xml </value>
>             </list>
>         </constructor-arg>
>     </bean>
> </beans>
>
> The retrieving of beans is handled by a static class called SpringLoader. This accomplished with the following:
>     BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance();
>     BeanFactoryReference bf = bfl.useBeanFactory( "za.co" );
>     return bf.getFactory().getBean( _beanId );
>
> This reduced the need to have static/constructor definitions for :
>
> ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( "applicationContext.xml" ) all over the show.

Ok , if I understand you correctly , then all the xyzTestCase classes
will then use the BeanFactoryLocator to load the beans , thereby
avoiding the issue of  proliferation of the loading of
applicationContext.xml file from each xyzTestCase.
I looked around last night and got some ideas from the Turbine
website.One of their tests uses he wrapper class TestSetup.So you'd
have something like


public static Test suite(){

        /* Tests that need Spring */

        TestSuite tsuite = new TestSuite();
        tsuite.addTest(test1Test.suite());
        tsuite.addTest(test2Test.suite());
        tsuite.addTest(test3Test.suite ());

        TestSetup wrapper= new TestSetup(tsuite)
        {
            private TurbineConfig config = null;
            public void setUp()
            {
                try
                {
                    ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext( "applicationContext.xml" )
                }
                catch (Exception e)
                {
                    fail( StringUtils.stackTrace(e) );
                }
            }
        };

        TestSuite realSuite = new TestSuite();
        realSuite.addTest(wrapper);
        return realSuite;
    }


But , then with this you'd have to run all your test cases as a suite.

True, as well as there is extra coding for the TestSuite. That SpringLoader object I mentioned handles the loading when you call it so you don't have to worry about loading it upfront. You are able to avoid a number of hideous loading options for the context ;-).

Jeff  Mutonho

GoogleTalk : ejbengine
Skype        : ejbengine
Registered Linux user number 366042





--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---

Reply via email to