oghenez / mycila

Automatically exported from code.google.com/p/mycila
0 stars 0 forks source link

Support Spring javaConfig #15

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Support Spring javaConfig

Original issue reported on code.google.com by mathieu....@gmail.com on 3 Dec 2009 at 5:55

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 3 Dec 2009 at 5:56

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 3 Dec 2009 at 7:57

GoogleCodeExporter commented 8 years ago
This version is available in Maven 2 central repository and contains:

* A fix for Spring Plugin: Spring Test Listeners where not invoked correctly 
for each
test method

Here is an example of test using @Transactional:

@RunWith(MycilaJunitRunner.class)
@SpringContext(locations = "/ctx-tx.xml")
@TransactionConfiguration(transactionManager = "myTransactionManager")
public class SpringTxTest {

    @Autowired
    Dao dao;

    @Test
    @Transactional
    public void test() {
        dao.save();
    }
}

* The name attribute of @Bean annotation is now optional. If not provided, the 
name
of the field or method is used.

@Bean
String abean = "helloa";

* Spring Java config is now supported in @SpringContext annotation through the
classes attribute:

@RunWith(MycilaJunitRunner.class)
@SpringContext(locations = "/ctx-autowired2.xml", classes = MyJavaConfig.class)
@TransactionConfiguration(transactionManager = "myTransactionManager")
public class SpringJavaConfigTest {

    @Autowired
    Dao dao;

    @Autowired
    Autowired2Bean autowired2Bean;

    @Test
    @Transactional
    public void test() {
        assertNotNull(dao);
        assertNotNull(autowired2Bean);
        assertNotNull(autowired2Bean.dao);
        dao.save();
    }
}

Original comment by mathieu....@gmail.com on 4 Dec 2009 at 3:20