Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

Panel

Anchor
configure default context
configure default context

How to configuration the default test application context

The annotation

Code Block
@ContextConfiguration(locations = {"classpath:applicationContext-csf-unit-tests-default.xml"})

is used to set the default test application context for all the junit tests which extend the AbstractIntegrationTestBase .java class.

If the project was created using the es-project-template (for either the jar or war) then the applicationContext-csf-unit-tests-default.xml file can be found it the project's src/test/resources directory.

If the project was NOT created using the es-project-template, then the applicationContext-csf-unit-tests-default.xml must be created in the project's src/test/resources directory.  To download the a starter version of the applicationContext-csf-unit-tests-default.xml file, right click on this link and select Save target as....  Be sure to save the file in the project's src/test/resources directory.

The following is a listing of the starter version of the applicationContext-csf-unit-tests-default.xml file:

  • For your CSF JAR projects:  Replace <projectName> with your project name.
    Code Block
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xmlns:util="http://www.springframework.org/schema/util"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/mvc
               http://www.springframework.org/schema/mvc/spring-mvc-xsd
               http://www.springframework.org/schema/util
               http://www.springframework.org/schema/util/spring-util.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx.xsd">
               
        <import resource="classpath*:applicationContext-csf-common.xml" />
        <import resource="classpath*:applicationContext-csf-webservices.xml" />
        <import resource="classpath*:applicationContext-csf-security-spring.xml" />
        <import resource="classpath*:applicationContext-csf-orm.xml" />
        <import resource="classpath*:applicationContext-csf-base.xml" />
        <!--import resource="classpath*:applicationContext-csf-email.xml" /-->
        <!--import resource="classpath*:applicationContext-csf-rules.xml" /-->
        <!--import resource="classpath*:applicationContext-csf-workflow.xml" /-->
        <import resource="classpath*:applicationContext-csf-<projectName>.xml" />
        <import resource="classpath*:applicationContext-csf-<projectName>-config-test.xml" />
     </beans>
    

  • For your CSF WAR project:  Replace <projectName> with your project name.
    Code Block
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:mvc="http://www.springframework.org/schema/mvc"
           xmlns:util="http://www.springframework.org/schema/util"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/mvc
               http://www.springframework.org/schema/mvc/spring-mvc-xsd
               http://www.springframework.org/schema/util
               http://www.springframework.org/schema/util/spring-util.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx.xsd">
               
        <import resource="classpath*:applicationContext-csf-common.xml" />
        <import resource="classpath*:applicationContext-csf-webservices.xml" />
        <import resource="classpath*:applicationContext-csf-security-spring.xml" />
        <import resource="classpath*:applicationContext-csf-orm.xml" />
        <import resource="classpath*:applicationContext-csf-base.xml" />
        <!--import resource="classpath*:applicationContext-csf-email.xml" /-->
        <!--import resource="classpath*:applicationContext-csf-rules.xml" /-->
        <!--import resource="classpath*:applicationContext-csf-workflow.xml" /-->
        <import resource="classpath*:applicationContext-csf-<projectName>.xml" />
        <import resource="classpath*:applicationContext-<projectName>.xml" />
        <import resource="classpath*:applicationContext-<projectName>-config-test.xml" />
     </beans>
    
    Notice that the starter version of the applicationContext-csf-unit-tests-default.xml only contains imports of the CSF application context files.  This
    This starter xml file must now be customized with your project's application context xml files.

The following is an example from the Student Sponsored Billing application and is an example on how to customize the applicationContext-csf-unit-tests-default.xml file.

Code Block
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://www.springframework.org/schema/mvc
           http://www.springframework.org/schema/mvc/spring-mvc-xsd
           http://www.springframework.org/schema/util
           http://www.springframework.org/schema/util/spring-util.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context.xsd
           http://www.springframework.org/schema/tx
           http://www.springframework.org/schema/tx/spring-tx.xsd">
           
    <import resource="classpath*:applicationContext-csf-common.xml" />
    <import resource="classpath*:applicationContext-csf-webservices.xml" />
    <import resource="classpath*:applicationContext-csf-security-spring.xml" />
    <import resource="classpath*:applicationContext-csf-orm.xml" />
    <import resource="classpath*:applicationContext-csf-base.xml" />
    <!--import resource="classpath*:applicationContext-csf-email.xml" /-->
    <!--import resource="classpath*:applicationContext-csf-rules.xml" /-->
    <!--import resource="classpath*:applicationContext-csf-workflow.xml" /-->
    <import resource="classpath*:applicationContext-csf-studentaccount.xml" />
    <import resource="classpath*:applicationContext-csf-ssb.xml" />
    <import resource="classpath*:applicationContext-ssb.xml" />
    <import resource="classpath*:applicationContext-ssb-config-test.xml" />
</beans>

The order in which the xml files appear is important.  Just remember the beans are instantiated in the order that they are processed and, if needed, overriding previous bean instantiations with identical ids.

...