Announcement Announcement Module
Collapse
No announcement yet.
roo + spring 3.1 + environment profiles + auto generated tests Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • roo + spring 3.1 + environment profiles + auto generated tests

    Spring 3.1 adds supports for environment profiles to context setup.


    At the end of this post is an example from the spring 3.1 docs.

    I am planning on using 3 environment profiles:
    1) dev - deployment to a dev server
    2) production - deployment to production server
    3) testing - unit test profile


    Is there a way to get roo to add the @ActiveProfile("testing") profile to the generated .aj files?

    It would be nice if roo supported profiles in the application context, but I am happy to do that manually.

    Thanks
    Mike
    ------------------------------------------------------------------------------------------------


    Code:
    <!-- app-config.xml -->
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jdbc="http://www.springframework.org/schema/jdbc"
        xmlns:jee="http://www.springframework.org/schema/jee"
        xsi:schemaLocation="...">
    
       ------ some lines deleted
    
        <beans profile="dev">
            <jdbc:embedded-database id="dataSource">
                <jdbc:script
                    location="classpath:com/bank/config/sql/schema.sql"/>
                <jdbc:script
                    location="classpath:com/bank/config/sql/test-data.sql"/>
            </jdbc:embedded-database>
        </beans>
    
        <beans profile="production">
            <jee:jndi-lookup id="dataSource"
                jndi-name="java:comp/env/jdbc/datasource"/>
        </beans>
    
    </beans>



    Code:
    package com.bank.service;
    
    @RunWith(SpringJUnit4ClassRunner.class)
    // ApplicationContext will be loaded from "classpath:/app-config.xml"
    @ContextConfiguration("/app-config.xml")
    @ActiveProfiles("dev")
    public class TransferServiceTest {
    
       @Autowired
       private TransferService transferService;
    
       @Test
       public void testTransferService() {
           // test the transferService
       }
    }
    Last edited by scmikes; Apr 3rd, 2012, 01:42 PM. Reason: correct code markup

  • #2
    I agree:

    A Test fails with Spring 3.1 and profiles due to the lack of an active profile

    Comment

    Working...
    X