Closed
Description
Andy Kriger opened SPR-4541 and commented
Create a class for this source and run it as a unit test.
- EXPECT: Both tests pass
- ACTUAL: withTimeout fails
import org.junit.*;
import org.junit.runner.RunWith;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.hibernate.SessionFactory;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
/* !!! YOU NEED A SPRING CONFIG THAT DEFINES A SESSIONFACTORY & TXMANAGER !!! */
})
@Transactional
public class SpringBug {
@Autowired
protected SessionFactory sessionFactory;
@Test
public void withoutTimeout() {
sessionFactory.getCurrentSession();
}
@Test(timeout = 60000)
public void withTimeout() {
sessionFactory.getCurrentSession();
}
}
Affects: 2.5.1
Issue Links:
- Support programmatic starting and stopping of transactions in the TestContext framework [SPR-5079] #9753 Support programmatic starting and stopping of transactions in the TestContext framework