@Test
lic void testTransactionSuspension_UnconnectableDataSource() throws Exception {

nnection connectionMock = mock(Connection.class);
taSource dataSourceMock = mock(DataSource.class);
en(dataSourceMock.getConnection()).thenReturn(connectionMock);
en(connectionMock.getAutoCommit()).thenReturn(false);
ntextSource unconnectableContextSourceMock = mock(ContextSource.class);
categorizedLdapException connectException = new UncategorizedLdapException("dummy");
en(unconnectableContextSourceMock.getReadWriteContext()).thenThrow(connectException);
y {
/ Create an outer transaction
inal PlatformTransactionManager txMgrOuter = new DataSourceTransactionManager(dataSourceMock);
inal TransactionStatus txOuter = txMgrOuter.getTransaction(new DefaultTransactionDefinition());
ry {
// Create inner transaction (not nested, though: unrelated data
// source)
final ContextSourceTransactionManager txMgrInner = new ContextSourceTransactionManager();
txMgrInner.setContextSource(unconnectableContextSourceMock);
final TransactionStatus txInner = txMgrInner.getTransaction(new DefaultTransactionDefinition(
		TransactionDefinition.PROPAGATION_REQUIRES_NEW));
try {
	// Do something with the connection that succeeds or fails
	// (but we dont get this far)
	// etc, etc...
	txMgrInner.commit(txInner);
}
catch (Exception e) {
	txMgrInner.rollback(txInner);
	throw e;
}
txMgrOuter.commit(txOuter);

atch (Exception e) {
txMgrOuter.rollback(txOuter);
throw e;

ail("Exception should be thrown");
tch (CannotCreateTransactionException expected) {
ssertThat(expected.getCause()).as("Should be thrown exception").isSameAs(connectException);
    verify(connectionMock).rollback();
}