Work with Spring 5
Fixes gh-415
This commit is contained in:
@@ -4,7 +4,7 @@ import org.springframework.ldap.core.DirContextAdapter;
|
||||
import org.springframework.ldap.core.DistinguishedName;
|
||||
import org.springframework.ldap.core.LdapTemplate;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
|
||||
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements OrgPersonDao {
|
||||
|
||||
private LdapTemplate ldapTemplate;
|
||||
|
||||
|
||||
public void create(OrgPerson person) {
|
||||
DistinguishedName dn = new DistinguishedName();
|
||||
dn.add("ou", person.getCountry());
|
||||
@@ -28,14 +28,14 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
ctx.setAttributeValue("description", person.getDescription());
|
||||
ldapTemplate.bind(dn, ctx, null);
|
||||
this.getHibernateTemplate().saveOrUpdate(person);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void createWithException(OrgPerson person) {
|
||||
this.create(person);
|
||||
throw new DummyException("This method failed");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void modifyAttributes(String dn, String lastName, String description) {
|
||||
@@ -45,7 +45,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
|
||||
ldapTemplate.modifyAttributes(dn, ctx.getModificationItems());
|
||||
}
|
||||
|
||||
|
||||
public void modifyAttributesWithException(String dn, String lastName,
|
||||
String description) {
|
||||
modifyAttributes(dn, lastName, description);
|
||||
@@ -56,7 +56,7 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
String dn = prepareDn(person);
|
||||
ldapTemplate.unbind(dn);
|
||||
this.getHibernateTemplate().delete(person);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void unbindWithException(OrgPerson person) {
|
||||
@@ -72,22 +72,22 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
this.getHibernateTemplate().saveOrUpdate(person);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateWithException(OrgPerson person) {
|
||||
this.update(person);
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
|
||||
public void updateAndRename(String dn, String newDn, String updatedDescription) {
|
||||
|
||||
|
||||
DirContextAdapter ctx = (DirContextAdapter) ldapTemplate.lookup(dn);
|
||||
ctx.setAttributeValue("description", updatedDescription);
|
||||
|
||||
ldapTemplate.modifyAttributes(ctx);
|
||||
ldapTemplate.rename(dn, newDn);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void updateAndRenameWithException(String dn, String newDn, String updatedDescription) {
|
||||
@@ -95,12 +95,12 @@ public class DummyDaoLdapAndHibernateImpl extends HibernateDaoSupport implements
|
||||
throw new DummyException("This method failed");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void setLdapTemplate(LdapTemplate ldapTemplate) {
|
||||
this.ldapTemplate = ldapTemplate;
|
||||
}
|
||||
|
||||
|
||||
private String prepareDn(OrgPerson person){
|
||||
return "cn=" + person.getFullname() + ",ou=" + person.getCompany() + ",ou=" + person.getCountry();
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class LdapConditionallyFilteredTestRunner extends SpringJUnit4ClassRunner
|
||||
String noadtest = System.getProperty("adtest");
|
||||
if (noadtest != null) {
|
||||
try {
|
||||
filter(new Categories.CategoryFilter(null, NoAdTest.class));
|
||||
filter(Categories.CategoryFilter.exclude(NoAdTest.class));
|
||||
} catch (NoTestsRemainException e) {
|
||||
// Nothing to do here.
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ import java.util.Map;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.transaction.TransactionConfiguration;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
@@ -32,8 +32,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("classpath:ldap321.xml")
|
||||
@TransactionConfiguration(transactionManager = "txManager",defaultRollback = true)
|
||||
@Transactional
|
||||
@Rollback
|
||||
public class Ldap321Test{
|
||||
@Autowired
|
||||
private RoleRepo roleRepo;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.ldap.itest.transaction.compensating.manager.DummyExce
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
|
||||
import org.springframework.ldap.transaction.compensating.manager.ContextSourceAndHibernateTransactionManager;
|
||||
import org.springframework.orm.hibernate3.HibernateTemplate;
|
||||
import org.springframework.orm.hibernate5.HibernateTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
@@ -47,7 +47,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ContextSourceAndHibernateTransactionManager}.
|
||||
*
|
||||
*
|
||||
* @author Hans Westerbeek
|
||||
*/
|
||||
@ContextConfiguration(locations = {"/conf/ldapAndHibernateTransactionTestContext.xml"})
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.ldap.itest.AbstractLdapTemplateIntegrationTest;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.DummyException;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPerson;
|
||||
import org.springframework.ldap.itest.transaction.compensating.manager.hibernate.OrgPersonDao;
|
||||
import org.springframework.orm.hibernate3.HibernateTemplate;
|
||||
import org.springframework.orm.hibernate5.HibernateTemplate;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
<property name="password" value="" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
|
||||
@@ -32,11 +32,11 @@
|
||||
<constructor-arg ref="transactedContextSource" />
|
||||
</bean>
|
||||
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
|
||||
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate5.HibernateTemplate">
|
||||
<property name="sessionFactory" ref="sessionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
|
||||
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
|
||||
<property name="dataSource" ref="dataSource"/>
|
||||
<property name="mappingResources">
|
||||
<list>
|
||||
|
||||
Reference in New Issue
Block a user