When running my test, it hangs at the call to method(). Am I doing something wrong? Help!
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"beans.xml"})
@Transactional(rollbackFor = Exception.class)
public class Test {
@Test
public void test() {
itemUnderTestDao.method();
// ...
}
}
public class ItemUnderTestDao {
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void method() {
// ...
}
}
Forget the above code. I have now uploaded an Eclipse project (excluding dependencies like spring) at http://www44.zippyshare.com/v/46865082/file.html. All input on how to get the test to pass is really appreciated! The test pass if I have two sqlite databases and two dataSources…
As mrembisz said you are trying to get 2 connections at the same time/thread.
I encountered the same thing in a little bit different circumstances.
2 ways you can fix this:
REQUIRED, this way you would reuse Connection that test originally acquired.maxThreadPoolSize >= (maxSimultaniousUpdates + 1) + (min size for other activities)(If you have at list 1 pending connection, eventually all pending operations would complete). Othrewise this would reappear in production.First solution seems to me better one, ofcourse if it does not harm your logic 🙂