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 } }


Reply With Quote